Upgrade Truth to 0.34

Convert invocation of deprecated 'withFailureMessage' to use new
'withMessage' instead.

Change-Id: I3a9f776ad895a8df8da4e26d435a18a72daae400
This commit is contained in:
Dave Borowitz
2017-07-06 10:57:05 -04:00
parent a329437de5
commit 66b50527f4
17 changed files with 28 additions and 46 deletions

View File

@@ -716,18 +716,18 @@ maven_jar(
sha1 = "4785a3c21320980282f9f33d0d1264a69040538f",
)
TRUTH_VERS = "0.32"
TRUTH_VERS = "0.34"
maven_jar(
name = "truth",
artifact = "com.google.truth:truth:" + TRUTH_VERS,
sha1 = "e996fb4b41dad04365112786796c945f909cfdf7",
sha1 = "73379200e907386d27eb10da60c5c2ed339f2bec",
)
maven_jar(
name = "truth-java8-extension",
artifact = "com.google.truth.extensions:truth-java8-extension:" + TRUTH_VERS,
sha1 = "2862787ce34cb6f385ada891e36ec7f9e7bd0902",
sha1 = "2d4aa36f7c048805af211406c4da4ddd1de15474",
)
# When bumping the easymock version number, make sure to also move powermock to a compatible version

View File

