Migrate from assertThat(foo).named("foo") to assertWithMessage("foo").that(foo).

PiperOrigin-RevId: 244916676
Change-Id: Ib75f8a598115174852f09eb0c3ef3fdce76132a1
This commit is contained in:
Gerrit Code Review
2019-04-23 22:41:34 +02:00
committed by Han-Wen Nienhuys
parent 2118670609
commit 8f1853adad
20 changed files with 111 additions and 87 deletions

View File

@@ -16,6 +16,7 @@ package com.google.gerrit.git.testing;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.truth.Truth.assertAbout;
import static com.google.common.truth.Truth.assertWithMessage;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Splitter;
@@ -126,9 +127,9 @@ public class PushResultSubject extends Subject<PushResultSubject, PushResult> {
public RemoteRefUpdateSubject onlyRef(String refName) {
check("setOfRefs()")
.withMessage("set of refs")
.about(StreamSubject.streams())
.that(actual().getRemoteUpdates().stream().map(RemoteRefUpdate::getRemoteName))
.named("set of refs")
.containsExactly(refName);
return ref(refName);
}
@@ -146,22 +147,22 @@ public class PushResultSubject extends Subject<PushResultSubject, PushResult> {
public void hasStatus(RemoteRefUpdate.Status status) {
RemoteRefUpdate u = actual();
Truth.assertThat(u.getStatus())
.named(
assertWithMessage(
"status of ref update for %s%s",
refName, u.getMessage() != null ? ": " + u.getMessage() : "")
.that(u.getStatus())
.isEqualTo(status);
}
public void hasNoMessage() {
Truth.assertThat(actual().getMessage())
.named("message of ref update for %s", refName)
assertWithMessage("message of ref update for %s", refName)
.that(actual().getMessage())
.isNull();
}
public void hasMessage(String expected) {
Truth.assertThat(actual().getMessage())
.named("message of ref update for %s", refName)
assertWithMessage("message of ref update for %s", refName)
.that(actual().getMessage())
.isEqualTo(expected);
}

View File

@@ -15,6 +15,7 @@
package com.google.gerrit.server.schema.testing;
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth.assertWithMessage;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Iterables;
@@ -151,8 +152,8 @@ public class AllProjectsCreatorTestUtil {
Set<String> subsections1 = config1.getSubsections(section);
Set<String> subsections2 = config2.getSubsections(section);
assertThat(subsections1)
.named("section \"%s\"", section)
assertWithMessage("section \"%s\"", section)
.that(subsections1)
.containsExactlyElementsIn(subsections2);
subsections1.forEach(s -> assertSubsectionEquivalent(config1, config2, section, s));
@@ -163,12 +164,12 @@ public class AllProjectsCreatorTestUtil {
Set<String> subsectionNames1 = config1.getNames(section, subsection);
Set<String> subsectionNames2 = config2.getNames(section, subsection);
String name = String.format("subsection \"%s\" of section \"%s\"", subsection, section);
assertThat(subsectionNames1).named(name).containsExactlyElementsIn(subsectionNames2);
assertWithMessage(name).that(subsectionNames1).containsExactlyElementsIn(subsectionNames2);
subsectionNames1.forEach(
n ->
assertThat(config1.getStringList(section, subsection, n))
.named(name)
assertWithMessage(name)
.that(config1.getStringList(section, subsection, n))
.asList()
.containsExactlyElementsIn(config2.getStringList(section, subsection, n)));
}

View File

@@ -16,6 +16,7 @@ package com.google.gerrit.acceptance.api.group;
import static com.google.common.collect.ImmutableList.toImmutableList;
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth.assertWithMessage;
import static com.google.common.truth.Truth8.assertThat;
import static com.google.gerrit.acceptance.GitUtil.deleteRef;
import static com.google.gerrit.acceptance.GitUtil.fetch;
@@ -1547,7 +1548,7 @@ public class GroupsIT extends AbstractDaemonTest {
void assertReindexOf(List<AccountGroup.UUID> groupUuids) {
for (AccountGroup.UUID groupUuid : groupUuids) {
assertThat(getCount(groupUuid)).named(groupUuid.get()).isEqualTo(1);
assertWithMessage(groupUuid.get()).that(getCount(groupUuid)).isEqualTo(1);
}
assertThat(countsByGroup).hasSize(groupUuids.size());
clear();

View File

@@ -15,6 +15,7 @@
package com.google.gerrit.acceptance.pgm;
import static com.google.common.collect.ImmutableMap.toImmutableMap;
import static com.google.common.truth.StreamSubject.streams;
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth.assertWithMessage;
import static com.google.common.truth.Truth8.assertThat;
@@ -255,30 +256,31 @@ public abstract class AbstractReindexTests extends StandaloneSiteTest {
}
private void assertSearchVersion(ServerContext ctx, int expected) {
assertThat(
assertWithMessage("search version")
.that(
ctx.getInjector()
.getInstance(ChangeIndexCollection.class)
.getSearchIndex()
.getSchema()
.getVersion())
.named("search version")
.isEqualTo(expected);
}
private void assertWriteVersions(ServerContext ctx, Integer... expected) {
assertThat(
assertWithMessage("write versions")
.about(streams())
.that(
ctx.getInjector().getInstance(ChangeIndexCollection.class).getWriteIndexes().stream()
.map(i -> i.getSchema().getVersion()))
.named("write versions")
.containsExactlyElementsIn(ImmutableSet.copyOf(expected));
}
private void assertReady(int expectedReady) throws Exception {
Set<Integer> allVersions = ChangeSchemaDefinitions.INSTANCE.getSchemas().keySet();
GerritIndexStatus status = new GerritIndexStatus(sitePaths);
assertThat(
assertWithMessage("ready state for index versions")
.that(
allVersions.stream().collect(toImmutableMap(v -> v, v -> status.getReady(CHANGES, v))))
.named("ready state for index versions")
.isEqualTo(allVersions.stream().collect(toImmutableMap(v -> v, v -> v == expectedReady)));
}
}

View File

@@ -15,6 +15,7 @@
package com.google.gerrit.acceptance.server.account;
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth.assertWithMessage;
import static com.google.common.truth.Truth.assert_;
import static com.google.common.truth.Truth8.assertThat;
@@ -259,14 +260,14 @@ public class AccountResolverIT extends AbstractDaemonTest {
assertThat(resolve(account.accountId())).containsExactly(id);
for (String input : inputs) {
assertThat(resolve(input)).named("results for %s (active)", input).containsExactly(id);
assertWithMessage("results for %s (active)", input).that(resolve(input)).containsExactly(id);
}
gApi.accounts().id(id.get()).setActive(false);
assertThat(resolve(account.accountId())).containsExactly(id);
for (String input : inputs) {
Result result = accountResolver.resolve(input);
assertThat(result.asIdSet()).named("results for %s (inactive)", input).isEmpty();
assertWithMessage("results for %s (inactive)", input).that(result.asIdSet()).isEmpty();
try {
result.asUnique();
assert_().fail("expected UnresolvableAccountException");
@@ -282,8 +283,8 @@ public class AccountResolverIT extends AbstractDaemonTest {
+ ": "
+ nameEmail);
}
assertThat(resolveByNameOrEmail(input))
.named("results by name or email for %s (inactive)", input)
assertWithMessage("results by name or email for %s (inactive)", input)
.that(resolveByNameOrEmail(input))
.isEmpty();
}
}

View File

@@ -15,6 +15,7 @@
package com.google.gerrit.acceptance.server.change;
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth.assertWithMessage;
import static com.google.gerrit.acceptance.GitUtil.assertPushOk;
import static com.google.gerrit.acceptance.GitUtil.pushHead;
import static com.google.gerrit.extensions.common.testing.EditInfoSubject.assertThat;
@@ -706,18 +707,18 @@ public class GetRelatedIT extends AbstractDaemonTest {
throws Exception {
List<RelatedChangeAndCommitInfo> actual =
gApi.changes().id(psId.changeId().get()).revision(psId.get()).related().changes;
assertThat(actual).named("related to " + psId).hasSize(expected.size());
assertWithMessage("related to " + psId).that(actual).hasSize(expected.size());
for (int i = 0; i < actual.size(); i++) {
String name = "index " + i + " related to " + psId;
RelatedChangeAndCommitInfo a = actual.get(i);
RelatedChangeAndCommitInfo e = expected.get(i);
assertThat(a.project).named("project of " + name).isEqualTo(e.project);
assertThat(a._changeNumber).named("change ID of " + name).isEqualTo(e._changeNumber);
assertWithMessage("project of " + name).that(a.project).isEqualTo(e.project);
assertWithMessage("change ID of " + name).that(a._changeNumber).isEqualTo(e._changeNumber);
// Don't bother checking changeId; assume _changeNumber is sufficient.
assertThat(a._revisionNumber).named("revision of " + name).isEqualTo(e._revisionNumber);
assertThat(a.commit.commit).named("commit of " + name).isEqualTo(e.commit.commit);
assertThat(a._currentRevisionNumber)
.named("current revision of " + name)
assertWithMessage("revision of " + name).that(a._revisionNumber).isEqualTo(e._revisionNumber);
assertWithMessage("commit of " + name).that(a.commit.commit).isEqualTo(e.commit.commit);
assertWithMessage("current revision of " + name)
.that(a._currentRevisionNumber)
.isEqualTo(e._currentRevisionNumber);
assertThat(a.status).isEqualTo(e.status);
}

View File

@@ -15,6 +15,7 @@
package com.google.gerrit.acceptance.server.notedb;
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth.assertWithMessage;
import static com.google.common.truth.Truth8.assertThat;
import static com.google.gerrit.extensions.client.ListChangesOption.MESSAGES;
import static java.util.stream.Collectors.toList;
@@ -306,8 +307,8 @@ public class NoteDbOnlyIT extends AbstractDaemonTest {
if (repo instanceof InMemoryRepository) {
((InMemoryRepository) repo).setPerformsAtomicTransactions(true);
} else {
assertThat(repo.getRefDatabase().performsAtomicTransactions())
.named("performsAtomicTransactions on %s", repo)
assertWithMessage("performsAtomicTransactions on %s", repo)
.that(repo.getRefDatabase().performsAtomicTransactions())
.isTrue();
}
}

View File

@@ -15,6 +15,7 @@
package com.google.gerrit.acceptance.server.project;
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth.assertWithMessage;
import static com.google.gerrit.reviewdb.client.RefNames.changeMetaRef;
import com.google.gerrit.acceptance.AbstractDaemonTest;
@@ -55,7 +56,7 @@ public class ReflogIT extends AbstractDaemonTest {
gApi.changes().id(id.get()).topic("foo");
ReflogEntry last = repo.getReflogReader(changeMetaRef(id)).getLastEntry();
assertThat(last).named("last RefLogEntry").isNotNull();
assertWithMessage("last RefLogEntry").that(last).isNotNull();
assertThat(last.getComment()).isEqualTo("restapi.change.PutTopic");
}
}

View File

@@ -15,6 +15,7 @@
package com.google.gerrit.acceptance.testsuite.group;
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth.assertWithMessage;
import static com.google.common.truth.Truth8.assertThat;
import com.google.common.collect.ImmutableSet;
@@ -313,8 +314,10 @@ public class GroupOperationsImplTest extends AbstractDaemonTest {
TestGroup visibleGroup = groupOperations.group(visibleGroupUuid).get();
TestGroup invisibleGroup = groupOperations.group(invisibleGroupUuid).get();
assertThat(visibleGroup.visibleToAll()).named("visibility of visible group").isTrue();
assertThat(invisibleGroup.visibleToAll()).named("visibility of invisible group").isFalse();
assertWithMessage("visibility of visible group").that(visibleGroup.visibleToAll()).isTrue();
assertWithMessage("visibility of invisible group")
.that(invisibleGroup.visibleToAll())
.isFalse();
}
@Test

View File

@@ -15,6 +15,7 @@
package com.google.gerrit.acceptance.testsuite.request;
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth.assertWithMessage;
import static com.google.common.truth.Truth.assert_;
import static com.google.common.truth.Truth8.assertThat;
@@ -98,24 +99,26 @@ public class RequestScopeOperationsImplTest extends AbstractDaemonTest {
private void fastCheckCurrentUser(Account.Id expected) {
// Check current user quickly, since the full check requires creating changes and is quite slow.
assertThat(userProvider.get().isIdentifiedUser())
.named("user from provider is an IdentifiedUser")
assertWithMessage("user from provider is an IdentifiedUser")
.that(userProvider.get().isIdentifiedUser())
.isTrue();
assertThat(userProvider.get().getAccountId()).named("user from provider").isEqualTo(expected);
assertWithMessage("user from provider")
.that(userProvider.get().getAccountId())
.isEqualTo(expected);
}
private void checkCurrentUser(Account.Id expected) throws Exception {
// Test all supported ways that an acceptance test might query the active user.
fastCheckCurrentUser(expected);
assertThat(gApi.accounts().self().get()._accountId)
.named("user from GerritApi")
assertWithMessage("user from GerritApi")
.that(gApi.accounts().self().get()._accountId)
.isEqualTo(expected.get());
AcceptanceTestRequestScope.Context ctx = atrScope.get();
assertThat(ctx.getUser().isIdentifiedUser())
.named("user from AcceptanceTestRequestScope.Context is an IdentifiedUser")
assertWithMessage("user from AcceptanceTestRequestScope.Context is an IdentifiedUser")
.that(ctx.getUser().isIdentifiedUser())
.isTrue();
assertThat(ctx.getUser().getAccountId())
.named("user from AcceptanceTestRequestScope.Context")
assertWithMessage("user from AcceptanceTestRequestScope.Context")
.that(ctx.getUser().getAccountId())
.isEqualTo(expected);
checkSshUser(expected);
}
@@ -131,8 +134,8 @@ public class RequestScopeOperationsImplTest extends AbstractDaemonTest {
assertThat(gApi.changes().id(changeId).get().owner._accountId).isEqualTo(expected.get());
String queryResults =
atrScope.get().getSession().exec("gerrit query owner:self change:" + changeId);
assertThat(findDistinct(queryResults, "I[0-9a-f]{40}"))
.named("Change-Ids in query results:\n%s", queryResults)
assertWithMessage("Change-Ids in query results:\n%s", queryResults)
.that(findDistinct(queryResults, "I[0-9a-f]{40}"))
.containsExactly(changeId);
}

View File

@@ -15,6 +15,7 @@
package com.google.gerrit.httpd.raw;
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth.assertWithMessage;
import static java.nio.charset.StandardCharsets.UTF_8;
import static javax.servlet.http.HttpServletResponse.SC_NOT_FOUND;
import static javax.servlet.http.HttpServletResponse.SC_OK;
@@ -336,8 +337,8 @@ public class ResourceServletTest extends GerritBaseTests {
}
private static void assertCacheHits(Cache<?, ?> cache, int hits, int misses) {
assertThat(cache.stats().hitCount()).named("hits").isEqualTo(hits);
assertThat(cache.stats().missCount()).named("misses").isEqualTo(misses);
assertWithMessage("hits").that(cache.stats().hitCount()).isEqualTo(hits);
assertWithMessage("misses").that(cache.stats().missCount()).isEqualTo(misses);
}
private static void assertCacheable(FakeHttpServletResponse res, boolean revalidate) {

View File

@@ -15,6 +15,7 @@
package com.google.gerrit.server.account;
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth.assertWithMessage;
import com.google.common.collect.ImmutableSet;
import com.google.gerrit.reviewdb.client.Account;
@@ -170,8 +171,8 @@ public class WatchConfigTest implements ValidationError.Sink {
private void assertParseNotifyValueFails(String notifyValue) {
assertThat(validationErrors).isEmpty();
parseNotifyValue(notifyValue);
assertThat(validationErrors)
.named("expected validation error for notifyValue: " + notifyValue)
assertWithMessage("expected validation error for notifyValue: " + notifyValue)
.that(validationErrors)
.isNotEmpty();
validationErrors.clear();
}

View File

@@ -15,6 +15,7 @@
package com.google.gerrit.server.cache.h2;
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth.assertWithMessage;
import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
@@ -66,22 +67,22 @@ public class H2CacheTest {
return "bar";
}))
.isEqualTo("bar");
assertThat(called.get()).named("Callable was called").isTrue();
assertThat(impl.getIfPresent("foo")).named("in-memory value").isEqualTo("bar");
assertWithMessage("Callable was called").that(called.get()).isTrue();
assertWithMessage("in-memory value").that(impl.getIfPresent("foo")).isEqualTo("bar");
mem.invalidate("foo");
assertThat(impl.getIfPresent("foo")).named("persistent value").isEqualTo("bar");
assertWithMessage("persistent value").that(impl.getIfPresent("foo")).isEqualTo("bar");
called.set(false);
assertThat(
assertWithMessage("cached value")
.that(
impl.get(
"foo",
() -> {
called.set(true);
return "baz";
}))
.named("cached value")
.isEqualTo("bar");
assertThat(called.get()).named("Callable was called").isFalse();
assertWithMessage("Callable was called").that(called.get()).isFalse();
}
@Test

View File

@@ -14,7 +14,7 @@
package com.google.gerrit.server.cache.serialize;
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth.assertWithMessage;
import static com.google.common.truth.Truth.assert_;
import com.google.common.collect.ImmutableList;
@@ -49,8 +49,8 @@ public class IntegerCacheSerializerTest extends GerritBaseTests {
private static void assertRoundTrip(int i) throws Exception {
byte[] serialized = IntegerCacheSerializer.INSTANCE.serialize(i);
int result = IntegerCacheSerializer.INSTANCE.deserialize(serialized);
assertThat(result)
.named("round-trip of %s via \"%s\"", i, TextFormat.escapeBytes(serialized))
assertWithMessage("round-trip of %s via \"%s\"", i, TextFormat.escapeBytes(serialized))
.that(result)
.isEqualTo(i);
}

View File

@@ -156,22 +156,24 @@ public class TagSetTest extends GerritBaseTests {
Map<String, CachedRef> aRefs = a.getRefsForTesting();
Map<String, CachedRef> bRefs = b.getRefsForTesting();
assertThat(ImmutableSortedSet.copyOf(aRefs.keySet()))
.named("ref name set")
assertWithMessage("ref name set")
.that(ImmutableSortedSet.copyOf(aRefs.keySet()))
.isEqualTo(ImmutableSortedSet.copyOf(bRefs.keySet()));
for (String name : aRefs.keySet()) {
CachedRef aRef = aRefs.get(name);
CachedRef bRef = bRefs.get(name);
assertThat(aRef.get()).named("value of ref %s", name).isEqualTo(bRef.get());
assertThat(aRef.flag).named("flag of ref %s", name).isEqualTo(bRef.flag);
assertWithMessage("value of ref %s", name).that(aRef.get()).isEqualTo(bRef.get());
assertWithMessage("flag of ref %s", name).that(aRef.flag).isEqualTo(bRef.flag);
}
ObjectIdOwnerMap<Tag> aTags = a.getTagsForTesting();
ObjectIdOwnerMap<Tag> bTags = b.getTagsForTesting();
assertThat(getTagIds(aTags)).named("tag ID set").isEqualTo(getTagIds(bTags));
assertWithMessage("tag ID set").that(getTagIds(aTags)).isEqualTo(getTagIds(bTags));
for (Tag aTag : aTags) {
Tag bTag = bTags.get(aTag);
assertThat(aTag.refFlags).named("flags for tag %s", aTag.name()).isEqualTo(bTag.refFlags);
assertWithMessage("flags for tag %s", aTag.name())
.that(aTag.refFlags)
.isEqualTo(bTag.refFlags);
}
}

View File

@@ -15,6 +15,7 @@
package com.google.gerrit.server.index.change;
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth.assertWithMessage;
import static java.nio.charset.StandardCharsets.UTF_8;
import static java.util.stream.Collectors.toList;
@@ -153,8 +154,8 @@ public class ChangeFieldTest extends GerritBaseTests {
ChangeField.storedSubmitRecords(recordList).stream()
.map(s -> new String(s, UTF_8))
.collect(toList());
assertThat(ChangeField.parseSubmitRecords(stored))
.named("JSON %s" + stored)
assertWithMessage("JSON %s" + stored)
.that(ChangeField.parseSubmitRecords(stored))
.isEqualTo(recordList);
}
}

View File

@@ -15,6 +15,7 @@
package com.google.gerrit.server.query.account;
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth.assertWithMessage;
import static com.google.common.truth.Truth8.assertThat;
import static java.util.stream.Collectors.toList;
import static org.junit.Assert.fail;
@@ -802,8 +803,8 @@ public abstract class AbstractQueryAccountsTest extends GerritServerTests {
throws Exception {
List<AccountInfo> result = query.get();
Iterable<Integer> ids = ids(result);
assertThat(ids)
.named(format(query, result, accounts))
assertWithMessage(format(query, result, accounts))
.that(ids)
.containsExactlyElementsIn(ids(accounts))
.inOrder();
return result;
@@ -860,8 +861,8 @@ public abstract class AbstractQueryAccountsTest extends GerritServerTests {
}
protected void assertMissingField(FieldDef<AccountState, ?> field) {
assertThat(getSchema().hasField(field))
.named("schema %s has field %s", getSchemaVersion(), field.getName())
assertWithMessage("schema %s has field %s", getSchemaVersion(), field.getName())
.that(getSchema().hasField(field))
.isFalse();
}

View File

@@ -16,6 +16,7 @@ package com.google.gerrit.server.query.change;
import static com.google.common.collect.ImmutableList.toImmutableList;
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth.assertWithMessage;
import static com.google.common.truth.TruthJUnit.assume;
import static com.google.gerrit.extensions.client.ListChangesOption.DETAILED_LABELS;
import static com.google.gerrit.extensions.client.ListChangesOption.REVIEWED;
@@ -1196,9 +1197,9 @@ public abstract class AbstractQueryChangesTest extends GerritServerTests {
}
String q = "status:new limit:" + i;
List<ChangeInfo> results = newQuery(q).get();
assertThat(results).named(q).hasSize(expectedSize);
assertThat(results.get(results.size() - 1)._moreChanges)
.named(q)
assertWithMessage(q).that(results).hasSize(expectedSize);
assertWithMessage(q)
.that(results.get(results.size() - 1)._moreChanges)
.isEqualTo(expectedMoreChanges);
assertThat(results.get(0)._number).isEqualTo(last.getId().get());
}
@@ -2466,8 +2467,8 @@ public abstract class AbstractQueryChangesTest extends GerritServerTests {
queryProvider.get().byCommitsOnBranchNotMerged(repo.getRepository(), dest, shas, i);
Iterable<Integer> ids = FluentIterable.from(cds).transform(in -> in.getId().get());
String name = "limit " + i;
assertThat(ids).named(name).hasSize(n);
assertThat(ids).named(name).containsExactlyElementsIn(expectedIds);
assertWithMessage(name).that(ids).hasSize(n);
assertWithMessage(name).that(ids).containsExactlyElementsIn(expectedIds);
}
}
@@ -3325,8 +3326,8 @@ public abstract class AbstractQueryChangesTest extends GerritServerTests {
throws Exception {
List<ChangeInfo> result = query.get();
Iterable<Change.Id> ids = ids(result);
assertThat(ids)
.named(format(query.getQuery(), ids, changes))
assertWithMessage(format(query.getQuery(), ids, changes))
.that(ids)
.containsExactlyElementsIn(Arrays.asList(changes))
.inOrder();
return result;
@@ -3338,8 +3339,8 @@ public abstract class AbstractQueryChangesTest extends GerritServerTests {
.map(ChangeData::getId)
.collect(toImmutableList());
Change.Id[] expectedIds = Arrays.stream(changes).map(Change::getId).toArray(Change.Id[]::new);
assertThat(actualIds)
.named(format(predicate.toString(), actualIds, expectedIds))
assertWithMessage(format(predicate.toString(), actualIds, expectedIds))
.that(actualIds)
.containsExactlyElementsIn(expectedIds)
.inOrder();
}
@@ -3428,8 +3429,8 @@ public abstract class AbstractQueryChangesTest extends GerritServerTests {
}
protected void assertMissingField(FieldDef<ChangeData, ?> field) {
assertThat(getSchema().hasField(field))
.named("schema %s has field %s", getSchemaVersion(), field.getName())
assertWithMessage("schema %s has field %s", getSchemaVersion(), field.getName())
.that(getSchema().hasField(field))
.isFalse();
}

View File

@@ -15,6 +15,7 @@
package com.google.gerrit.server.query.group;
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth.assertWithMessage;
import static com.google.common.truth.Truth8.assertThat;
import static com.google.common.truth.TruthJUnit.assume;
import static java.util.stream.Collectors.toList;
@@ -459,8 +460,8 @@ public abstract class AbstractQueryGroupsTest extends GerritServerTests {
throws Exception {
List<GroupInfo> result = query.get();
Iterable<String> uuids = uuids(result);
assertThat(uuids)
.named(format(query, result, groups))
assertWithMessage(format(query, result, groups))
.that(uuids)
.containsExactlyElementsIn(uuids(groups))
.inOrder();
return result;

View File

@@ -14,7 +14,7 @@
package com.google.gerrit.server.query.project;
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth.assertWithMessage;
import static com.google.common.truth.TruthJUnit.assume;
import static java.util.stream.Collectors.toList;
@@ -375,8 +375,8 @@ public abstract class AbstractQueryProjectsTest extends GerritServerTests {
throws Exception {
List<ProjectInfo> result = query.get();
Iterable<String> names = names(result);
assertThat(names)
.named(format(query, result, projects))
assertWithMessage(format(query, result, projects))
.that(names)
.containsExactlyElementsIn(names(projects))
.inOrder();
return result;