Skip to content

Commit

Permalink
Temporarily qualify calls to custom assertThat(Optional) methods
Browse files Browse the repository at this point in the history
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 <ekempin@google.com>
  • Loading branch information
EdwinKempin committed Jan 15, 2024
1 parent 762b64a commit 454e167
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions javatests/com/google/gerrit/server/notedb/IntBlobTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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));
}
Expand All @@ -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));
}
Expand All @@ -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));
}
Expand All @@ -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));
}
Expand All @@ -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));
}
Expand All @@ -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));
}
Expand All @@ -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 {
Expand Down

0 comments on commit 454e167

Please # to comment.