Test that listing checks with options works if checkers are invalid

When the ListChecksOption.CHECKER option is used for listing checks
additional fields in CheckInfo are populated ('checkerName', 'blocking'
and 'checkerStatus'). Populating these fields is only possible when the
checker has a valid configuration. If the checker configuration is
invalid we expect that listing checks still works and that the
additional fields are not populated for invalid checkers.

Change-Id: I7b76558600a2254732ad4705d5c2a4044367fb0a
Signed-off-by: Edwin Kempin <ekempin@google.com>
diff --git a/javatests/com/google/gerrit/plugins/checks/acceptance/api/ListChecksIT.java b/javatests/com/google/gerrit/plugins/checks/acceptance/api/ListChecksIT.java
index c7348ba..cdd5f29 100644
--- a/javatests/com/google/gerrit/plugins/checks/acceptance/api/ListChecksIT.java
+++ b/javatests/com/google/gerrit/plugins/checks/acceptance/api/ListChecksIT.java
@@ -16,6 +16,7 @@
 
 import static com.google.common.collect.Iterables.getOnlyElement;
 import static com.google.common.truth.Truth.assertThat;
+import static com.google.common.truth.Truth8.assertThat;
 import static com.google.gerrit.extensions.client.ListChangesOption.CURRENT_REVISION;
 
 import com.google.common.collect.ImmutableSet;
@@ -32,6 +33,8 @@
 import com.google.gerrit.reviewdb.client.Project;
 import java.sql.Timestamp;
 import java.util.Collection;
+import java.util.List;
+import java.util.Optional;
 import org.junit.Before;
 import org.junit.Test;
 
@@ -112,6 +115,31 @@
   }
 
   @Test
+  public void listAllWithOptionsSkipsPopulatingCheckerFieldsForInvalidCheckers() throws Exception {
+    checkerOperations.checker(checkKey1.checkerUuid()).forUpdate().forceInvalidConfig().update();
+
+    List<CheckInfo> checks = checksApiFactory.revision(patchSetId).list(ListChecksOption.CHECKER);
+
+    assertThat(checks).hasSize(2);
+
+    Optional<CheckInfo> maybeCheck1 =
+        checks.stream().filter(c -> c.checkerUuid.equals(checkKey1.checkerUuid().get())).findAny();
+    assertThat(maybeCheck1).isPresent();
+    CheckInfo check1 = maybeCheck1.get();
+    assertThat(check1.checkerName).isNull();
+    assertThat(check1.blocking).isNull();
+    assertThat(check1.checkerStatus).isNull();
+
+    Optional<CheckInfo> maybeCheck2 =
+        checks.stream().filter(c -> c.checkerUuid.equals(checkKey2.checkerUuid().get())).findAny();
+    assertThat(maybeCheck2).isPresent();
+    CheckInfo check2 = maybeCheck2.get();
+    assertThat(check2.checkerName).isEqualTo("Checker Two");
+    assertThat(check2.blocking).isEmpty();
+    assertThat(check2.checkerStatus).isEqualTo(CheckerStatus.ENABLED);
+  }
+
+  @Test
   public void listIncludesCheckFromCheckerThatDoesNotApplyToTheProject() throws Exception {
     Project.NameKey otherProject = createProjectOverAPI("other", null, true, null);
     checkerOperations