Skip to content

Commit f6e8a2c

Browse files
authored
Merge pull request #1123 from bitwiseman/task/assertThat
Move to using assertThat() exclusively
2 parents 2be27d1 + 76bea51 commit f6e8a2c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+959
-964
lines changed

src/test/java/org/kohsuke/github/AbstractGitHubWireMockTest.java

Lines changed: 13 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,9 @@
44
import com.github.tomakehurst.wiremock.extension.responsetemplating.ResponseTemplateTransformer;
55
import com.github.tomakehurst.wiremock.extension.responsetemplating.helpers.HandlebarsCurrentDateHelper;
66
import org.apache.commons.io.IOUtils;
7-
import org.hamcrest.Description;
87
import org.hamcrest.Matcher;
8+
import org.hamcrest.MatcherAssert;
99
import org.hamcrest.Matchers;
10-
import org.hamcrest.StringDescription;
1110
import org.junit.After;
1211
import org.junit.Assert;
1312
import org.junit.Before;
@@ -21,13 +20,14 @@
2120
import java.io.IOException;
2221
import java.util.*;
2322

23+
import static org.hamcrest.Matchers.*;
2424
import static org.junit.Assume.assumeFalse;
2525
import static org.junit.Assume.assumeTrue;
2626

2727
/**
2828
* @author Liam Newman
2929
*/
30-
public abstract class AbstractGitHubWireMockTest extends Assert {
30+
public abstract class AbstractGitHubWireMockTest {
3131

3232
private final GitHubBuilder githubBuilder = createGitHubBuilder();
3333

@@ -255,52 +255,23 @@ private String getOrganization() throws IOException {
255255
return mockGitHub.isTestWithOrg() ? GITHUB_API_TEST_ORG : gitHub.getMyself().getLogin();
256256
}
257257

258-
public static <T> void assertThat(T actual, Matcher<? super T> matcher) {
259-
assertThat("", actual, matcher);
258+
public static void fail() {
259+
Assert.fail();
260260
}
261-
262-
public static <T> void assertThat(String reason, T actual, Matcher<? super T> matcher) {
263-
if (!matcher.matches(actual)) {
264-
Description description = new StringDescription();
265-
description.appendText(reason)
266-
.appendText(System.lineSeparator())
267-
.appendText("Expected: ")
268-
.appendDescriptionOf(matcher)
269-
.appendText(System.lineSeparator())
270-
.appendText(" but: ");
271-
matcher.describeMismatch(actual, description);
272-
throw new AssertionError(description.toString());
273-
}
261+
public static void fail(String reason) {
262+
Assert.fail(reason);
274263
}
275264

276-
public static void assertThat(String reason, boolean assertion) {
277-
if (!assertion) {
278-
throw new AssertionError(reason);
279-
}
280-
}
281-
282-
public static void assertEquals(Object expected, Object actual) {
283-
assertThat(actual, Matchers.equalTo(expected));
284-
}
285-
286-
public static void assertNotEquals(Object expected, Object actual) {
287-
assertThat(actual, Matchers.not(expected));
288-
}
289-
290-
public static void assertNotNull(Object actual) {
291-
assertThat(actual, Matchers.notNullValue());
292-
}
293-
294-
public static void assertNull(Object actual) {
295-
assertThat(actual, Matchers.nullValue());
265+
public static <T> void assertThat(T actual, Matcher<? super T> matcher) {
266+
MatcherAssert.assertThat("", actual, matcher);
296267
}
297268

298-
public static void assertTrue(Boolean condition) {
299-
assertThat(condition, Matchers.is(true));
269+
public static <T> void assertThat(String reason, T actual, Matcher<? super T> matcher) {
270+
MatcherAssert.assertThat(reason, actual, matcher);
300271
}
301272

302-
public static void assertFalse(Boolean condition) {
303-
assertThat(condition, Matchers.is(false));
273+
public static void assertThat(String reason, boolean assertion) {
274+
MatcherAssert.assertThat(reason, assertion);
304275
}
305276

306277
protected static class TemplatingHelper {

0 commit comments

Comments
 (0)