Merge "ListChecksIT: fix flaky test"
diff --git a/java/com/google/gerrit/plugins/checks/api/ListPendingChecks.java b/java/com/google/gerrit/plugins/checks/api/ListPendingChecks.java
index a4535bc..9bc5bb6 100644
--- a/java/com/google/gerrit/plugins/checks/api/ListPendingChecks.java
+++ b/java/com/google/gerrit/plugins/checks/api/ListPendingChecks.java
@@ -33,7 +33,6 @@
private final AdministrateCheckersPermission permission;
private CheckerUuid checkerUuid;
- private String scheme;
private List<CheckState> states = new ArrayList<>(CheckState.values().length);
@Option(
@@ -45,11 +44,6 @@
this.checkerUuid = checkerUuid;
}
- @Option(name = "--scheme", metaVar = "SCHEME", usage = "checker scheme")
- public void setScheme(String scheme) {
- this.scheme = scheme;
- }
-
@Option(name = "--state", metaVar = "STATE", usage = "check state")
public void addState(CheckState state) {
this.states.add(state);
@@ -72,12 +66,8 @@
states.add(CheckState.NOT_STARTED);
}
- if (checkerUuid == null && scheme == null) {
- throw new BadRequestException("checker or scheme is required");
- }
-
- if (checkerUuid != null && scheme != null) {
- throw new BadRequestException("checker and scheme are mutually exclusive");
+ if (checkerUuid == null) {
+ throw new BadRequestException("checker UUID is required");
}
// TODO(ekempin): Implement this REST endpoint
diff --git a/java/com/google/gerrit/plugins/checks/api/PendingChecks.java b/java/com/google/gerrit/plugins/checks/api/PendingChecks.java
index 8b0811b..361472b 100644
--- a/java/com/google/gerrit/plugins/checks/api/PendingChecks.java
+++ b/java/com/google/gerrit/plugins/checks/api/PendingChecks.java
@@ -52,17 +52,6 @@
}
/**
- * Lists the pending checks for all checkers of the specified checker scheme.
- *
- * @param scheme the checker scheme for which pending checks should be listed
- * @param checkStates the states that should be considered as pending, if not specified {@link
- * CheckState#NOT_STARTED} is assumed.
- * @return the pending checks
- */
- List<PendingChecksInfo> listForScheme(String scheme, CheckState... checkStates)
- throws RestApiException;
-
- /**
* A default implementation which allows source compatibility when adding new methods to the
* interface.
*/
@@ -71,10 +60,5 @@
public List<PendingChecksInfo> list(CheckerUuid checkerUuid, CheckState... checkStates) {
throw new NotImplementedException();
}
-
- @Override
- public List<PendingChecksInfo> listForScheme(String scheme, CheckState... checkStates) {
- throw new NotImplementedException();
- }
}
}
diff --git a/java/com/google/gerrit/plugins/checks/api/PendingChecksImpl.java b/java/com/google/gerrit/plugins/checks/api/PendingChecksImpl.java
index 0b9c139..ca4cf18 100644
--- a/java/com/google/gerrit/plugins/checks/api/PendingChecksImpl.java
+++ b/java/com/google/gerrit/plugins/checks/api/PendingChecksImpl.java
@@ -46,17 +46,4 @@
throw asRestApiException("Cannot list pending checks", e);
}
}
-
- @Override
- public List<PendingChecksInfo> listForScheme(String scheme, CheckState... checkStates)
- throws RestApiException {
- try {
- ListPendingChecks listPendingChecks = listPendingChecksProvider.get();
- listPendingChecks.setScheme(scheme);
- Stream.of(checkStates).forEach(listPendingChecks::addState);
- return listPendingChecks.apply(TopLevelResource.INSTANCE);
- } catch (Exception e) {
- throw asRestApiException("Cannot list pending checks for scheme", e);
- }
- }
}
diff --git a/javatests/com/google/gerrit/plugins/checks/acceptance/api/ListPendingChecksIT.java b/javatests/com/google/gerrit/plugins/checks/acceptance/api/ListPendingChecksIT.java
index 7cb8d53..2dd95f1 100644
--- a/javatests/com/google/gerrit/plugins/checks/acceptance/api/ListPendingChecksIT.java
+++ b/javatests/com/google/gerrit/plugins/checks/acceptance/api/ListPendingChecksIT.java
@@ -29,10 +29,12 @@
@Inject private RequestScopeOperations requestScopeOperations;
@Test
- public void specifyingEitherCheckerUuidOrSchemeIsRequired() throws Exception {
- exception.expect(BadRequestException.class);
- exception.expectMessage("checker or scheme is required");
- pendingChecksApi.listForScheme(null);
+ public void specifyingCheckerUuidIsRequired() throws Exception {
+ // The extension API doesn't allow to not specify a checker UUID. Call the endpoint over REST to
+ // test this.
+ RestResponse response = adminRestSession.get("/plugins/checks/checks.pending/");
+ response.assertBadRequest();
+ assertThat(response.getEntityContent()).isEqualTo("checker UUID is required");
}
@Test
@@ -43,18 +45,6 @@
}
@Test
- public void cannotSpecifyCheckerUuidAndScheme() throws Exception {
- // The extension API doesn't allow to specify checker UUID and scheme at the same time. Call the
- // endpoint over REST to test this.
- RestResponse response =
- adminRestSession.get(
- String.format(
- "/plugins/checks/checks.pending/?checker=%s&scheme=%s", "foo:bar", "foo"));
- response.assertBadRequest();
- assertThat(response.getEntityContent()).isEqualTo("checker and scheme are mutually exclusive");
- }
-
- @Test
public void cannotListPendingChecksWithoutAdministrateCheckers() throws Exception {
requestScopeOperations.setApiUser(user.getId());
@@ -69,11 +59,4 @@
exception.expectMessage("not implemented");
pendingChecksApi.list("foo:bar");
}
-
- @Test
- public void listPendingChecksForSchemeNotImplemented() throws Exception {
- exception.expect(MethodNotAllowedException.class);
- exception.expectMessage("not implemented");
- pendingChecksApi.listForScheme("foo");
- }
}
diff --git a/src/main/resources/Documentation/rest-api-pending-checks.md b/src/main/resources/Documentation/rest-api-pending-checks.md
index 39e2a1a..62e64c8 100644
--- a/src/main/resources/Documentation/rest-api-pending-checks.md
+++ b/src/main/resources/Documentation/rest-api-pending-checks.md
@@ -11,7 +11,7 @@
### <a id="get-checker"> List Pending Checks
_'GET /checks.pending/'_
-Lists pending checks for a checker or for all checkers of a scheme.
+Lists pending checks for a checker.
Checks are pending if they are in a non-final state and the external
checker system intends to post further updates on them.
@@ -23,11 +23,7 @@
Request parameters:
* <a id="checker-param"> `checker`: the UUID of the checker for which
- pending checks should be listed (optional, if not specified `scheme`
- must be set)
-* <a id="scheme-param"> `scheme`: the scheme of the checkers for which
- pending checks should be listed (optional, if not specified `checker`
- must be set)
+ pending checks should be listed (required)
* <a id="state-param"> `state`: state that should be considered as
pending (optional, by default the state `NOT_STARTED` is assumed,
this option may be specified multiple times to request checks
@@ -81,56 +77,6 @@
]
```
-#### Request by checker scheme
-
-```
- GET /checks.pending/?scheme=test&state=NOT_STARTED&state=SCHEDULED HTTP/1.0
-```
-
-As response a list of [PendingChecksInfo](#pending-checks-info)
-entities is returned that describes the pending checks.
-
-#### Response by checker scheme
-
-```
- HTTP/1.1 200 OK
- Content-Disposition: attachment
- Content-Type: application/json; charset=UTF-8
- )]}'
- [
- {
- "patch_set": {
- "project": "test-project",
- "change_number": 1,
- "patch_set_id": 1,
- }
- "pending_checks": {
- "test:my-checker": {
- "state": "NOT_STARTED",
- },
- "test:my-other-checker": {
- "state": "SCHEDULED",
- }
- }
- },
- {
- "patch_set": {
- "project": "test-project",
- "change_number": 5,
- "patch_set_id": 2,
- }
- "pending_checks": {
- "test:my-checker": {
- "state": "NOT_STARTED",
- },
- "test:my-other-checker": {
- "state": "NOT_STARTED",
- }
- }
- }
- ]
-```
-
## <a id="json-entities"> JSON Entities
### <a id="checkable-patch-set-info"> CheckablePatchSetInfo