From 07593362ee3550b94cdf734a14e22c9f848185e1 Mon Sep 17 00:00:00 2001 From: "waqas.ikram" Date: Mon, 23 Sep 2019 15:11:20 +0100 Subject: Adding service delete endpoint in sdnc simulator Change-Id: I7c849b32a7b920becd6b7f9622e5f5bbe01eebe0 Issue-ID: SO-2342 Signed-off-by: waqas.ikram --- .../controller/OperationsControllerTest.java | 40 +++++++++++++++++++++- .../so/sdncsimulator/controller/TestUtils.java | 4 +++ .../resources/test-data/deleteServiceInput.json | 28 +++++++++++++++ 3 files changed, 71 insertions(+), 1 deletion(-) create mode 100644 plans/so/integration-etsi-testing/so-simulators/sdnc-simulator/src/test/resources/test-data/deleteServiceInput.json (limited to 'plans/so/integration-etsi-testing/so-simulators/sdnc-simulator/src/test') 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 a338283c..3c17a376 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 @@ -25,6 +25,7 @@ import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import static org.onap.so.sdncsimulator.controller.TestUtils.getInvalidRequestInput; import static org.onap.so.sdncsimulator.controller.TestUtils.getRequestInput; +import static org.onap.so.sdncsimulator.controller.TestUtils.getServiceRequestWithRequestActionDeleteServiceInput; import static org.onap.so.sdncsimulator.controller.TestUtils.getVnfRequestInput; import static org.onap.so.sdncsimulator.controller.TestUtils.getVnfRequestWithRequestActionDeleteVnfInput; import static org.onap.so.sdncsimulator.controller.TestUtils.getVnfRequestWithSvcActionActivateInput; @@ -302,7 +303,7 @@ public class OperationsControllerTest { assertNotNull(vnf.getVnfId()); assertEquals(VNF_INSTANCE_ID, vnf.getVnfId()); assertNotNull(vnf.getVnfData()); - GenericResourceApiOperStatusData vnfLevelOperStatus = vnf.getVnfData().getVnfLevelOperStatus(); + final GenericResourceApiOperStatusData vnfLevelOperStatus = vnf.getVnfData().getVnfLevelOperStatus(); assertNotNull(vnfLevelOperStatus); assertEquals(GenericResourceApiLastRpcActionEnumeration.ACTIVATE, vnfLevelOperStatus.getLastRpcAction()); @@ -364,6 +365,43 @@ public class OperationsControllerTest { } + @Test + public void test_postServiceOperationInformation_withActionDeleteServiceInstance_successfullyRemoveServiceFromExistingServiceInCache() + throws Exception { + final HttpEntity httpEntity = new HttpEntity<>(getRequestInput(), getHttpHeaders()); + final ResponseEntity responseEntity = + restTemplate.exchange(getUrl(), HttpMethod.POST, httpEntity, OutputRequest.class); + + assertEquals(HttpStatus.OK, responseEntity.getStatusCode()); + Optional serviceOptional = + cacheServiceProvider.getGenericResourceApiServicemodelinfrastructureService(SERVICE_INSTANCE_ID); + assertTrue(serviceOptional.isPresent()); + + final GenericResourceApiServicemodelinfrastructureService service = serviceOptional.get(); + assertNotNull(service.getServiceInstanceId()); + + final HttpEntity httpRemoveServiceEntity = + new HttpEntity<>(getServiceRequestWithRequestActionDeleteServiceInput(), getHttpHeaders()); + final ResponseEntity responseRemoveServiceEntity = + restTemplate.exchange(getUrl(), HttpMethod.POST, httpRemoveServiceEntity, OutputRequest.class); + assertEquals(HttpStatus.OK, responseRemoveServiceEntity.getStatusCode()); + + final OutputRequest actualOutputRequest = responseRemoveServiceEntity.getBody(); + assertNotNull(actualOutputRequest); + assertNotNull(actualOutputRequest.getOutput()); + + final Output actualObject = actualOutputRequest.getOutput(); + + assertEquals(HttpStatus.OK.toString(), actualObject.getResponseCode()); + assertEquals(Constants.YES, actualObject.getAckFinalIndicator()); + assertEquals(SVC_REQUEST_ID, actualObject.getSvcRequestId()); + + serviceOptional = + cacheServiceProvider.getGenericResourceApiServicemodelinfrastructureService(SERVICE_INSTANCE_ID); + assertFalse(serviceOptional.isPresent()); + + } + private HttpHeaders getHttpHeaders() { return TestUtils.getHttpHeaders(userCredentials.getUsers().iterator().next().getUsername()); } diff --git a/plans/so/integration-etsi-testing/so-simulators/sdnc-simulator/src/test/java/org/onap/so/sdncsimulator/controller/TestUtils.java b/plans/so/integration-etsi-testing/so-simulators/sdnc-simulator/src/test/java/org/onap/so/sdncsimulator/controller/TestUtils.java index b43ecf4c..8e0e9b43 100644 --- a/plans/so/integration-etsi-testing/so-simulators/sdnc-simulator/src/test/java/org/onap/so/sdncsimulator/controller/TestUtils.java +++ b/plans/so/integration-etsi-testing/so-simulators/sdnc-simulator/src/test/java/org/onap/so/sdncsimulator/controller/TestUtils.java @@ -58,6 +58,10 @@ public class TestUtils { return getFileAsString(getFile("test-data/deleteVnfInput.json").toPath()); } + public static String getServiceRequestWithRequestActionDeleteServiceInput() throws IOException { + return getFileAsString(getFile("test-data/deleteServiceInput.json").toPath()); + } + public static String getFileAsString(final Path path) throws IOException { return new String(Files.readAllBytes(path)); } diff --git a/plans/so/integration-etsi-testing/so-simulators/sdnc-simulator/src/test/resources/test-data/deleteServiceInput.json b/plans/so/integration-etsi-testing/so-simulators/sdnc-simulator/src/test/resources/test-data/deleteServiceInput.json new file mode 100644 index 00000000..1040209f --- /dev/null +++ b/plans/so/integration-etsi-testing/so-simulators/sdnc-simulator/src/test/resources/test-data/deleteServiceInput.json @@ -0,0 +1,28 @@ +{ + "input": { + "request-information": { + "request-action": "DeleteServiceInstance", + "source": "MSO", + "request-id": "33ebd358-a189-4664-90f5-cf9e23658e0a" + }, + "sdnc-request-header": { + "svc-request-id": "04fc9f50-87b8-430d-a232-ef24bd6c4150", + "svc-action": "deactivate" + }, + "service-information": { + "onap-model-information": { + "model-name": "Sol004Zip3Service", + "model-version": "2.0", + "model-uuid": "c112a499-6148-488b-ba82-3f5938cf26d2", + "model-invariant-uuid": "e9acd081-9c89-4b4d-bcb3-e0e2b9715b2a" + }, + "subscription-service-type": "vCPE", + "service-id": "ccece8fe-13da-456a-baf6-41b3a4a2bc2b", + "global-customer-id": "NordixDemoCustomer", + "service-instance-id": "ccece8fe-13da-456a-baf6-41b3a4a2bc2b" + }, + "service-request-input": { + "service-instance-name": "ServiceTest_24_07_2019" + } + } +} -- cgit 1.2.3-korg