-
-
Notifications
You must be signed in to change notification settings - Fork 402
Expand file tree
/
Copy pathGitLockFailedExceptionTest.java
More file actions
49 lines (42 loc) · 1.81 KB
/
GitLockFailedExceptionTest.java
File metadata and controls
49 lines (42 loc) · 1.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package hudson.plugins.git;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.nullValue;
import static org.junit.jupiter.api.Assertions.assertThrows;
import org.junit.jupiter.api.Test;
class GitLockFailedExceptionTest {
@Test
void throwsGitLockFailedException() {
GitLockFailedException lockFailed = assertThrows(GitLockFailedException.class, () -> {
throw new GitLockFailedException();
});
assertThat(lockFailed.getMessage(), is(nullValue()));
}
@Test
void throwsGitLockFailedExceptionWithMessage() {
String message = "My local exception message";
GitLockFailedException lockFailed = assertThrows(GitLockFailedException.class, () -> {
throw new GitLockFailedException(message);
});
assertThat(lockFailed.getMessage(), is(message));
}
@Test
void throwsGitLockFailedExceptionWithCause() {
String message = "My git exception message";
GitException e = new GitException(message);
GitLockFailedException lockFailed = assertThrows(GitLockFailedException.class, () -> {
throw new GitLockFailedException(e);
});
assertThat(lockFailed.getMessage(), is("hudson.plugins.git.GitException: " + message));
}
@Test
void throwsGitLockFailedExceptionWithCauseAndMessage() {
String message = "My git exception message";
GitException e = new GitException(message);
String lockMessage = "My lock message that is not part of the GitException";
GitLockFailedException lockFailed = assertThrows(GitLockFailedException.class, () -> {
throw new GitLockFailedException(lockMessage, e);
});
assertThat(lockFailed.getMessage(), is(lockMessage));
}
}