Merge changes I257382ad,I8ce16c97
* changes:
ChecksSubmitRule: Catch all RuntimeExceptions
Populate CombinedCheckState in query path from a cache
diff --git a/javatests/com/google/gerrit/plugins/checks/CheckerUuidTest.java b/javatests/com/google/gerrit/plugins/checks/CheckerUuidTest.java
index 46bf2f8..be79a8d 100644
--- a/javatests/com/google/gerrit/plugins/checks/CheckerUuidTest.java
+++ b/javatests/com/google/gerrit/plugins/checks/CheckerUuidTest.java
@@ -14,7 +14,9 @@
package com.google.gerrit.plugins.checks;
+import static com.google.common.truth.OptionalSubject.optionals;
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.plugins.checks.CheckerUuid.MAX_SCHEME_LENGTH;
import static java.util.stream.Collectors.joining;
@@ -74,20 +76,21 @@
@Test
public void isUuid() {
for (String checkerUuid : VALID_CHECKER_UUIDS) {
- assertThat(CheckerUuid.isUuid(checkerUuid)).named(checkerUuid).isTrue();
+ assertWithMessage(checkerUuid).that(CheckerUuid.isUuid(checkerUuid)).isTrue();
}
assertThat(CheckerUuid.isUuid(null)).isFalse();
for (String invalidCheckerUuid : INVALID_CHECKER_UUIDS) {
- assertThat(CheckerUuid.isUuid(invalidCheckerUuid)).named(invalidCheckerUuid).isFalse();
+ assertWithMessage(invalidCheckerUuid).that(CheckerUuid.isUuid(invalidCheckerUuid)).isFalse();
}
}
@Test
public void parseValidUuids() {
for (String uuidString : VALID_CHECKER_UUIDS) {
- assertThat(CheckerUuid.tryParse(uuidString).map(CheckerUuid::get))
- .named(uuidString)
+ assertWithMessage(uuidString)
+ .about(optionals())
+ .that(CheckerUuid.tryParse(uuidString).map(CheckerUuid::get))
.hasValue(uuidString);
CheckerUuid checkerUuid;
try {
@@ -95,9 +98,9 @@
} catch (RuntimeException e) {
throw new AssertionError("failed to parse " + uuidString, e);
}
- assertThat(checkerUuid.get()).named(uuidString).isEqualTo(uuidString);
- assertThat(Repository.isValidRefName(checkerUuid.toRefName()))
- .named("valid ref name: %s", checkerUuid.toRefName())
+ assertWithMessage(uuidString).that(checkerUuid.get()).isEqualTo(uuidString);
+ assertWithMessage("valid ref name: %s", checkerUuid.toRefName())
+ .that(Repository.isValidRefName(checkerUuid.toRefName()))
.isTrue();
}
}
@@ -134,6 +137,9 @@
}
private static void assertInvalid(@Nullable String uuidString) {
- assertThat(CheckerUuid.tryParse(uuidString)).named(String.valueOf(uuidString)).isEmpty();
+ assertWithMessage(String.valueOf(uuidString))
+ .about(optionals())
+ .that(CheckerUuid.tryParse(uuidString))
+ .isEmpty();
}
}
diff --git a/javatests/com/google/gerrit/plugins/checks/api/CombinedCheckStateTest.java b/javatests/com/google/gerrit/plugins/checks/api/CombinedCheckStateTest.java
index cbbdfc2..a68093a 100644
--- a/javatests/com/google/gerrit/plugins/checks/api/CombinedCheckStateTest.java
+++ b/javatests/com/google/gerrit/plugins/checks/api/CombinedCheckStateTest.java
@@ -17,6 +17,7 @@
import static com.google.common.collect.ImmutableListMultimap.toImmutableListMultimap;
import static com.google.common.collect.ImmutableSet.toImmutableSet;
import static com.google.common.truth.Truth.assertThat;
+import static com.google.common.truth.Truth.assertWithMessage;
import com.google.common.collect.ImmutableListMultimap;
import com.google.common.collect.ImmutableMap;
@@ -83,8 +84,8 @@
for (CheckState inProgress : ALL_IN_PROGRESS) {
for (Set<CheckState> subset : Sets.powerSet(others)) {
Set<CheckState> toCombine = Sets.union(ImmutableSet.of(inProgress), subset);
- assertThat(combine(toCombine))
- .named(toCombine.toString())
+ assertWithMessage(toCombine.toString())
+ .that(combine(toCombine))
.isEqualTo(CombinedCheckState.IN_PROGRESS);
}
}
@@ -94,8 +95,8 @@
public void combineFailedAlwaysWins() {
for (CheckState other : EnumSet.complementOf(EnumSet.of(CheckState.FAILED))) {
Set<CheckState> toCombine = ImmutableSet.of(CheckState.FAILED, other);
- assertThat(combine(toCombine))
- .named(toCombine.toString())
+ assertWithMessage(toCombine.toString())
+ .that(combine(toCombine))
.isEqualTo(CombinedCheckState.FAILED);
}
}
@@ -104,8 +105,8 @@
public void combineFailedBeatsInProgress() {
for (CheckState inProgress : ALL_IN_PROGRESS) {
Set<CheckState> toCombine = ImmutableSet.of(inProgress, CheckState.FAILED);
- assertThat(combine(toCombine))
- .named(toCombine.toString())
+ assertWithMessage(toCombine.toString())
+ .that(combine(toCombine))
.isEqualTo(CombinedCheckState.FAILED);
}
}