Merge "Add backend support for re-running checks."
diff --git a/javatests/com/google/gerrit/plugins/checks/acceptance/api/UpdateCheckIT.java b/javatests/com/google/gerrit/plugins/checks/acceptance/api/UpdateCheckIT.java
index c6aa0c1..7cc2ce8 100644
--- a/javatests/com/google/gerrit/plugins/checks/acceptance/api/UpdateCheckIT.java
+++ b/javatests/com/google/gerrit/plugins/checks/acceptance/api/UpdateCheckIT.java
@@ -17,9 +17,11 @@
 import static com.google.common.truth.Truth.assertThat;
 import static com.google.gerrit.testing.GerritJUnit.assertThrows;
 
+import com.google.gerrit.acceptance.testsuite.project.ProjectOperations;
 import com.google.gerrit.acceptance.testsuite.request.RequestScopeOperations;
 import com.google.gerrit.extensions.restapi.AuthException;
 import com.google.gerrit.extensions.restapi.BadRequestException;
+import com.google.gerrit.extensions.restapi.ResourceNotFoundException;
 import com.google.gerrit.plugins.checks.CheckKey;
 import com.google.gerrit.plugins.checks.CheckerUuid;
 import com.google.gerrit.plugins.checks.acceptance.AbstractCheckersTest;
@@ -42,6 +44,7 @@
 
 public class UpdateCheckIT extends AbstractCheckersTest {
   @Inject private RequestScopeOperations requestScopeOperations;
+  @Inject private ProjectOperations projectOperations;
 
   private PatchSet.Id patchSetId;
   private CheckKey checkKey;
@@ -227,8 +230,9 @@
   }
 
   @Test
-  public void canUpdateCheckForCheckerThatDoesNotApplyToTheProject() throws Exception {
-    Project.NameKey otherProject = createProjectOverAPI("other", null, true, null);
+  public void canUpdateCheckForCheckerThatDoesNotApplyToTheProjectAndCheckExists()
+      throws Exception {
+    Project.NameKey otherProject = projectOperations.newProject().create();
     checkerOperations.checker(checkKey.checkerUuid()).forUpdate().repository(otherProject).update();
 
     CheckInput input = new CheckInput();
@@ -239,6 +243,22 @@
   }
 
   @Test
+  public void
+      throwExceptionForUpdateCheckForCheckerThatDoesNotApplyToTheProjectAndCheckDoesNotExist()
+          throws Exception {
+    Project.NameKey otherProject = projectOperations.newProject().create();
+    CheckerUuid checkerUuid = checkerOperations.newChecker().repository(otherProject).create();
+    CheckKey checkKey = CheckKey.create(otherProject, patchSetId, checkerUuid);
+    assertThrows(
+        ResourceNotFoundException.class,
+        () ->
+            checksApiFactory
+                .revision(patchSetId)
+                .id(checkKey.checkerUuid())
+                .update(new CheckInput()));
+  }
+
+  @Test
   public void canUpdateCheckForCheckerWithUnsupportedOperatorInQuery() throws Exception {
     checkerOperations
         .checker(checkKey.checkerUuid())
diff --git a/resources/Documentation/rest-api-checks.md b/resources/Documentation/rest-api-checks.md
index c9de7a5..4395644 100644
--- a/resources/Documentation/rest-api-checks.md
+++ b/resources/Documentation/rest-api-checks.md
@@ -1,4 +1,4 @@
-# /changes/<id>/revisions/<id>/checks/ REST API
+# /changes/`id`/revisions/`id`/checks/ REST API
 
 This page describes the check-related REST endpoints that are added by the
 @PLUGIN@ plugin.
@@ -143,6 +143,7 @@
 
 ### <a id="update-check"> Update Check
 _'POST /changes/1/revisions/1/checks/'_
+
 _'POST /changes/1/revisions/1/checks/test:my-checker'_
 
 Updates a check. The semantics are the same as for [CreateCheck](#create-check).