diff options
author | waqas.ikram <waqas.ikram@est.tech> | 2020-01-28 16:07:47 +0000 |
---|---|---|
committer | waqas.ikram <waqas.ikram@est.tech> | 2020-01-28 18:08:36 +0000 |
commit | 1ac31d97454ec9e317d72f05b5c7847e541fedc7 (patch) | |
tree | 884bcdd2f35e2f318757caac5335c8c2dbed3d06 /plans/so/integration-etsi-testing/so-simulators/sdnc-simulator | |
parent | d0a68c3945879639bba7511fc8ea0c1a23518d90 (diff) |
Fix for SO-2617
Change-Id: Ie562083754e82068fd54118c5ba73714b7a53f2d
Issue-ID: SO-2617
Signed-off-by: waqas.ikram <waqas.ikram@est.tech>
Diffstat (limited to 'plans/so/integration-etsi-testing/so-simulators/sdnc-simulator')
3 files changed, 25 insertions, 19 deletions
diff --git a/plans/so/integration-etsi-testing/so-simulators/sdnc-simulator/src/main/java/org/onap/so/sdncsimulator/controller/OperationsController.java b/plans/so/integration-etsi-testing/so-simulators/sdnc-simulator/src/main/java/org/onap/so/sdncsimulator/controller/OperationsController.java index f96224d3..2f24ef69 100644 --- a/plans/so/integration-etsi-testing/so-simulators/sdnc-simulator/src/main/java/org/onap/so/sdncsimulator/controller/OperationsController.java +++ b/plans/so/integration-etsi-testing/so-simulators/sdnc-simulator/src/main/java/org/onap/so/sdncsimulator/controller/OperationsController.java @@ -52,6 +52,7 @@ import org.springframework.web.bind.annotation.RequestMapping; @Controller @RequestMapping(path = OPERATIONS_URL) public class OperationsController { + private static final String HTTP_STATUS_OK = HttpStatus.OK.value() + ""; private static final Logger LOGGER = LoggerFactory.getLogger(OperationsController.class); @@ -80,7 +81,7 @@ public class OperationsController { final Output output = getOutput(apiServiceOperationInformation); final OutputRequest outputRequest = new OutputRequest(output); - if (output.getResponseCode().equals(HttpStatus.OK.toString())) { + if (output.getResponseCode().equals(HTTP_STATUS_OK)) { LOGGER.info("Sucessfully executed service request sending response: {}", outputRequest); return ResponseEntity.ok(outputRequest); } @@ -106,7 +107,7 @@ public class OperationsController { final Output output = getOutput(apiVnfOperationInformation); final OutputRequest outputRequest = new OutputRequest(output); - if (output.getResponseCode().equals(HttpStatus.OK.toString())) { + if (output.getResponseCode().equals(HTTP_STATUS_OK)) { LOGGER.info("Sucessfully executed request vnf sending response: {}", outputRequest); return ResponseEntity.ok(outputRequest); } diff --git a/plans/so/integration-etsi-testing/so-simulators/sdnc-simulator/src/main/java/org/onap/so/sdncsimulator/providers/ServiceOperationsCacheServiceProviderimpl.java b/plans/so/integration-etsi-testing/so-simulators/sdnc-simulator/src/main/java/org/onap/so/sdncsimulator/providers/ServiceOperationsCacheServiceProviderimpl.java index dae8b7f4..88db4c13 100644 --- a/plans/so/integration-etsi-testing/so-simulators/sdnc-simulator/src/main/java/org/onap/so/sdncsimulator/providers/ServiceOperationsCacheServiceProviderimpl.java +++ b/plans/so/integration-etsi-testing/so-simulators/sdnc-simulator/src/main/java/org/onap/so/sdncsimulator/providers/ServiceOperationsCacheServiceProviderimpl.java @@ -78,6 +78,8 @@ import org.springframework.stereotype.Service; public class ServiceOperationsCacheServiceProviderimpl extends AbstractCacheServiceProvider implements ServiceOperationsCacheServiceProvider { + private static final String HTTP_STATUS_BAD_REQUEST = Integer.toString(HttpStatus.BAD_REQUEST.value()); + private static final String HTTP_STATUS_OK = Integer.toString(HttpStatus.OK.value()); private static final String EMPTY_STRING = ""; private static final Logger LOGGER = LoggerFactory.getLogger(ServiceOperationsCacheServiceProviderimpl.class); @@ -114,7 +116,7 @@ public class ServiceOperationsCacheServiceProviderimpl extends AbstractCacheServ .instanceId(serviceInstanceId).objectPath(getObjectPath(serviceInstanceId))); } LOGGER.error("serviceInstanceId: {} already exists", serviceInstanceId); - return new Output().ackFinalIndicator(YES).responseCode(HttpStatus.BAD_REQUEST.toString()) + return new Output().ackFinalIndicator(YES).responseCode(HTTP_STATUS_BAD_REQUEST) .responseMessage("serviceInstanceId: " + serviceInstanceId + " already exists") .svcRequestId(svcRequestId); } @@ -122,7 +124,7 @@ public class ServiceOperationsCacheServiceProviderimpl extends AbstractCacheServ LOGGER.error( "Unable to add GenericResourceApiServiceOperationInformation in cache due to invalid input: {}... ", input); - return new Output().ackFinalIndicator(YES).responseCode(HttpStatus.BAD_REQUEST.toString()) + return new Output().ackFinalIndicator(YES).responseCode(HTTP_STATUS_BAD_REQUEST) .responseMessage("Service instance not found").svcRequestId(svcRequestId); } @@ -141,7 +143,7 @@ public class ServiceOperationsCacheServiceProviderimpl extends AbstractCacheServ LOGGER.info("Deleting GenericResourceApiServiceOperationInformation from cache using key: {}", serviceInstanceId); cache.evict(serviceInstanceId); - return new Output().ackFinalIndicator(YES).responseCode(HttpStatus.OK.toString()) + return new Output().ackFinalIndicator(YES).responseCode(HTTP_STATUS_OK) .responseMessage(EMPTY_STRING).svcRequestId(svcRequestId).serviceResponseInformation( new GenericResourceApiInstanceReference().instanceId(serviceInstanceId)); } @@ -151,7 +153,7 @@ public class ServiceOperationsCacheServiceProviderimpl extends AbstractCacheServ } LOGGER.error("Unable to remove service instance from cache due to invalid input: {}... ", input); - return new Output().ackFinalIndicator(YES).responseCode(HttpStatus.BAD_REQUEST.toString()) + return new Output().ackFinalIndicator(YES).responseCode(HTTP_STATUS_BAD_REQUEST) .responseMessage("Unable to remove service").svcRequestId(svcRequestId); } @@ -208,7 +210,7 @@ public class ServiceOperationsCacheServiceProviderimpl extends AbstractCacheServ .objectPath(getObjectPath(serviceInstanceId, vnfId))); } LOGGER.error("vnfId: {} already exists with SVC Action: {}", vnfId, svcAction); - return new Output().ackFinalIndicator(YES).responseCode(HttpStatus.BAD_REQUEST.toString()) + return new Output().ackFinalIndicator(YES).responseCode(HTTP_STATUS_BAD_REQUEST) .responseMessage("vnfId: " + vnfId + " already exists").svcRequestId(svcRequestId); } } @@ -220,7 +222,7 @@ public class ServiceOperationsCacheServiceProviderimpl extends AbstractCacheServ LOGGER.error( "Unable to add GenericResourceApiServiceOperationInformation in cache due to invalid input: {}... ", input); - return new Output().ackFinalIndicator(YES).responseCode(HttpStatus.BAD_REQUEST.toString()) + return new Output().ackFinalIndicator(YES).responseCode(HTTP_STATUS_BAD_REQUEST) .responseMessage("Unable to add vnf").svcRequestId(svcRequestId); } @@ -256,7 +258,7 @@ public class ServiceOperationsCacheServiceProviderimpl extends AbstractCacheServ return false; }); - return new Output().ackFinalIndicator(YES).responseCode(HttpStatus.OK.toString()) + return new Output().ackFinalIndicator(YES).responseCode(HTTP_STATUS_OK) .responseMessage(EMPTY_STRING).svcRequestId(svcRequestId) .serviceResponseInformation( new GenericResourceApiInstanceReference().instanceId(serviceInstanceId)) @@ -271,7 +273,7 @@ public class ServiceOperationsCacheServiceProviderimpl extends AbstractCacheServ } LOGGER.error("Unable to remove vnf instance from cache due to invalid input: {}... ", input); - return new Output().ackFinalIndicator(YES).responseCode(HttpStatus.BAD_REQUEST.toString()) + return new Output().ackFinalIndicator(YES).responseCode(HTTP_STATUS_BAD_REQUEST) .responseMessage("Unable to remove vnf").svcRequestId(svcRequestId); } @@ -406,7 +408,7 @@ public class ServiceOperationsCacheServiceProviderimpl extends AbstractCacheServ final GenericResourceApiServicestatusServiceStatus serviceStatus = getServiceStatus(getSvcAction(input.getSdncRequestHeader()), - getRequestAction(input.getRequestInformation()), HttpStatus.OK.toString()); + getRequestAction(input.getRequestInformation()), HTTP_STATUS_OK); return new GenericResourceApiServicemodelinfrastructureService().serviceData(apiServicedataServiceData) .serviceStatus(serviceStatus).serviceInstanceId(serviceInstanceId); diff --git a/plans/so/integration-etsi-testing/so-simulators/sdnc-simulator/src/test/java/org/onap/so/sdncsimulator/controller/OperationsControllerTest.java b/plans/so/integration-etsi-testing/so-simulators/sdnc-simulator/src/test/java/org/onap/so/sdncsimulator/controller/OperationsControllerTest.java index b498bd6e..888a251e 100644 --- a/plans/so/integration-etsi-testing/so-simulators/sdnc-simulator/src/test/java/org/onap/so/sdncsimulator/controller/OperationsControllerTest.java +++ b/plans/so/integration-etsi-testing/so-simulators/sdnc-simulator/src/test/java/org/onap/so/sdncsimulator/controller/OperationsControllerTest.java @@ -71,6 +71,9 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @Configuration public class OperationsControllerTest { + private static final String HTTP_STATUS_BAD_REQUEST = Integer.toString(HttpStatus.BAD_REQUEST.value()); + private static final String HTTP_STATUS_OK = Integer.toString(HttpStatus.OK.value()); + private static final String SVC_REQUEST_ID = "04fc9f50-87b8-430d-a232-ef24bd6c4150"; private static final String VNF_SVC_REQUEST_ID = "8fd2622b-01fc-424d-bfc8-f48bcd64e546"; @@ -112,7 +115,7 @@ public class OperationsControllerTest { final Output actualObject = actualOutputRequest.getOutput(); assertNotNull(actualObject); - assertEquals(HttpStatus.OK.toString(), actualObject.getResponseCode()); + assertEquals(HTTP_STATUS_OK, actualObject.getResponseCode()); assertEquals(Constants.YES, actualObject.getAckFinalIndicator()); assertEquals(SVC_REQUEST_ID, actualObject.getSvcRequestId()); assertNotNull(actualObject.getServiceResponseInformation()); @@ -157,7 +160,7 @@ public class OperationsControllerTest { final Output actualObject = actualOutputRequest.getOutput(); assertNotNull(actualObject); - assertEquals(HttpStatus.BAD_REQUEST.toString(), actualObject.getResponseCode()); + assertEquals(HTTP_STATUS_BAD_REQUEST, actualObject.getResponseCode()); assertEquals(SVC_REQUEST_ID, actualObject.getSvcRequestId()); assertEquals(Constants.YES, actualObject.getAckFinalIndicator()); @@ -183,7 +186,7 @@ public class OperationsControllerTest { final Output actualObject = actualOutputRequest.getOutput(); - assertEquals(HttpStatus.OK.toString(), actualObject.getResponseCode()); + assertEquals(HTTP_STATUS_OK, actualObject.getResponseCode()); assertEquals(Constants.YES, actualObject.getAckFinalIndicator()); assertEquals(VNF_SVC_REQUEST_ID, actualObject.getSvcRequestId()); assertNotNull(actualObject.getServiceResponseInformation()); @@ -242,7 +245,7 @@ public class OperationsControllerTest { final Output actualObject = badOutputRequest.getOutput(); assertNotNull(actualObject); - assertEquals(HttpStatus.BAD_REQUEST.toString(), actualObject.getResponseCode()); + assertEquals(HTTP_STATUS_BAD_REQUEST, actualObject.getResponseCode()); assertEquals(VNF_SVC_REQUEST_ID, actualObject.getSvcRequestId()); assertEquals(Constants.YES, actualObject.getAckFinalIndicator()); @@ -276,7 +279,7 @@ public class OperationsControllerTest { final Output actualObject = actualOutputRequest.getOutput(); - assertEquals(HttpStatus.OK.toString(), actualObject.getResponseCode()); + assertEquals(HTTP_STATUS_OK, actualObject.getResponseCode()); assertEquals(Constants.YES, actualObject.getAckFinalIndicator()); assertEquals(VNF_SVC_REQUEST_ID, actualObject.getSvcRequestId()); assertNotNull(actualObject.getServiceResponseInformation()); @@ -349,7 +352,7 @@ public class OperationsControllerTest { final Output actualObject = actualOutputRequest.getOutput(); - assertEquals(HttpStatus.OK.toString(), actualObject.getResponseCode()); + assertEquals(HTTP_STATUS_OK, actualObject.getResponseCode()); assertEquals(Constants.YES, actualObject.getAckFinalIndicator()); assertEquals(VNF_SVC_REQUEST_ID, actualObject.getSvcRequestId()); @@ -395,7 +398,7 @@ public class OperationsControllerTest { final Output actualObject = actualOutputRequest.getOutput(); - assertEquals(HttpStatus.OK.toString(), actualObject.getResponseCode()); + assertEquals(HTTP_STATUS_OK, actualObject.getResponseCode()); assertEquals(Constants.YES, actualObject.getAckFinalIndicator()); assertEquals(SVC_REQUEST_ID, actualObject.getSvcRequestId()); @@ -435,7 +438,7 @@ public class OperationsControllerTest { final Output actualObject = actualOutputRequest.getOutput(); - assertEquals(HttpStatus.OK.toString(), actualObject.getResponseCode()); + assertEquals(HTTP_STATUS_OK, actualObject.getResponseCode()); assertEquals(Constants.YES, actualObject.getAckFinalIndicator()); assertEquals(SVC_REQUEST_ID, actualObject.getSvcRequestId()); |