@@ -38,7 +38,7 @@ public class GcAssert {
throws RepositoryNotFoundException, IOException {
for (Project.NameKey p : projects) {
assert_()
.withFailureMessage("Project " + p.get() + " has no pack files.")
.withMessage("Project " + p.get() + " has no pack files.")
.that(getPackFiles(p))
.isNotEmpty();
}
@@ -48,7 +48,7 @@ public class GcAssert {
throws RepositoryNotFoundException, IOException {
for (Project.NameKey p : projects) {
assert_()
.withFailureMessage("Project " + p.get() + " has pack files.")
.withMessage("Project " + p.get() + " has pack files.")
.that(getPackFiles(p))
.isEmpty();
}

View File

@@ -40,7 +40,7 @@ public class RestResponse extends HttpResponse {
public void assertStatus(int status) throws Exception {
assert_()
.withFailureMessage(String.format("Expected status code %d", status))
.withMessage(String.format("Expected status code %d", status))
.that(getStatusCode())
.isEqualTo(status);
}

View File

@@ -201,7 +201,7 @@ public class AccountIT extends AbstractDaemonTest {
RefUpdate ru = repo.updateRef(ref);
ru.setForceUpdate(true);
assert_()
.withFailureMessage("Failed to delete " + ref)
.withMessage("Failed to delete " + ref)
.that(ru.delete())
.isEqualTo(RefUpdate.Result.FORCED);
}

View File

@@ -26,9 +26,9 @@ public class GroupAssert {
public static void assertGroups(Iterable<String> expected, Set<String> actual) {
for (String g : expected) {
assert_().withFailureMessage("missing group " + g).that(actual.remove(g)).isTrue();
assert_().withMessage("missing group " + g).that(actual.remove(g)).isTrue();
}
assert_().withFailureMessage("unexpected groups: " + actual).that(actual).isEmpty();
assert_().withMessage("unexpected groups: " + actual).that(actual).isEmpty();
}
public static void assertGroupInfo(AccountGroup group, GroupInfo info) {

View File

@@ -62,7 +62,7 @@ public class CapabilitiesIT extends AbstractDaemonTest {
assertThat(info.queryLimit.max).isEqualTo((short) DEFAULT_MAX_QUERY_LIMIT);
} else {
assert_()
.withFailureMessage(String.format("capability %s was not granted", c))
.withMessage(String.format("capability %s was not granted", c))
.that((Boolean) CapabilityInfo.class.getField(c).get(info))
.isTrue();
}
@@ -86,7 +86,7 @@ public class CapabilitiesIT extends AbstractDaemonTest {
} else if (PRIORITY.equals(c)) {
assertThat(info.priority).isFalse();
} else if (QUERY_LIMIT.equals(c)) {
assert_().withFailureMessage("missing queryLimit").that(info.queryLimit).isNotNull();
assert_().withMessage("missing queryLimit").that(info.queryLimit).isNotNull();
assertThat(info.queryLimit.min).isEqualTo((short) 0);
assertThat(info.queryLimit.max).isEqualTo((short) DEFAULT_MAX_QUERY_LIMIT);
} else if (ACCESS_DATABASE.equals(c)) {
@@ -95,7 +95,7 @@ public class CapabilitiesIT extends AbstractDaemonTest {
assertThat(info.runAs).isFalse();
} else {
assert_()
.withFailureMessage(String.format("capability %s was not granted", c))
.withMessage(String.format("capability %s was not granted", c))
.that((Boolean) CapabilityInfo.class.getField(c).get(info))
.isTrue();
}

View File

@@ -1209,7 +1209,7 @@ public abstract class AbstractSubmit extends AbstractDaemonTest {
RevCommit localHead = getHead(repo);
RevCommit remoteHead = getRemoteHead();
assert_()
.withFailureMessage(String.format("%s not equal %s", localHead.name(), remoteHead.name()))
.withMessage(String.format("%s not equal %s", localHead.name(), remoteHead.name()))
.that(localHead.getId())
.isNotEqualTo(remoteHead.getId());
assertThat(remoteHead.getParentCount()).isEqualTo(1);

View File

@@ -84,13 +84,13 @@ public class EmailValidatorIT extends AbstractDaemonTest {
if (tld.startsWith(UNSUPPORTED_PREFIX)) {
String test = "test@example." + tld.toLowerCase().substring(UNSUPPORTED_PREFIX.length());
assert_()
.withFailureMessage("expected invalid TLD \"" + test + "\"")
.withMessage("expected invalid TLD \"" + test + "\"")
.that(validator.isValid(test))
.isFalse();
} else {
String test = "test@example." + tld.toLowerCase();
assert_()
.withFailureMessage("failed to validate TLD \"" + test + "\"")
.withMessage("failed to validate TLD \"" + test + "\"")
.that(validator.isValid(test))
.isTrue();
}

View File

@@ -62,10 +62,7 @@ public class AbandonRestoreIT extends AbstractDaemonTest {
command.append(" --message ").append(message);
}
String response = adminSshSession.exec(command.toString());
assert_()
.withFailureMessage(adminSshSession.getError())
.that(adminSshSession.hasError())
.isFalse();
assert_().withMessage(adminSshSession.getError()).that(adminSshSession.hasError()).isFalse();
assertThat(response.toLowerCase(Locale.US)).doesNotContain("error");
}

View File

@@ -36,10 +36,7 @@ public class BanCommitIT extends AbstractDaemonTest {
RevCommit c = commitBuilder().add("a.txt", "some content").create();
String response = adminSshSession.exec("gerrit ban-commit " + project.get() + " " + c.name());
assert_()
.withFailureMessage(adminSshSession.getError())
.that(adminSshSession.hasError())
.isFalse();
assert_().withMessage(adminSshSession.getError()).that(adminSshSession.hasError()).isFalse();
assertThat(response.toLowerCase(Locale.US)).doesNotContain("error");
RemoteRefUpdate u =

View File

@@ -33,10 +33,7 @@ public class CreateProjectIT extends AbstractDaemonTest {
String newProjectName = "newProject";
adminSshSession.exec(
"gerrit create-project --branch master --owner " + newGroupName + " " + newProjectName);
assert_()
.withFailureMessage(adminSshSession.getError())
.that(adminSshSession.hasError())
.isFalse();
assert_().withMessage(adminSshSession.getError()).that(adminSshSession.hasError()).isFalse();
ProjectState projectState = projectCache.get(new Project.NameKey(newProjectName));
assertThat(projectState).isNotNull();
}
@@ -49,10 +46,7 @@ public class CreateProjectIT extends AbstractDaemonTest {
String newProjectName = "newProject";
adminSshSession.exec(
"gerrit create-project --branch master --owner " + wrongGroupName + " " + newProjectName);
assert_()
.withFailureMessage(adminSshSession.getError())
.that(adminSshSession.hasError())
.isTrue();
assert_().withMessage(adminSshSession.getError()).that(adminSshSession.hasError()).isTrue();
ProjectState projectState = projectCache.get(new Project.NameKey(newProjectName));
assertThat(projectState).isNull();
}

View File

@@ -56,10 +56,7 @@ public class GarbageCollectionIT extends AbstractDaemonTest {
public void testGc() throws Exception {
String response =
adminSshSession.exec("gerrit gc \"" + project.get() + "\" \"" + project2.get() + "\"");
assert_()
.withFailureMessage(adminSshSession.getError())
.that(adminSshSession.hasError())
.isFalse();
assert_().withMessage(adminSshSession.getError()).that(adminSshSession.hasError()).isFalse();
assertNoError(response);
gcAssert.assertHasPackFile(project, project2);
gcAssert.assertHasNoPackFile(allProjects, project3);
@@ -69,10 +66,7 @@ public class GarbageCollectionIT extends AbstractDaemonTest {
@UseLocalDisk
public void testGcAll() throws Exception {
String response = adminSshSession.exec("gerrit gc --all");
assert_()
.withFailureMessage(adminSshSession.getError())
.that(adminSshSession.hasError())
.isFalse();
assert_().withMessage(adminSshSession.getError()).that(adminSshSession.hasError()).isFalse();
assertNoError(response);
gcAssert.assertHasPackFile(allProjects, project, project2, project3);
}

View File

@@ -313,7 +313,7 @@ public class QueryIT extends AbstractDaemonTest {
private List<ChangeAttribute> executeSuccessfulQuery(String params, SshSession session)
throws Exception {
String rawResponse = session.exec("gerrit query --format=JSON " + params);
assert_().withFailureMessage(session.getError()).that(session.hasError()).isFalse();
assert_().withMessage(session.getError()).that(session.hasError()).isFalse();
return getChanges(rawResponse);
}

View File

@@ -173,7 +173,7 @@ public abstract class PrologTestCase extends GerritBaseTests {
private void call(BufferingPrologControl env, String name) {
StructureTerm head = SymbolTerm.create(pkg, name, 0);
assert_()
.withFailureMessage("Cannot invoke " + pkg + ":" + name)
.withMessage("Cannot invoke " + pkg + ":" + name)
.that(env.execute(Prolog.BUILTIN, "call", head))
.isTrue();
}

View File

@@ -510,7 +510,7 @@ public class ProjectConfigTest extends LocalDiskRepositoryTestCase {
u.setNewObjectId(rev);
Result result = u.forceUpdate();
assert_()
.withFailureMessage("Cannot update ref for test: " + result)
.withMessage("Cannot update ref for test: " + result)
.that(result)
.isAnyOf(Result.FAST_FORWARD, Result.FORCED, Result.NEW, Result.NO_CHANGE);
}

View File

@@ -659,7 +659,7 @@ public class CommitMsgHookTest extends HookTestCase {
ref.setNewObjectId(commitId);
Result result = ref.forceUpdate();
assert_()
.withFailureMessage(Constants.HEAD + " did not change: " + ref.getResult())
.withMessage(Constants.HEAD + " did not change: " + ref.getResult())
.that(result)
.isAnyOf(Result.FAST_FORWARD, Result.FORCED, Result.NEW, Result.NO_CHANGE);
}

View File

@@ -104,14 +104,14 @@ public abstract class HookTestCase extends LocalDiskRepositoryTestCase {
String path = scproot + "/hooks/" + name;
String errorMessage = "Cannot locate " + path + " in CLASSPATH";
URL url = cl().getResource(path);
assert_().withFailureMessage(errorMessage).that(url).isNotNull();
assert_().withMessage(errorMessage).that(url).isNotNull();
String protocol = url.getProtocol();
assert_().withFailureMessage("Cannot invoke " + url).that(protocol).isAnyOf("file", "jar");
assert_().withMessage("Cannot invoke " + url).that(protocol).isAnyOf("file", "jar");
if ("file".equals(protocol)) {
hook = new File(url.getPath());
assert_().withFailureMessage(errorMessage).that(hook.isFile()).isTrue();
assert_().withMessage(errorMessage).that(hook.isFile()).isTrue();
long time = hook.lastModified();
hook.setExecutable(true);
hook.setLastModified(time);