Acceptance Tests: use hasSize assertion to verify expected list sizes

Instead of:

  assertThat(list.size()).isEqualTo(n);

do:

  assertThat(list).hasSize(n);

Change-Id: I166e445b87c733462d12567bd97580f481cf8129
This commit is contained in:
David Pursehouse
2015-04-30 14:24:38 +09:00
parent 9e471a9bca
commit fc4c1325d8
4 changed files with 5 additions and 5 deletions

View File

@@ -67,12 +67,12 @@ public class AccountIT extends AbstractDaemonTest {
String adminUsername = "admin";
List<AccountInfo> result = gApi.accounts()
.suggestAccounts().withQuery(adminUsername).get();
assertThat(result.size()).isEqualTo(1);
assertThat(result).hasSize(1);
assertThat(result.get(0).username).isEqualTo(adminUsername);
List<AccountInfo> resultShortcutApi = gApi.accounts()
.suggestAccounts(adminUsername).get();
assertThat(resultShortcutApi.size()).isEqualTo(result.size());
assertThat(resultShortcutApi).hasSize(result.size());
List<AccountInfo> emptyResult = gApi.accounts()
.suggestAccounts("unknown").get();

View File

@@ -71,7 +71,7 @@ public class DeleteDraftPatchSetIT extends AbstractDaemonTest {
assertThat(c.status).isEqualTo(ChangeStatus.DRAFT);
RestResponse r = deletePatchSet(changeId, ps, adminSession);
assertThat(r.getStatusCode()).isEqualTo(HttpStatus.SC_NO_CONTENT);
assertThat(getChange(changeId).patches().size()).isEqualTo(1);
assertThat(getChange(changeId).patches()).hasSize(1);
ps = getCurrentPatchSet(changeId);
r = deletePatchSet(changeId, ps, adminSession);
assertThat(r.getStatusCode()).isEqualTo(HttpStatus.SC_NO_CONTENT);

View File

@@ -93,7 +93,7 @@ public class GarbageCollectionIT extends AbstractDaemonTest {
GarbageCollectionResult result = garbageCollectionFactory.create().run(
Arrays.asList(allProjects, project, project2, project3));
assertThat(result.hasErrors()).isTrue();
assertThat(result.getErrors().size()).isEqualTo(1);
assertThat(result.getErrors()).hasSize(1);
GarbageCollectionResult.Error error = result.getErrors().get(0);
assertThat(error.getType()).isEqualTo(
GarbageCollectionResult.Error.Type.GC_ALREADY_SCHEDULED);

View File

@@ -62,6 +62,6 @@ public class JschVerifyFalseBugIT extends AbstractDaemonTest {
for (Future<Void> future : futures) {
future.get();
}
assertThat(futures.size()).isEqualTo(threads);
assertThat(futures).hasSize(threads);
}
}