From 2d726dd3d27ed398da065d865433c060d961423e Mon Sep 17 00:00:00 2001 From: Dave Borowitz Date: Wed, 29 Apr 2015 14:27:31 -0700 Subject: [PATCH] Upgrade Truth to 0.26 Un-deprecates CollectionSubject, removing the need for many Iterable casts. Removes the Subject.is() method, which is replaced by either isEqualTo or isSameAs. Change-Id: I58d725b3cc84947e98a1f9b18cc8d2d160f01c97 --- .../acceptance/api/accounts/AccountIT.java | 4 ++-- .../acceptance/api/change/ChangeIT.java | 24 +++++++++---------- .../gerrit/acceptance/api/group/GroupsIT.java | 2 +- .../acceptance/api/revision/RevisionIT.java | 18 +++++++------- .../acceptance/git/AbstractPushForReview.java | 12 +++++----- .../gerrit/acceptance/git/SubmitOnPushIT.java | 2 +- .../acceptance/git/VisibleRefFilterIT.java | 4 ++-- .../rest/change/AbstractSubmit.java | 4 ++-- .../rest/change/ChangeMessagesIT.java | 10 ++++---- .../acceptance/rest/change/HashtagsIT.java | 2 +- .../rest/change/ListChangesOptionsIT.java | 6 ++--- .../rest/project/ProjectAssert.java | 2 +- .../gerrit/server/change/HashtagsTest.java | 24 +++++++++---------- .../git/LocalDiskRepositoryManagerTest.java | 8 +++---- .../change/AbstractQueryChangesTest.java | 3 +-- lib/BUCK | 4 ++-- 16 files changed, 64 insertions(+), 65 deletions(-) diff --git a/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/api/accounts/AccountIT.java b/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/api/accounts/AccountIT.java index f084b98571..0e824e9adc 100644 --- a/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/api/accounts/AccountIT.java +++ b/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/api/accounts/AccountIT.java @@ -67,12 +67,12 @@ public class AccountIT extends AbstractDaemonTest { String adminUsername = "admin"; List result = gApi.accounts() .suggestAccounts().withQuery(adminUsername).get(); - assertThat(result.size()).is(1); + assertThat(result.size()).isEqualTo(1); assertThat(result.get(0).username).isEqualTo(adminUsername); List resultShortcutApi = gApi.accounts() .suggestAccounts(adminUsername).get(); - assertThat(resultShortcutApi.size()).is(result.size()); + assertThat(resultShortcutApi.size()).isEqualTo(result.size()); List emptyResult = gApi.accounts() .suggestAccounts("unknown").get(); diff --git a/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/api/change/ChangeIT.java b/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/api/change/ChangeIT.java index f87349a045..bd01e34b2d 100644 --- a/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/api/change/ChangeIT.java +++ b/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/api/change/ChangeIT.java @@ -60,9 +60,9 @@ public class ChangeIT extends AbstractDaemonTest { assertThat(c.mergeable).isTrue(); assertThat(c.changeId).isEqualTo(r.getChangeId()); assertThat(c.created).isEqualTo(c.updated); - assertThat(c._number).is(r.getChange().getId().get()); + assertThat(c._number).isEqualTo(r.getChange().getId().get()); - assertThat(c.owner._accountId).is(admin.getId().get()); + assertThat(c.owner._accountId).isEqualTo(admin.getId().get()); assertThat(c.owner.name).isNull(); assertThat(c.owner.email).isNull(); assertThat(c.owner.username).isNull(); @@ -128,7 +128,7 @@ public class ChangeIT extends AbstractDaemonTest { .revision(r3.getCommit().name()) .rebase(ri); PatchSet ps3 = r3.getPatchSet(); - assertThat(ps3.getId().get()).is(2); + assertThat(ps3.getId().get()).isEqualTo(2); // rebase r2 onto r3 (referenced by ref) ri.base = ps3.getId().toRefName(); @@ -137,7 +137,7 @@ public class ChangeIT extends AbstractDaemonTest { .revision(r2.getCommit().name()) .rebase(ri); PatchSet ps2 = r2.getPatchSet(); - assertThat(ps2.getId().get()).is(2); + assertThat(ps2.getId().get()).isEqualTo(2); // rebase r1 onto r2 (referenced by commit) ri.base = ps2.getRevision().get(); @@ -146,7 +146,7 @@ public class ChangeIT extends AbstractDaemonTest { .revision(r1.getCommit().name()) .rebase(ri); PatchSet ps1 = r1.getPatchSet(); - assertThat(ps1.getId().get()).is(2); + assertThat(ps1.getId().get()).isEqualTo(2); // rebase r1 onto r3 (referenced by change number) ri.base = String.valueOf(r3.getChange().getId().get()); @@ -154,7 +154,7 @@ public class ChangeIT extends AbstractDaemonTest { .id(r1.getChangeId()) .revision(ps1.getRevision().get()) .rebase(ri); - assertThat(r1.getPatchSetId().get()).is(3); + assertThat(r1.getPatchSetId().get()).isEqualTo(3); } @Test(expected = ResourceConflictException.class) @@ -190,7 +190,7 @@ public class ChangeIT extends AbstractDaemonTest { .id(r.getChangeId()) .addReviewer(in); - assertThat((Iterable)getReviewers(r.getChangeId())) + assertThat(getReviewers(r.getChangeId())) .containsExactlyElementsIn(ImmutableSet.of(user.id)); } @@ -206,7 +206,7 @@ public class ChangeIT extends AbstractDaemonTest { .revision(r.getCommit().name()) .submit(); - assertThat((Iterable)getReviewers(r.getChangeId())) + assertThat(getReviewers(r.getChangeId())) .containsExactlyElementsIn(ImmutableSet.of(admin.getId())); AddReviewerInput in = new AddReviewerInput(); @@ -214,7 +214,7 @@ public class ChangeIT extends AbstractDaemonTest { gApi.changes() .id(r.getChangeId()) .addReviewer(in); - assertThat((Iterable)getReviewers(r.getChangeId())) + assertThat(getReviewers(r.getChangeId())) .containsExactlyElementsIn(ImmutableSet.of(admin.getId(), user.id)); } @@ -293,7 +293,7 @@ public class ChangeIT extends AbstractDaemonTest { PushOneCommit.Result r = createChange(); ChangeInfo result = Iterables.getOnlyElement(query(r.getChangeId())); assertThat(result.labels).isNull(); - assertThat((Iterable)result.messages).isNull(); + assertThat(result.messages).isNull(); assertThat(result.revisions).isNull(); assertThat(result.actions).isNull(); } @@ -307,13 +307,13 @@ public class ChangeIT extends AbstractDaemonTest { .get()); assertThat(Iterables.getOnlyElement(result.labels.keySet())) .isEqualTo("Code-Review"); - assertThat((Iterable)result.messages).hasSize(1); + assertThat(result.messages).hasSize(1); assertThat(result.actions).isNotEmpty(); RevisionInfo rev = Iterables.getOnlyElement(result.revisions.values()); assertThat(rev._number).isEqualTo(r.getPatchSetId().get()); assertThat(rev.created).isNotNull(); - assertThat(rev.uploader._accountId).is(admin.getId().get()); + assertThat(rev.uploader._accountId).isEqualTo(admin.getId().get()); assertThat(rev.ref).isEqualTo(r.getPatchSetId().toRefName()); assertThat(rev.actions).isNotEmpty(); } diff --git a/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/api/group/GroupsIT.java b/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/api/group/GroupsIT.java index e90b28e1a8..8ed416513a 100644 --- a/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/api/group/GroupsIT.java +++ b/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/api/group/GroupsIT.java @@ -387,7 +387,7 @@ public class GroupsIT extends AbstractDaemonTest { } }).toSortedList(Ordering.natural()); assertThat(expectedGroups.size()).isAtLeast(2); - assertThat((Iterable) gApi.groups().list().getAsMap().keySet()) + assertThat(gApi.groups().list().getAsMap().keySet()) .containsExactlyElementsIn(expectedGroups).inOrder(); } diff --git a/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/api/revision/RevisionIT.java b/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/api/revision/RevisionIT.java index 1ebae6038d..79460fd895 100644 --- a/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/api/revision/RevisionIT.java +++ b/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/api/revision/RevisionIT.java @@ -153,10 +153,10 @@ public class RevisionIT extends AbstractDaemonTest { ChangeApi orig = gApi.changes() .id(project.get() + "~master~" + r.getChangeId()); - assertThat((Iterable)orig.get().messages).hasSize(1); + assertThat(orig.get().messages).hasSize(1); ChangeApi cherry = orig.revision(r.getCommit().name()) .cherryPick(in); - assertThat((Iterable)orig.get().messages).hasSize(2); + assertThat(orig.get().messages).hasSize(2); String cherryPickedRevision = cherry.get().currentRevision; String expectedMessage = String.format( @@ -168,7 +168,7 @@ public class RevisionIT extends AbstractDaemonTest { origIt.next(); assertThat(origIt.next().message).isEqualTo(expectedMessage); - assertThat((Iterable)cherry.get().messages).hasSize(1); + assertThat(cherry.get().messages).hasSize(1); Iterator cherryIt = cherry.get().messages.iterator(); expectedMessage = "Patch Set 1: Cherry Picked from branch master."; assertThat(cherryIt.next().message).isEqualTo(expectedMessage); @@ -190,7 +190,7 @@ public class RevisionIT extends AbstractDaemonTest { .revision(r.getCommit().name()) .cherryPick(in) .get(); - assertThat((Iterable)cherryInfo.messages).hasSize(2); + assertThat(cherryInfo.messages).hasSize(2); Iterator cherryIt = cherryInfo.messages.iterator(); assertThat(cherryIt.next().message).isEqualTo("Uploaded patch set 1."); assertThat(cherryIt.next().message).isEqualTo("Uploaded patch set 2."); @@ -228,7 +228,7 @@ public class RevisionIT extends AbstractDaemonTest { in.message = subject; ChangeApi cherry = orig.revision(r2.getCommit().name()).cherryPick(in); ChangeInfo cherryInfo = cherry.get(); - assertThat((Iterable)cherryInfo.messages).hasSize(2); + assertThat(cherryInfo.messages).hasSize(2); Iterator cherryIt = cherryInfo.messages.iterator(); assertThat(cherryIt.next().message).isEqualTo("Uploaded patch set 1."); assertThat(cherryIt.next().message).isEqualTo("Uploaded patch set 2."); @@ -253,10 +253,10 @@ public class RevisionIT extends AbstractDaemonTest { ChangeApi orig = gApi.changes() .id(project.get() + "~master~" + r.getChangeId()); - assertThat((Iterable)orig.get().messages).hasSize(1); + assertThat(orig.get().messages).hasSize(1); ChangeApi cherry = orig.revision(r.getCommit().name()) .cherryPick(in); - assertThat((Iterable)orig.get().messages).hasSize(2); + assertThat(orig.get().messages).hasSize(2); assertThat(cherry.get().subject).contains(in.message); cherry.current().review(ReviewInput.approve()); @@ -288,7 +288,7 @@ public class RevisionIT extends AbstractDaemonTest { String triplet = project.get() + "~master~" + r.getChangeId(); ChangeApi orig = gApi.changes().id(triplet); - assertThat((Iterable)orig.get().messages).hasSize(1); + assertThat(orig.get().messages).hasSize(1); try { orig.revision(r.getCommit().name()).cherryPick(in); @@ -345,7 +345,7 @@ public class RevisionIT extends AbstractDaemonTest { .current() .setReviewed(PushOneCommit.FILE_NAME, false); - assertThat((Iterable)gApi.changes().id(r.getChangeId()).current().reviewed()) + assertThat(gApi.changes().id(r.getChangeId()).current().reviewed()) .isEmpty(); } diff --git a/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/git/AbstractPushForReview.java b/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/git/AbstractPushForReview.java index 880ad29583..2323270fa9 100644 --- a/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/git/AbstractPushForReview.java +++ b/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/git/AbstractPushForReview.java @@ -175,7 +175,7 @@ public abstract class AbstractPushForReview extends AbstractDaemonTest { LabelInfo cr = ci.labels.get("Code-Review"); assertThat(cr.all).hasSize(1); assertThat(cr.all.get(0).name).isEqualTo("Administrator"); - assertThat(cr.all.get(0).value).is(1); + assertThat(cr.all.get(0).value).isEqualTo(1); PushOneCommit push = pushFactory.create(db, admin.getIdent(), testRepo, PushOneCommit.SUBJECT, @@ -186,7 +186,7 @@ public abstract class AbstractPushForReview extends AbstractDaemonTest { cr = ci.labels.get("Code-Review"); assertThat(cr.all).hasSize(1); assertThat(cr.all.get(0).name).isEqualTo("Administrator"); - assertThat(cr.all.get(0).value).is(2); + assertThat(cr.all.get(0).value).isEqualTo(2); } @Test @@ -233,7 +233,7 @@ public abstract class AbstractPushForReview extends AbstractDaemonTest { r.assertChange(Change.Status.NEW, null); Set hashtags = gApi.changes().id(r.getChangeId()).getHashtags(); - assertThat((Iterable)hashtags).containsExactlyElementsIn(expected); + assertThat(hashtags).containsExactlyElementsIn(expected); // specify a single hashtag as option in new patch set String hashtag2 = "tag2"; @@ -244,7 +244,7 @@ public abstract class AbstractPushForReview extends AbstractDaemonTest { r.assertOkStatus(); expected = ImmutableSet.of(hashtag1, hashtag2); hashtags = gApi.changes().id(r.getChangeId()).getHashtags(); - assertThat((Iterable)hashtags).containsExactlyElementsIn(expected); + assertThat(hashtags).containsExactlyElementsIn(expected); } @Test @@ -263,7 +263,7 @@ public abstract class AbstractPushForReview extends AbstractDaemonTest { r.assertChange(Change.Status.NEW, null); Set hashtags = gApi.changes().id(r.getChangeId()).getHashtags(); - assertThat((Iterable)hashtags).containsExactlyElementsIn(expected); + assertThat(hashtags).containsExactlyElementsIn(expected); // specify multiple hashtags as options in new patch set String hashtag3 = "tag3"; @@ -275,7 +275,7 @@ public abstract class AbstractPushForReview extends AbstractDaemonTest { r.assertOkStatus(); expected = ImmutableSet.of(hashtag1, hashtag2, hashtag3, hashtag4); hashtags = gApi.changes().id(r.getChangeId()).getHashtags(); - assertThat((Iterable)hashtags).containsExactlyElementsIn(expected); + assertThat(hashtags).containsExactlyElementsIn(expected); } @Test diff --git a/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/git/SubmitOnPushIT.java b/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/git/SubmitOnPushIT.java index 207c6b101a..5066e6664f 100644 --- a/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/git/SubmitOnPushIT.java +++ b/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/git/SubmitOnPushIT.java @@ -253,7 +253,7 @@ public class SubmitOnPushIT extends AbstractDaemonTest { try (Repository r = repoManager.openRepository(project); RevWalk rw = new RevWalk(r)) { RevCommit c = rw.parseCommit(r.getRef(branch).getObjectId()); - assertThat(c.getParentCount()).is(2); + assertThat(c.getParentCount()).isEqualTo(2); assertThat(c.getShortMessage()).isEqualTo("Merge \"" + subject + "\""); assertThat(c.getAuthorIdent().getEmailAddress()).isEqualTo(admin.email); assertThat(c.getCommitterIdent().getEmailAddress()).isEqualTo( diff --git a/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/git/VisibleRefFilterIT.java b/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/git/VisibleRefFilterIT.java index f52effd79b..0b07b87cef 100644 --- a/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/git/VisibleRefFilterIT.java +++ b/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/git/VisibleRefFilterIT.java @@ -280,7 +280,7 @@ public class VisibleRefFilterIT extends AbstractDaemonTest { } Splitter s = Splitter.on(CharMatcher.WHITESPACE).omitEmptyStrings(); - assertThat(filtered).containsSequence( - Ordering.natural().sortedCopy(s.split(out))); + assertThat(filtered).containsExactlyElementsIn( + Ordering.natural().sortedCopy(s.split(out))).inOrder(); } } diff --git a/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/rest/change/AbstractSubmit.java b/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/rest/change/AbstractSubmit.java index e6c5e97953..a07bde7e86 100644 --- a/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/rest/change/AbstractSubmit.java +++ b/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/rest/change/AbstractSubmit.java @@ -152,8 +152,8 @@ public abstract class AbstractSubmit extends AbstractDaemonTest { private void assertSubmitter(PushOneCommit.Result change) throws Exception { ChangeInfo info = get(change.getChangeId(), ListChangesOption.MESSAGES); - assertThat((Iterable)info.messages).isNotNull(); - assertThat((Iterable)info.messages).hasSize(3); + assertThat(info.messages).isNotNull(); + assertThat(info.messages).hasSize(3); if (getSubmitType() == SubmitType.CHERRY_PICK) { assertThat(Iterables.getLast(info.messages).message).startsWith( "Change has been successfully cherry-picked as "); diff --git a/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/rest/change/ChangeMessagesIT.java b/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/rest/change/ChangeMessagesIT.java index 3c763551ef..a56a7f2e82 100644 --- a/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/rest/change/ChangeMessagesIT.java +++ b/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/rest/change/ChangeMessagesIT.java @@ -73,15 +73,15 @@ public class ChangeMessagesIT extends AbstractDaemonTest { String changeId = createChange().getChangeId(); postMessage(changeId, "Some nits need to be fixed."); ChangeInfo c = info(changeId); - assertThat((Iterable)c.messages).isNull(); + assertThat(c.messages).isNull(); } @Test public void defaultMessage() throws Exception { String changeId = createChange().getChangeId(); ChangeInfo c = get(changeId); - assertThat((Iterable)c.messages).isNotNull(); - assertThat((Iterable)c.messages).hasSize(1); + assertThat(c.messages).isNotNull(); + assertThat(c.messages).hasSize(1); assertThat(c.messages.iterator().next().message) .isEqualTo("Uploaded patch set 1."); } @@ -94,8 +94,8 @@ public class ChangeMessagesIT extends AbstractDaemonTest { String secondMessage = "I like this feature."; postMessage(changeId, secondMessage); ChangeInfo c = get(changeId); - assertThat((Iterable)c.messages).isNotNull(); - assertThat((Iterable)c.messages).hasSize(3); + assertThat(c.messages).isNotNull(); + assertThat(c.messages).hasSize(3); Iterator it = c.messages.iterator(); assertThat(it.next().message).isEqualTo("Uploaded patch set 1."); assertMessage(firstMessage, it.next().message); diff --git a/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/rest/change/HashtagsIT.java b/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/rest/change/HashtagsIT.java index 5f46312c28..6ef53ffadc 100644 --- a/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/rest/change/HashtagsIT.java +++ b/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/rest/change/HashtagsIT.java @@ -196,7 +196,7 @@ public class HashtagsIT extends AbstractDaemonTest { ? extends IterableSubject>, String, Iterable> assertThatGet(PushOneCommit.Result r) throws Exception { - return assertThat((Iterable) gApi.changes() + return assertThat(gApi.changes() .id(r.getChange().getId().get()) .getHashtags()); } diff --git a/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/rest/change/ListChangesOptionsIT.java b/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/rest/change/ListChangesOptionsIT.java index 63e5627d81..3728a51ddd 100644 --- a/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/rest/change/ListChangesOptionsIT.java +++ b/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/rest/change/ListChangesOptionsIT.java @@ -68,7 +68,7 @@ public class ListChangesOptionsIT extends AbstractDaemonTest { public void currentRevision() throws Exception { ChangeInfo c = get(changeId, CURRENT_REVISION); assertThat(c.currentRevision).isEqualTo(commitId(2)); - assertThat((Iterable)c.revisions.keySet()).containsAllIn( + assertThat(c.revisions.keySet()).containsAllIn( ImmutableSet.of(commitId(2))); assertThat(c.revisions.get(commitId(2))._number).isEqualTo(3); } @@ -78,7 +78,7 @@ public class ListChangesOptionsIT extends AbstractDaemonTest { ChangeInfo c = get(changeId, CURRENT_REVISION, MESSAGES); assertThat(c.revisions).hasSize(1); assertThat(c.currentRevision).isEqualTo(commitId(2)); - assertThat((Iterable)c.revisions.keySet()).containsAllIn( + assertThat(c.revisions.keySet()).containsAllIn( ImmutableSet.of(commitId(2))); assertThat(c.revisions.get(commitId(2))._number).isEqualTo(3); } @@ -87,7 +87,7 @@ public class ListChangesOptionsIT extends AbstractDaemonTest { public void allRevisions() throws Exception { ChangeInfo c = get(changeId, ALL_REVISIONS); assertThat(c.currentRevision).isEqualTo(commitId(2)); - assertThat((Iterable)c.revisions.keySet()).containsAllIn( + assertThat(c.revisions.keySet()).containsAllIn( ImmutableSet.of(commitId(0), commitId(1), commitId(2))); assertThat(c.revisions.get(commitId(0))._number).isEqualTo(1); assertThat(c.revisions.get(commitId(1))._number).isEqualTo(2); diff --git a/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/rest/project/ProjectAssert.java b/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/rest/project/ProjectAssert.java index 504f5d7c1f..db6df957e0 100644 --- a/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/rest/project/ProjectAssert.java +++ b/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/rest/project/ProjectAssert.java @@ -75,6 +75,6 @@ public class ProjectAssert { for (AccountGroup.UUID g : state.getOwners()) { assertThat(expectedOwners.remove(g)).isTrue(); } - assertThat((Iterable)expectedOwners).isEmpty(); + assertThat(expectedOwners).isEmpty(); } } diff --git a/gerrit-server/src/test/java/com/google/gerrit/server/change/HashtagsTest.java b/gerrit-server/src/test/java/com/google/gerrit/server/change/HashtagsTest.java index d5b722c354..6100ffd8a6 100644 --- a/gerrit-server/src/test/java/com/google/gerrit/server/change/HashtagsTest.java +++ b/gerrit-server/src/test/java/com/google/gerrit/server/change/HashtagsTest.java @@ -23,45 +23,45 @@ import org.junit.Test; public class HashtagsTest { @Test public void emptyCommitMessage() throws Exception { - assertThat((Iterable)HashtagsUtil.extractTags("")).isEmpty(); + assertThat(HashtagsUtil.extractTags("")).isEmpty(); } @Test public void nullCommitMessage() throws Exception { - assertThat((Iterable)HashtagsUtil.extractTags(null)).isEmpty(); + assertThat(HashtagsUtil.extractTags(null)).isEmpty(); } @Test public void noHashtags() throws Exception { String commitMessage = "Subject\n\nLine 1\n\nLine 2"; - assertThat((Iterable)HashtagsUtil.extractTags(commitMessage)).isEmpty(); + assertThat(HashtagsUtil.extractTags(commitMessage)).isEmpty(); } @Test public void singleHashtag() throws Exception { String commitMessage = "#Subject\n\nLine 1\n\nLine 2"; - assertThat((Iterable)HashtagsUtil.extractTags(commitMessage)) + assertThat(HashtagsUtil.extractTags(commitMessage)) .containsExactlyElementsIn(Sets.newHashSet("Subject")); } @Test public void singleHashtagNumeric() throws Exception { String commitMessage = "Subject\n\n#123\n\nLine 2"; - assertThat((Iterable)HashtagsUtil.extractTags(commitMessage)) + assertThat(HashtagsUtil.extractTags(commitMessage)) .containsExactlyElementsIn(Sets.newHashSet("123")); } @Test public void multipleHashtags() throws Exception { String commitMessage = "#Subject\n\n#Hashtag\n\nLine 2"; - assertThat((Iterable)HashtagsUtil.extractTags(commitMessage)) + assertThat(HashtagsUtil.extractTags(commitMessage)) .containsExactlyElementsIn(Sets.newHashSet("Subject", "Hashtag")); } @Test public void repeatedHashtag() throws Exception { String commitMessage = "#Subject\n\n#Hashtag1\n\n#Hashtag2\n\n#Hashtag1"; - assertThat((Iterable)HashtagsUtil.extractTags(commitMessage)) + assertThat(HashtagsUtil.extractTags(commitMessage)) .containsExactlyElementsIn( Sets.newHashSet("Subject", "Hashtag1", "Hashtag2")); } @@ -69,21 +69,21 @@ public class HashtagsTest { @Test public void multipleHashtagsNoSpaces() throws Exception { String commitMessage = "Subject\n\n#Hashtag1#Hashtag2"; - assertThat((Iterable)HashtagsUtil.extractTags(commitMessage)) + assertThat(HashtagsUtil.extractTags(commitMessage)) .containsExactlyElementsIn(Sets.newHashSet("Hashtag1")); } @Test public void hyphenatedHashtag() throws Exception { String commitMessage = "Subject\n\n#Hyphenated-Hashtag"; - assertThat((Iterable)HashtagsUtil.extractTags(commitMessage)) + assertThat(HashtagsUtil.extractTags(commitMessage)) .containsExactlyElementsIn(Sets.newHashSet("Hyphenated-Hashtag")); } @Test public void underscoredHashtag() throws Exception { String commitMessage = "Subject\n\n#Underscored_Hashtag"; - assertThat((Iterable)HashtagsUtil.extractTags(commitMessage)) + assertThat(HashtagsUtil.extractTags(commitMessage)) .containsExactlyElementsIn(Sets.newHashSet("Underscored_Hashtag")); } @@ -91,7 +91,7 @@ public class HashtagsTest { public void hashtagsWithAccentedCharacters() throws Exception { String commitMessage = "Jag #måste #öva på min #Svenska!\n\n" + "Jag behöver en #läkare."; - assertThat((Iterable)HashtagsUtil.extractTags(commitMessage)) + assertThat(HashtagsUtil.extractTags(commitMessage)) .containsExactlyElementsIn( Sets.newHashSet("måste", "öva", "Svenska", "läkare")); } @@ -99,6 +99,6 @@ public class HashtagsTest { @Test public void hashWithoutHashtag() throws Exception { String commitMessage = "Subject\n\n# Text"; - assertThat((Iterable)HashtagsUtil.extractTags(commitMessage)).isEmpty(); + assertThat(HashtagsUtil.extractTags(commitMessage)).isEmpty(); } } diff --git a/gerrit-server/src/test/java/com/google/gerrit/server/git/LocalDiskRepositoryManagerTest.java b/gerrit-server/src/test/java/com/google/gerrit/server/git/LocalDiskRepositoryManagerTest.java index 2ebad527a2..ca154b1814 100644 --- a/gerrit-server/src/test/java/com/google/gerrit/server/git/LocalDiskRepositoryManagerTest.java +++ b/gerrit-server/src/test/java/com/google/gerrit/server/git/LocalDiskRepositoryManagerTest.java @@ -73,7 +73,7 @@ public class LocalDiskRepositoryManagerTest extends EasyMockSupport { try (Repository repo = repoManager.openRepository(projectA)) { assertThat(repo).isNotNull(); } - assertThat((Iterable) repoManager.list()).containsExactly(projectA); + assertThat(repoManager.list()).containsExactly(projectA); } @Test(expected = RepositoryNotFoundException.class) @@ -174,7 +174,7 @@ public class LocalDiskRepositoryManagerTest extends EasyMockSupport { try (Repository repo = repoManager.openRepository(projectA)) { assertThat(repo).isNotNull(); } - assertThat((Iterable) repoManager.list()).containsExactly(projectA); + assertThat(repoManager.list()).containsExactly(projectA); } @Test(expected = RepositoryNotFoundException.class) @@ -196,8 +196,8 @@ public class LocalDiskRepositoryManagerTest extends EasyMockSupport { repoManager.getBasePath().resolve(".git").toFile().mkdir(); // create an invalid repo name createRepository(repoManager.getBasePath(), "project?A"); - assertThat((Iterable) repoManager.list()).containsExactly(projectA, - projectB, projectC); + assertThat(repoManager.list()) + .containsExactly(projectA, projectB, projectC); } @Test diff --git a/gerrit-server/src/test/java/com/google/gerrit/server/query/change/AbstractQueryChangesTest.java b/gerrit-server/src/test/java/com/google/gerrit/server/query/change/AbstractQueryChangesTest.java index 85e06e8069..07cbaf3b61 100644 --- a/gerrit-server/src/test/java/com/google/gerrit/server/query/change/AbstractQueryChangesTest.java +++ b/gerrit-server/src/test/java/com/google/gerrit/server/query/change/AbstractQueryChangesTest.java @@ -1126,8 +1126,7 @@ public abstract class AbstractQueryChangesTest { protected void assertQuery(QueryRequest query, Change... changes) throws Exception { - assertThat((Iterable) query(query)) - .named(query.toString()) + assertThat(query(query)).named(query.toString()) .containsExactlyElementsIn(ids(changes)).inOrder(); } diff --git a/lib/BUCK b/lib/BUCK index 2760acce91..d91ea26c4c 100644 --- a/lib/BUCK +++ b/lib/BUCK @@ -188,8 +188,8 @@ maven_jar( maven_jar( name = 'truth', - id = 'com.google.truth:truth:0.25', - sha1 = '503ba892e8482976b81eb2b2df292858fbac3782', + id = 'com.google.truth:truth:0.26', + sha1 = 'b5802815625d82f39c33219299771f3d64301b06', license = 'DO_NOT_DISTRIBUTE', deps = [ ':guava',