More assertThat matchers

This commit is contained in:
Liam Newman
2021-04-20 12:34:01 -07:00
parent b550910f4c
commit cd1454ac03
2 changed files with 9 additions and 12 deletions

View File

@@ -31,10 +31,7 @@ public class Github2faTest extends AbstractGitHubWireMockTest {
});
assertThat(token, notNullValue());
for (int i = 0; i < asList.size(); i++) {
assertThat(token.getScopes().get(i).contentEquals(asList.get(i)), is(true));
}
assertThat(token.getScopes(), contains(asList.toArray()));
assertThat(token.getToken(), equalTo("63042a99d88bf138e6d6cf5788e0dc4e7a5d7309"));
assertThat(token.getTokenLastEight(), equalTo("7a5d7309"));

View File

@@ -373,16 +373,16 @@ public class RequesterRetryTest extends AbstractGitHubWireMockTest {
baseRequestCount = this.mockGitHub.getRequestCount();
assertThat(this.gitHub.getOrganization(GITHUB_API_TEST_ORG), is(notNullValue()));
String capturedLog = getTestCapturedLog();
assertThat(capturedLog.contains("will try 2 more time"), is(true));
assertThat(capturedLog.contains("will try 1 more time"), is(true));
assertThat(capturedLog, containsString("will try 2 more time"));
assertThat(capturedLog, containsString("will try 1 more time"));
assertThat(this.mockGitHub.getRequestCount(), equalTo(baseRequestCount + expectedRequestCount));
resetTestCapturedLog();
baseRequestCount = this.mockGitHub.getRequestCount();
this.gitHub.createRequest().withUrlPath("/orgs/" + GITHUB_API_TEST_ORG).send();
capturedLog = getTestCapturedLog();
assertThat(capturedLog.contains("will try 2 more time"), is(true));
assertThat(capturedLog.contains("will try 1 more time"), is(true));
assertThat(capturedLog, containsString("will try 2 more time"));
assertThat(capturedLog, containsString("will try 1 more time"));
assertThat(this.mockGitHub.getRequestCount(), equalTo(baseRequestCount + expectedRequestCount));
}
@@ -399,13 +399,13 @@ public class RequesterRetryTest extends AbstractGitHubWireMockTest {
equalTo(200));
String capturedLog = getTestCapturedLog();
if (expectedRequestCount > 0) {
assertThat(capturedLog.contains("will try 2 more time"), is(true));
assertThat(capturedLog.contains("will try 1 more time"), is(true));
assertThat(capturedLog, containsString("will try 2 more time"));
assertThat(capturedLog, containsString("will try 1 more time"));
assertThat(this.mockGitHub.getRequestCount(), equalTo(baseRequestCount + expectedRequestCount));
} else {
// Success without retries
assertThat(capturedLog.contains("will try 2 more time"), is(false));
assertThat(capturedLog.contains("will try 1 more time"), is(false));
assertThat(capturedLog, not(containsString("will try 2 more time")));
assertThat(capturedLog, not(containsString("will try 1 more time")));
assertThat(this.mockGitHub.getRequestCount(), equalTo(baseRequestCount + 1));
}
}