From 454e1676a82fd48ae553fe35594e5af4b313123d Mon Sep 17 00:00:00 2001 From: Edwin Kempin Date: Mon, 15 Jan 2024 11:21:30 +0000 Subject: [PATCH] Temporarily qualify calls to custom assertThat(Optional) methods The Truth team is working on migrating callers of the Truth8.assertThat methods to call equivalent methods on the main Truth class. Due to this calls to custom assertThat(Optional) methods will temporarily become ambiguous and hence need to be qualified to avoid breakage. Release-Notes: skip Change-Id: I016a8802b11e90bc7bdea76876dd766d0f79c94a Signed-off-by: Edwin Kempin --- .../gerrit/server/notedb/IntBlobTest.java | 28 +++++++++++-------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/javatests/com/google/gerrit/server/notedb/IntBlobTest.java b/javatests/com/google/gerrit/server/notedb/IntBlobTest.java index 333c229147ed..f335201327aa 100644 --- a/javatests/com/google/gerrit/server/notedb/IntBlobTest.java +++ b/javatests/com/google/gerrit/server/notedb/IntBlobTest.java @@ -16,12 +16,12 @@ import static com.google.common.truth.Truth.assertThat; import static com.google.gerrit.testing.GerritJUnit.assertThrows; -import static com.google.gerrit.truth.OptionalSubject.assertThat; import com.google.gerrit.entities.Project; import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.git.LockFailureException; import com.google.gerrit.server.extensions.events.GitReferenceUpdated; +import com.google.gerrit.truth.OptionalSubject; import java.io.IOException; import org.eclipse.jgit.errors.IncorrectObjectTypeException; import org.eclipse.jgit.internal.storage.dfs.DfsRepositoryDescription; @@ -52,7 +52,7 @@ public void setUp() throws Exception { @Test public void parseNoRef() throws Exception { - assertThat(IntBlob.parse(repo, "refs/nothing")).isEmpty(); + OptionalSubject.assertThat(IntBlob.parse(repo, "refs/nothing")).isEmpty(); } @Test @@ -66,14 +66,18 @@ public void parseNonBlob() throws Exception { public void parseValid() throws Exception { String refName = "refs/foo"; ObjectId id = tr.update(refName, tr.blob("123")); - assertThat(IntBlob.parse(repo, refName)).value().isEqualTo(IntBlob.create(id, 123)); + OptionalSubject.assertThat(IntBlob.parse(repo, refName)) + .value() + .isEqualTo(IntBlob.create(id, 123)); } @Test public void parseWithWhitespace() throws Exception { String refName = "refs/foo"; ObjectId id = tr.update(refName, tr.blob(" 123 ")); - assertThat(IntBlob.parse(repo, refName)).value().isEqualTo(IntBlob.create(id, 123)); + OptionalSubject.assertThat(IntBlob.parse(repo, refName)) + .value() + .isEqualTo(IntBlob.create(id, 123)); } @Test @@ -92,7 +96,7 @@ public void tryStoreNoOldId() throws Exception { IntBlob.tryStore(repo, rw, projectName, refName, null, 123, GitReferenceUpdated.DISABLED); assertThat(ru.getResult()).isEqualTo(RefUpdate.Result.NEW); assertThat(ru.getName()).isEqualTo(refName); - assertThat(IntBlob.parse(repo, refName)) + OptionalSubject.assertThat(IntBlob.parse(repo, refName)) .value() .isEqualTo(IntBlob.create(ru.getNewObjectId(), 123)); } @@ -105,7 +109,7 @@ public void tryStoreOldIdZero() throws Exception { repo, rw, projectName, refName, ObjectId.zeroId(), 123, GitReferenceUpdated.DISABLED); assertThat(ru.getResult()).isEqualTo(RefUpdate.Result.NEW); assertThat(ru.getName()).isEqualTo(refName); - assertThat(IntBlob.parse(repo, refName)) + OptionalSubject.assertThat(IntBlob.parse(repo, refName)) .value() .isEqualTo(IntBlob.create(ru.getNewObjectId(), 123)); } @@ -118,7 +122,7 @@ public void tryStoreCorrectOldId() throws Exception { IntBlob.tryStore(repo, rw, projectName, refName, id, 456, GitReferenceUpdated.DISABLED); assertThat(ru.getResult()).isEqualTo(RefUpdate.Result.FORCED); assertThat(ru.getName()).isEqualTo(refName); - assertThat(IntBlob.parse(repo, refName)) + OptionalSubject.assertThat(IntBlob.parse(repo, refName)) .value() .isEqualTo(IntBlob.create(ru.getNewObjectId(), 456)); } @@ -137,14 +141,14 @@ public void tryStoreWrongOldId() throws Exception { GitReferenceUpdated.DISABLED); assertThat(ru.getResult()).isEqualTo(RefUpdate.Result.LOCK_FAILURE); assertThat(ru.getName()).isEqualTo(refName); - assertThat(IntBlob.parse(repo, refName)).isEmpty(); + OptionalSubject.assertThat(IntBlob.parse(repo, refName)).isEmpty(); } @Test public void storeNoOldId() throws Exception { String refName = "refs/foo"; IntBlob.store(repo, rw, projectName, refName, null, 123, GitReferenceUpdated.DISABLED); - assertThat(IntBlob.parse(repo, refName)) + OptionalSubject.assertThat(IntBlob.parse(repo, refName)) .value() .isEqualTo(IntBlob.create(getRef(refName), 123)); } @@ -154,7 +158,7 @@ public void storeOldIdZero() throws Exception { String refName = "refs/foo"; IntBlob.store( repo, rw, projectName, refName, ObjectId.zeroId(), 123, GitReferenceUpdated.DISABLED); - assertThat(IntBlob.parse(repo, refName)) + OptionalSubject.assertThat(IntBlob.parse(repo, refName)) .value() .isEqualTo(IntBlob.create(getRef(refName), 123)); } @@ -164,7 +168,7 @@ public void storeCorrectOldId() throws Exception { String refName = "refs/foo"; ObjectId id = tr.update(refName, tr.blob("123")); IntBlob.store(repo, rw, projectName, refName, id, 456, GitReferenceUpdated.DISABLED); - assertThat(IntBlob.parse(repo, refName)) + OptionalSubject.assertThat(IntBlob.parse(repo, refName)) .value() .isEqualTo(IntBlob.create(getRef(refName), 456)); } @@ -185,7 +189,7 @@ public void storeWrongOldId() throws Exception { 123, GitReferenceUpdated.DISABLED)); assertThat(thrown.getFailedRefs()).containsExactly("refs/foo"); - assertThat(IntBlob.parse(repo, refName)).isEmpty(); + OptionalSubject.assertThat(IntBlob.parse(repo, refName)).isEmpty(); } private ObjectId getRef(String refName) throws IOException {