Merge "Added supervision of producers"
[nonrtric.git] / enrichment-coordinator-service / src / test / java / org / oransc / enrichment / controller / ProducerSimulatorController.java
index c44a9ee..479c1b2 100644 (file)
@@ -34,11 +34,13 @@ import lombok.Getter;
 
 import org.oransc.enrichment.clients.ProducerJobInfo;
 import org.oransc.enrichment.controllers.ErrorResponse;
+import org.oransc.enrichment.controllers.VoidResponse;
 import org.slf4j.Logger;
 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.GetMapping;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RestController;
@@ -54,6 +56,9 @@ public class ProducerSimulatorController {
     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 SUPERVISION_URL = "/producer_simulator/supervision";
+    public static final String SUPERVISION_ERROR_URL = "/producer_simulator/supervision_error";
+
     public static class TestResults {
 
         public List<ProducerJobInfo> jobsStarted = Collections.synchronizedList(new ArrayList<ProducerJobInfo>());
@@ -81,7 +86,7 @@ public class ProducerSimulatorController {
     @ApiOperation(value = "Callback for EI job creation", notes = "")
     @ApiResponses(
         value = { //
-            @ApiResponse(code = 200, message = "OK", response = void.class)}//
+            @ApiResponse(code = 200, message = "OK", response = VoidResponse.class)}//
     )
     public ResponseEntity<Object> jobCreatedCallback( //
         @RequestBody ProducerJobInfo request) {
@@ -102,7 +107,7 @@ public class ProducerSimulatorController {
     @ApiOperation(value = "Callback for EI job deletion", notes = "")
     @ApiResponses(
         value = { //
-            @ApiResponse(code = 200, message = "OK", response = void.class)}//
+            @ApiResponse(code = 200, message = "OK", response = VoidResponse.class)}//
     )
     public ResponseEntity<Object> jobDeletedCallback( //
         @RequestBody ProducerJobInfo request) {
@@ -119,7 +124,7 @@ public class ProducerSimulatorController {
     @ApiOperation(value = "Callback for EI job creation, returns error", notes = "")
     @ApiResponses(
         value = { //
-            @ApiResponse(code = 200, message = "OK", response = void.class)}//
+            @ApiResponse(code = 200, message = "OK", response = VoidResponse.class)}//
     )
     public ResponseEntity<Object> jobCreatedCallbackReturnError( //
         @RequestBody ProducerJobInfo request) {
@@ -132,7 +137,7 @@ public class ProducerSimulatorController {
     @ApiOperation(value = "Callback for EI job creation, returns error", notes = "")
     @ApiResponses(
         value = { //
-            @ApiResponse(code = 200, message = "OK", response = void.class)}//
+            @ApiResponse(code = 200, message = "OK", response = VoidResponse.class)}//
     )
     public ResponseEntity<Object> jobDeletedCallbackReturnError( //
         @RequestBody ProducerJobInfo request) {
@@ -141,4 +146,26 @@ public class ProducerSimulatorController {
         return ErrorResponse.create("Producer returns error on delete job", HttpStatus.NOT_FOUND);
     }
 
+    @GetMapping(path = SUPERVISION_URL, produces = MediaType.APPLICATION_JSON_VALUE)
+    @ApiOperation(value = "Producer supervision", notes = "")
+    @ApiResponses(
+        value = { //
+            @ApiResponse(code = 200, message = "OK", response = String.class)}//
+    )
+    public ResponseEntity<Object> producerSupervision() {
+        logger.info("Producer supervision");
+        return new ResponseEntity<>(HttpStatus.OK);
+    }
+
+    @GetMapping(path = SUPERVISION_ERROR_URL, produces = MediaType.APPLICATION_JSON_VALUE)
+    @ApiOperation(value = "Producer supervision error", notes = "")
+    @ApiResponses(
+        value = { //
+            @ApiResponse(code = 200, message = "OK", response = String.class)}//
+    )
+    public ResponseEntity<Object> producerSupervisionError() {
+        logger.info("Producer supervision error");
+        return new ResponseEntity<>(HttpStatus.NOT_FOUND);
+    }
+
 }