SpannerRefDatabaseTest: Use Google truth instead of JUnit assertions
Change-Id: If088f63538ceec3e2bae704c23910f6e3cea7c3b
diff --git a/src/test/java/com/googlesource/gerrit/plugins/spannerrefdb/SpannerRefDatabaseTest.java b/src/test/java/com/googlesource/gerrit/plugins/spannerrefdb/SpannerRefDatabaseTest.java
index 34ef27f..826a409 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/spannerrefdb/SpannerRefDatabaseTest.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/spannerrefdb/SpannerRefDatabaseTest.java
@@ -14,11 +14,7 @@
package com.googlesource.gerrit.plugins.spannerrefdb;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
+import static com.google.common.truth.Truth.assertThat;
import com.google.gerrit.entities.Project;
import java.util.Optional;
@@ -85,10 +81,10 @@
throws Exception {
Ref ref = nullRef(refName);
try (AutoCloseable lock = refdb.lockRef(project, refName)) {
- assertTrue(refdb.compareAndPut(project, ref, newValue));
+ assertThat(refdb.compareAndPut(project, ref, newValue)).isTrue();
Optional<ObjectId> oid = refdb.getObjectId(project, refName);
- assertFalse(oid.isEmpty());
- assertEquals(newValue, oid.get());
+ assertThat(oid.isEmpty()).isFalse();
+ assertThat(newValue).isEqualTo(oid.get());
}
}
@@ -97,8 +93,8 @@
throws Exception {
Ref expecRef = newRef(refName, oldValue);
try (AutoCloseable lock = refdb.lockRef(project, refName)) {
- assertTrue(refdb.compareAndPut(project, expecRef, newValue));
- assertEquals(newValue, refdb.getObjectId(project, refName).get());
+ assertThat(refdb.compareAndPut(project, expecRef, newValue)).isTrue();
+ assertThat(newValue).isEqualTo(refdb.getObjectId(project, refName).get());
}
}
@@ -106,33 +102,35 @@
throws Exception {
Ref expecRef = newRef(refName, oldValue);
try (AutoCloseable lock = refdb.lockRef(project, refName)) {
- assertTrue(refdb.compareAndPut(project, expecRef, ObjectId.zeroId()));
- assertTrue(refdb.getObjectId(project, refName).isEmpty());
+ assertThat(refdb.compareAndPut(project, expecRef, ObjectId.zeroId())).isTrue();
+ assertThat(refdb.getObjectId(project, refName).isEmpty()).isTrue();
}
}
private void createNewRef(Project.NameKey project, String refName, String newValue)
throws Exception {
try (AutoCloseable lock = refdb.lockRef(project, refName)) {
- assertTrue(refdb.compareAndPut(project, refName, ObjectId.zeroId().name(), newValue));
- assertNotNull(refdb.get(project, refName));
- assertEquals(newValue, refdb.get(project, refName));
+ assertThat(refdb.compareAndPut(project, refName, ObjectId.zeroId().name(), newValue))
+ .isTrue();
+ assertThat(refdb.get(project, refName)).isNotNull();
+ assertThat(newValue).isEqualTo(refdb.get(project, refName));
}
}
private void updateRef(Project.NameKey project, String refName, String oldValue, String newValue)
throws Exception {
try (AutoCloseable lock = refdb.lockRef(project, refName)) {
- assertTrue(refdb.compareAndPut(project, refName, oldValue, newValue));
- assertEquals(newValue, refdb.get(project, refName));
+ assertThat(refdb.compareAndPut(project, refName, oldValue, newValue)).isTrue();
+ assertThat(newValue).isEqualTo(refdb.get(project, refName));
}
}
private void deleteRef(Project.NameKey project, String refName, String oldValue)
throws Exception {
try (AutoCloseable lock = refdb.lockRef(project, refName)) {
- assertTrue(refdb.compareAndPut(project, refName, oldValue, ObjectId.zeroId().name()));
- assertNull(refdb.get(project, refName));
+ assertThat(refdb.compareAndPut(project, refName, oldValue, ObjectId.zeroId().name()))
+ .isTrue();
+ assertThat(refdb.get(project, refName)).isNull();
}
}
}