X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=enrichment-coordinator-service%2Fsrc%2Ftest%2Fjava%2Forg%2Foransc%2Fenrichment%2Fcontroller%2FProducerSimulatorController.java;h=1c0767b01e759ea3c9ba359c2056fd4eb43daedf;hb=8fd8e9fc86a24be49d61841e381423120a41296d;hp=479c1b2d24c553cc8be9b227c4cbbb4e8a129e70;hpb=5d97a401dc1e26f64ad57daab90f924da9c12c64;p=nonrtric.git diff --git a/enrichment-coordinator-service/src/test/java/org/oransc/enrichment/controller/ProducerSimulatorController.java b/enrichment-coordinator-service/src/test/java/org/oransc/enrichment/controller/ProducerSimulatorController.java index 479c1b2d..1c0767b0 100644 --- a/enrichment-coordinator-service/src/test/java/org/oransc/enrichment/controller/ProducerSimulatorController.java +++ b/enrichment-coordinator-service/src/test/java/org/oransc/enrichment/controller/ProducerSimulatorController.java @@ -1,9 +1,9 @@ /*- * ========================LICENSE_START================================= - * ONAP : ccsdk oran - * ====================================================================== - * Copyright (C) 2019-2020 Nordix Foundation. All rights reserved. - * ====================================================================== + * O-RAN-SC + * %% + * Copyright (C) 2020 Nordix Foundation + * %% * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -20,10 +20,12 @@ package org.oransc.enrichment.controller; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import io.swagger.annotations.ApiResponse; -import io.swagger.annotations.ApiResponses; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.responses.ApiResponses; +import io.swagger.v3.oas.annotations.tags.Tag; import java.lang.invoke.MethodHandles; import java.util.ArrayList; @@ -32,37 +34,38 @@ import java.util.List; import lombok.Getter; -import org.oransc.enrichment.clients.ProducerJobInfo; import org.oransc.enrichment.controllers.ErrorResponse; import org.oransc.enrichment.controllers.VoidResponse; +import org.oransc.enrichment.controllers.r1producer.ProducerConsts; +import org.oransc.enrichment.controllers.r1producer.ProducerJobInfo; 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.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; @RestController("ProducerSimulatorController") -@Api(tags = {"Producer Simulator"}) +@Tag(name = ProducerConsts.PRODUCER_API_CALLBACKS_NAME) 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/info_job"; + public static final String JOB_ERROR_URL = "/producer_simulator/info_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 jobsStarted = Collections.synchronizedList(new ArrayList()); - public List jobsStopped = Collections.synchronizedList(new ArrayList()); + public List jobsStopped = Collections.synchronizedList(new ArrayList()); public int noOfRejectedCreate = 0; public int noOfRejectedDelete = 0; public boolean errorFound = false; @@ -82,12 +85,17 @@ public class ProducerSimulatorController { @Getter private TestResults testResults = new TestResults(); - @PostMapping(path = JOB_CREATED_URL, produces = MediaType.APPLICATION_JSON_VALUE) - @ApiOperation(value = "Callback for EI job creation", notes = "") + @PostMapping(path = JOB_URL, produces = MediaType.APPLICATION_JSON_VALUE) + @Operation( + summary = "Callback for Information Job creation/modification", + description = "The call is invoked to activate or to modify a data subscription. The endpoint is provided by the Information Producer.") @ApiResponses( value = { // - @ApiResponse(code = 200, message = "OK", response = VoidResponse.class)}// - ) + @ApiResponse( + responseCode = "200", + description = "OK", // + content = @Content(schema = @Schema(implementation = VoidResponse.class))) // + }) public ResponseEntity jobCreatedCallback( // @RequestBody ProducerJobInfo request) { try { @@ -103,29 +111,37 @@ public class ProducerSimulatorController { } } - @PostMapping(path = JOB_DELETED_URL, produces = MediaType.APPLICATION_JSON_VALUE) - @ApiOperation(value = "Callback for EI job deletion", notes = "") + @DeleteMapping(path = "/producer_simulator/info_job/{infoJobId}", produces = MediaType.APPLICATION_JSON_VALUE) + @Operation( + summary = "Callback for Information Job deletion", + description = "The call is invoked to terminate a data subscription. The endpoint is provided by the Information Producer.") @ApiResponses( value = { // - @ApiResponse(code = 200, message = "OK", response = VoidResponse.class)}// - ) + @ApiResponse( + responseCode = "200", + description = "OK", // + content = @Content(schema = @Schema(implementation = VoidResponse.class))) // + }) public ResponseEntity jobDeletedCallback( // - @RequestBody ProducerJobInfo request) { + @PathVariable("infoJobId") String infoJobId) { try { - logger.info("Job deleted callback {}", request.id); - this.testResults.jobsStopped.add(request); + logger.info("Job deleted callback {}", infoJobId); + this.testResults.jobsStopped.add(infoJobId); 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) - @ApiOperation(value = "Callback for EI job creation, returns error", notes = "") + @PostMapping(path = JOB_ERROR_URL, produces = MediaType.APPLICATION_JSON_VALUE) + @Operation(summary = "Callback for Information Job creation, returns error", description = "", hidden = true) @ApiResponses( value = { // - @ApiResponse(code = 200, message = "OK", response = VoidResponse.class)}// - ) + @ApiResponse( + responseCode = "200", + description = "OK", // + content = @Content(schema = @Schema(implementation = VoidResponse.class))) // + }) public ResponseEntity jobCreatedCallbackReturnError( // @RequestBody ProducerJobInfo request) { logger.info("Job created (returning error) callback {}", request.id); @@ -133,36 +149,47 @@ 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) - @ApiOperation(value = "Callback for EI job creation, returns error", notes = "") + @DeleteMapping(path = JOB_ERROR_URL + "/{infoJobId}", produces = MediaType.APPLICATION_JSON_VALUE) + @Operation(summary = "Callback for Information Job deletion, returns error", description = "", hidden = true) @ApiResponses( value = { // - @ApiResponse(code = 200, message = "OK", response = VoidResponse.class)}// - ) + @ApiResponse( + responseCode = "200", + description = "OK", // + content = @Content(schema = @Schema(implementation = VoidResponse.class))) // + }) public ResponseEntity jobDeletedCallbackReturnError( // - @RequestBody ProducerJobInfo request) { - logger.info("Job created (returning error) callback {}", request.id); + @PathVariable("infoJobId") String infoJobId) { + logger.info("Job created (returning error) callback {}", infoJobId); this.testResults.noOfRejectedDelete += 1; 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 = "") + @Operation( + summary = "Producer supervision", + description = "The endpoint is provided by the Information Producer and is used for supervision of the producer.") @ApiResponses( value = { // - @ApiResponse(code = 200, message = "OK", response = String.class)}// - ) + @ApiResponse( + responseCode = "200", + description = "The producer is OK", // + content = @Content(schema = @Schema(implementation = String.class))) // + }) public ResponseEntity 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 = "") + @Operation(summary = "Producer supervision error", description = "", hidden = true) @ApiResponses( value = { // - @ApiResponse(code = 200, message = "OK", response = String.class)}// - ) + @ApiResponse( + responseCode = "200", + description = "OK", // + content = @Content(schema = @Schema(implementation = String.class))) // + }) public ResponseEntity producerSupervisionError() { logger.info("Producer supervision error"); return new ResponseEntity<>(HttpStatus.NOT_FOUND);