Improvments of the producer API callbacks
[nonrtric.git] / enrichment-coordinator-service / src / test / java / org / oransc / enrichment / controller / ProducerSimulatorController.java
index cc61d21..2a3688c 100644 (file)
@@ -40,7 +40,9 @@ import org.slf4j.LoggerFactory;
 import org.springframework.http.HttpStatus;
 import org.springframework.http.MediaType;
 import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.DeleteMapping;
 import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RestController;
@@ -51,18 +53,16 @@ public class ProducerSimulatorController {
 
     private final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
 
-    public static final String JOB_CREATED_URL = "/producer_simulator/job_created";
-    public static final String JOB_DELETED_URL = "/producer_simulator/job_deleted";
-    public static final String JOB_CREATED_ERROR_URL = "/producer_simulator/job_created_error";
-    public static final String JOB_DELETED_ERROR_URL = "/producer_simulator/job_deleted_error";
+    public static final String JOB_URL = "/producer_simulator/ei_job";
+    public static final String JOB_ERROR_URL = "/producer_simulator/ei_job_error";
 
-    public static final String SUPERVISION_URL = "/producer_simulator/supervision";
-    public static final String SUPERVISION_ERROR_URL = "/producer_simulator/supervision_error";
+    public static final String SUPERVISION_URL = "/producer_simulator/health_check";
+    public static final String SUPERVISION_ERROR_URL = "/producer_simulator/health_check_error";
 
     public static class TestResults {
 
         public List<ProducerJobInfo> jobsStarted = Collections.synchronizedList(new ArrayList<ProducerJobInfo>());
-        public List<ProducerJobInfo> jobsStopped = Collections.synchronizedList(new ArrayList<ProducerJobInfo>());
+        public List<String> jobsStopped = Collections.synchronizedList(new ArrayList<String>());
         public int noOfRejectedCreate = 0;
         public int noOfRejectedDelete = 0;
         public boolean errorFound = false;
@@ -82,7 +82,7 @@ public class ProducerSimulatorController {
     @Getter
     private TestResults testResults = new TestResults();
 
-    @PostMapping(path = JOB_CREATED_URL, produces = MediaType.APPLICATION_JSON_VALUE)
+    @PostMapping(path = JOB_URL, produces = MediaType.APPLICATION_JSON_VALUE)
     @ApiOperation(value = "Callback for EI job creation", notes = "")
     @ApiResponses(
         value = { //
@@ -103,24 +103,24 @@ public class ProducerSimulatorController {
         }
     }
 
-    @PostMapping(path = JOB_DELETED_URL, produces = MediaType.APPLICATION_JSON_VALUE)
+    @DeleteMapping(path = "/producer_simulator/ei_job/{eiJobId}", produces = MediaType.APPLICATION_JSON_VALUE)
     @ApiOperation(value = "Callback for EI job deletion", notes = "")
     @ApiResponses(
         value = { //
             @ApiResponse(code = 200, message = "OK", response = VoidResponse.class)}//
     )
     public ResponseEntity<Object> jobDeletedCallback( //
-        @RequestBody ProducerJobInfo request) {
+        @PathVariable("eiJobId") String eiJobId) {
         try {
-            logger.info("Job deleted callback {}", request.id);
-            this.testResults.jobsStopped.add(request);
+            logger.info("Job deleted callback {}", eiJobId);
+            this.testResults.jobsStopped.add(eiJobId);
             return new ResponseEntity<>(HttpStatus.OK);
         } catch (Exception e) {
             return ErrorResponse.create(e, HttpStatus.NOT_FOUND);
         }
     }
 
-    @PostMapping(path = JOB_CREATED_ERROR_URL, produces = MediaType.APPLICATION_JSON_VALUE)
+    @PostMapping(path = JOB_ERROR_URL, produces = MediaType.APPLICATION_JSON_VALUE)
     @ApiOperation(value = "Callback for EI job creation, returns error", notes = "", hidden = true)
     @ApiResponses(
         value = { //
@@ -133,7 +133,7 @@ public class ProducerSimulatorController {
         return ErrorResponse.create("Producer returns error on create job", HttpStatus.NOT_FOUND);
     }
 
-    @PostMapping(path = JOB_DELETED_ERROR_URL, produces = MediaType.APPLICATION_JSON_VALUE)
+    @DeleteMapping(path = JOB_ERROR_URL + "/{eiJobId}", produces = MediaType.APPLICATION_JSON_VALUE)
     @ApiOperation(value = "Callback for EI job creation, returns error", notes = "", hidden = true)
     @ApiResponses(
         value = { //