Query pending checks: Test with AND condition that has checker somewhere nested

It's allowed to have an AND condition at root level if it contains
exactly one checker operator as immediate child. If the checker operator
is not an immediate child but nested more deeply the query should be
rejected. This was not tested yet.

Signed-off-by: Edwin Kempin <ekempin@google.com>
Change-Id: Icc177e7c8397112dd258dc5f306dc7731e21d936
diff --git a/javatests/com/google/gerrit/plugins/checks/acceptance/api/QueryPendingChecksIT.java b/javatests/com/google/gerrit/plugins/checks/acceptance/api/QueryPendingChecksIT.java
index c15b5d1..7783dbf 100644
--- a/javatests/com/google/gerrit/plugins/checks/acceptance/api/QueryPendingChecksIT.java
+++ b/javatests/com/google/gerrit/plugins/checks/acceptance/api/QueryPendingChecksIT.java
@@ -111,13 +111,13 @@
   }
 
   @Test
-  public void canSpecifyCheckersAsRootPredicate() throws Exception {
+  public void canSpecifyCheckerAsRootPredicate() throws Exception {
     CheckerUuid checkerUuid = checkerOperations.newChecker().repository(project).create();
     assertThat(queryPendingChecks(String.format("checker:\"%s\"", checkerUuid))).hasSize(1);
   }
 
   @Test
-  public void canSpecifyCheckersInAndCondition() throws Exception {
+  public void canSpecifyCheckerInAndCondition() throws Exception {
     CheckerUuid checkerUuid = checkerOperations.newChecker().repository(project).create();
     assertThat(
             queryPendingChecks(String.format("checker:\"%s\" AND state:NOT_STARTED", checkerUuid)))
@@ -125,6 +125,19 @@
   }
 
   @Test
+  public void cannotSpecifyCheckerInAndConditionIfNotImmediateChild() throws Exception {
+    CheckerUuid checkerUuid = checkerOperations.newChecker().repository(project).create();
+
+    String expectedMessage =
+        "query must be 'checker:<checker-uuid>' or 'checker:<checker-uuid> AND <other-operators>'";
+    assertInvalidQuery(
+        String.format("state:NOT_STARTED AND (checker:\"%s\" OR state:NOT_STARTED)", checkerUuid),
+        expectedMessage);
+    assertInvalidQuery(
+        String.format("state:NOT_STARTED AND NOT checker:\"%s\"", checkerUuid), expectedMessage);
+  }
+
+  @Test
   public void andConditionAtRootCanContainAnyCombinationOfOtherPredicates() throws Exception {
     CheckerUuid checkerUuid = checkerOperations.newChecker().repository(project).create();
 
@@ -146,7 +159,7 @@
   }
 
   @Test
-  public void cannotSpecifyCheckersInOrCondition() throws Exception {
+  public void cannotSpecifyCheckerInOrCondition() throws Exception {
     CheckerUuid checkerUuid = checkerOperations.newChecker().repository(project).create();
 
     String expectedMessage =
@@ -158,7 +171,7 @@
   }
 
   @Test
-  public void cannotSpecifyCheckersInNotCondition() throws Exception {
+  public void cannotSpecifyCheckerInNotCondition() throws Exception {
     CheckerUuid checkerUuid = checkerOperations.newChecker().repository(project).create();
     assertInvalidQuery(
         String.format("NOT checker:\"%s\"", checkerUuid),