}},
"tags": ["Actuator"]
}},
- "/data-consumer/v1/info-jobs": {"get": {
- "summary": "Information Job identifiers",
- "description": "query for information job identifiers",
- "operationId": "getJobIds",
- "responses": {
- "200": {
- "description": "Information information job identifiers",
- "content": {"application/json": {"schema": {
- "type": "array",
- "items": {"type": "string"}
- }}}
+ "/data-consumer/v1/info-jobs": {
+ "get": {
+ "summary": "Information Job identifiers",
+ "description": "query for information job identifiers",
+ "operationId": "getJobIds",
+ "responses": {
+ "200": {
+ "description": "Information information job identifiers",
+ "content": {"application/json": {"schema": {
+ "type": "array",
+ "items": {"type": "string"}
+ }}}
+ },
+ "404": {
+ "description": "Information type is not found",
+ "content": {"application/json": {"schema": {"$ref": "#/components/schemas/ProblemDetails"}}}
+ }
},
- "404": {
- "description": "Information type is not found",
- "content": {"application/json": {"schema": {"$ref": "#/components/schemas/ProblemDetails"}}}
- }
+ "parameters": [
+ {
+ "schema": {"type": "string"},
+ "in": "query",
+ "name": "infoTypeId",
+ "description": "selects subscription jobs of matching information type",
+ "required": false
+ },
+ {
+ "schema": {"type": "string"},
+ "in": "query",
+ "name": "owner",
+ "description": "selects result for one owner",
+ "required": false
+ }
+ ],
+ "tags": ["Data consumer"]
},
- "parameters": [
- {
- "schema": {"type": "string"},
- "in": "query",
- "name": "infoTypeId",
- "description": "selects subscription jobs of matching information type",
- "required": false
- },
- {
+ "delete": {
+ "summary": "Information Jobs",
+ "description": "delete all jobs for one owner",
+ "operationId": "deleteJobsForOwner",
+ "responses": {"204": {
+ "description": "No Content",
+ "content": {"application/json": {"schema": {"type": "object"}}}
+ }},
+ "parameters": [{
"schema": {"type": "string"},
"in": "query",
"name": "owner",
"description": "selects result for one owner",
- "required": false
- }
- ],
- "tags": ["Data consumer"]
- }},
+ "required": true
+ }],
+ "tags": ["Data consumer"]
+ }
+ },
"/actuator/loggers/{name}": {
"post": {
"summary": "Actuator web endpoint 'loggers-name'",
}
}
+ @DeleteMapping(path = "/info-jobs", produces = MediaType.APPLICATION_JSON_VALUE)
+ @Operation(summary = "Information Jobs", description = "delete all jobs for one owner")
+ @ApiResponses(
+ value = { //
+ @ApiResponse(responseCode = "204") //
+ })
+ public ResponseEntity<Object> deleteJobsForOwner( //
+
+ @Parameter(
+ name = ConsumerConsts.OWNER_PARAM,
+ required = true, //
+ description = ConsumerConsts.OWNER_PARAM_DESCRIPTION) //
+ @RequestParam(name = ConsumerConsts.OWNER_PARAM, required = true) String owner) {
+
+ for (InfoJob job : this.infoJobs.getJobsForOwner(owner)) {
+
+ logger.debug("DELETE info jobs, id: {}, type: {}, owner: {}", job.getId(), job.getTypeId(), owner);
+ this.infoJobs.remove(job, this.infoProducers);
+ }
+ return new ResponseEntity<>(HttpStatus.NO_CONTENT);
+ }
+
@GetMapping(path = "/info-jobs/{infoJobId}", produces = MediaType.APPLICATION_JSON_VALUE) //
@Operation(summary = ConsumerConsts.INDIVIDUAL_JOB, description = "") //
@ApiResponses(
assertThat(rsp).isEqualTo("[\"test\"]");
}
+ @Test
+ void consumerDeleteJobsForOneOwner() throws Exception {
+ putInfoProducerWithOneType("producer1", TYPE_ID);
+ putInfoJob(TYPE_ID, "jobId1");
+ putInfoJob(TYPE_ID, "jobId2");
+ putInfoJob(TYPE_ID, "jobId3", "otherOwner");
+ assertThat(this.infoJobs.size()).isEqualTo(3);
+ String url = ConsumerConsts.API_ROOT + "/info-jobs?owner=owner";
+ restClient().delete(url).block();
+ assertThat(this.infoJobs.size()).isEqualTo(1);
+
+ assertThat(this.producerSimulator.getTestResults().jobsStarted).hasSize(3);
+
+ await().untilAsserted(() -> assertThat(this.producerSimulator.getTestResults().jobsStopped).hasSize(2));
+
+ }
+
@Test
void a1eGetEiTypesEmpty() throws Exception {
String url = A1eConsts.API_ROOT + "/eitypes";
}
@Test
- void producerPutProducerWithOneType_rejecting()
- throws JsonMappingException, JsonProcessingException, ServiceException {
+ void producerPutProducerWithOneType_rejecting() throws Exception {
putInfoProducerWithOneTypeRejecting("simulateProducerError", TYPE_ID);
String url = A1eConsts.API_ROOT + "/eijobs/" + EI_JOB_ID;
String body = gson.toJson(infoJobInfo());
}
@Test
- void producerGetInfoJobsForProducer() throws JsonMappingException, JsonProcessingException, ServiceException {
+ void producerGetInfoJobsForProducer() throws Exception {
putInfoProducerWithOneType(PRODUCER_ID, TYPE_ID);
putInfoJob(TYPE_ID, "jobId1");
putInfoJob(TYPE_ID, "jobId2");
}
@Test
- void a1eJobStatusNotifications() throws JsonMappingException, JsonProcessingException, ServiceException {
+ void a1eJobStatusNotifications() throws Exception {
A1eCallbacksSimulatorController.TestResults consumerCalls = this.a1eCallbacksSimulator.getTestResults();
ProducerSimulatorController.TestResults producerCalls = this.producerSimulator.getTestResults();
}
@Test
- void a1eJobStatusNotifications2() throws JsonMappingException, JsonProcessingException, ServiceException {
+ void a1eJobStatusNotifications2() throws Exception {
// Test replacing a producer with new and removed types
// Create a job
}
@Test
- void producerSupervision() throws JsonMappingException, JsonProcessingException, ServiceException {
+ void producerSupervision() throws Exception {
A1eCallbacksSimulatorController.TestResults consumerResults = this.a1eCallbacksSimulator.getTestResults();
putInfoProducerWithOneTypeRejecting("simulateProducerError", TYPE_ID);
}
@Test
- void producerSupervision2() throws JsonMappingException, JsonProcessingException, ServiceException {
+ void producerSupervision2() throws Exception {
// Test that supervision enables not enabled jobs and sends a notification when
// suceeded
baseUrl() + A1eCallbacksSimulatorController.getJobStatusUrl(infoJobId));
}
- private A1eEiJobInfo infoJobInfo() throws JsonMappingException, JsonProcessingException {
+ private A1eEiJobInfo infoJobInfo() throws Exception {
return infoJobInfo(TYPE_ID, EI_JOB_ID);
}
- A1eEiJobInfo infoJobInfo(String typeId, String infoJobId) throws JsonMappingException, JsonProcessingException {
- return new A1eEiJobInfo(typeId, jsonObject(), "owner", "https://junk.com",
+ A1eEiJobInfo infoJobInfo(String typeId, String infoJobId) throws Exception {
+ return infoJobInfo(typeId, infoJobId, "owner");
+
+ }
+
+ A1eEiJobInfo infoJobInfo(String typeId, String infoJobId, String owner) throws Exception {
+ return new A1eEiJobInfo(typeId, jsonObject(), owner, "https://junk.com",
baseUrl() + A1eCallbacksSimulatorController.getJobStatusUrl(infoJobId));
}
return jsonObject("{ " + EI_JOB_PROPERTY + " : \"value\" }");
}
- private InfoJob putInfoJob(String infoTypeId, String jobId)
- throws JsonMappingException, JsonProcessingException, ServiceException {
+ private InfoJob putInfoJob(String infoTypeId, String jobId, String owner) throws Exception {
+ String url = A1eConsts.API_ROOT + "/eijobs/" + jobId;
+ String body = gson.toJson(infoJobInfo(infoTypeId, jobId, owner));
+ restClient().putForEntity(url, body).block();
+
+ return this.infoJobs.getJob(jobId);
+
+ }
+
+ private InfoJob putInfoJob(String infoTypeId, String jobId) throws Exception {
String url = A1eConsts.API_ROOT + "/eijobs/" + jobId;
String body = gson.toJson(infoJobInfo(infoTypeId, jobId));