diff options
author | waqas.ikram <waqas.ikram@est.tech> | 2019-09-25 12:27:06 +0100 |
---|---|---|
committer | waqas.ikram <waqas.ikram@est.tech> | 2019-09-25 12:27:08 +0100 |
commit | a1f84a15cf98925a334062bfd912c9097c1b5be5 (patch) | |
tree | bf1e60edf10e9638fb3edcf9c4ad45da2cb8b7fb /plans/so/integration-etsi-testing/so-simulators/sdnc-simulator/src/test | |
parent | 2fd2236b7db11e5ff8592ca982557546af4b3fad (diff) |
Fixing service delete in sdnc simulator
Change-Id: I76a52aaa102e08b27d20e1bc908f145b4256595e
Issue-ID: SO-2342
Signed-off-by: waqas.ikram <waqas.ikram@est.tech>
Diffstat (limited to 'plans/so/integration-etsi-testing/so-simulators/sdnc-simulator/src/test')
4 files changed, 81 insertions, 1 deletions
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 3c17a376..b498bd6e 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 @@ -23,8 +23,11 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; +import static org.onap.sdnc.northbound.client.model.GenericResourceApiRpcActionEnumeration.ASSIGN; +import static org.onap.sdnc.northbound.client.model.GenericResourceApiRpcActionEnumeration.DEACTIVATE; 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.getServiceRequestWithRequestActionDeleteServiceAndSvcActionDeactivateInput; 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; @@ -402,6 +405,49 @@ public class OperationsControllerTest { } + @Test + public void test_postServiceOperationInformation_withActionDeleteServiceInstanceAndSvcActionDeactivate_successfullyUpdateExistingServiceInCache() + throws Exception { + + final HttpEntity<?> httpEntity = new HttpEntity<>(getRequestInput(), getHttpHeaders()); + final ResponseEntity<OutputRequest> responseEntity = + restTemplate.exchange(getUrl(), HttpMethod.POST, httpEntity, OutputRequest.class); + + assertEquals(HttpStatus.OK, responseEntity.getStatusCode()); + Optional<GenericResourceApiServicemodelinfrastructureService> serviceOptional = + cacheServiceProvider.getGenericResourceApiServicemodelinfrastructureService(SERVICE_INSTANCE_ID); + assertTrue(serviceOptional.isPresent()); + + GenericResourceApiServicemodelinfrastructureService service = serviceOptional.get(); + assertNotNull(service.getServiceInstanceId()); + assertNotNull(service.getServiceStatus()); + assertEquals(ASSIGN, service.getServiceStatus().getRpcAction()); + + final HttpEntity<?> entity = new HttpEntity<>( + getServiceRequestWithRequestActionDeleteServiceAndSvcActionDeactivateInput(), getHttpHeaders()); + final ResponseEntity<OutputRequest> deactivateResponseEntity = + restTemplate.exchange(getUrl(), HttpMethod.POST, entity, OutputRequest.class); + assertEquals(HttpStatus.OK, deactivateResponseEntity.getStatusCode()); + + final OutputRequest actualOutputRequest = deactivateResponseEntity.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); + assertTrue(serviceOptional.isPresent()); + service = serviceOptional.get(); + assertNotNull(service.getServiceStatus()); + assertEquals(DEACTIVATE, service.getServiceStatus().getRpcAction()); + + } + 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 8e0e9b43..52901b27 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 @@ -62,6 +62,12 @@ public class TestUtils { return getFileAsString(getFile("test-data/deleteServiceInput.json").toPath()); } + public static String getServiceRequestWithRequestActionDeleteServiceAndSvcActionDeactivateInput() + throws IOException { + return getFileAsString(getFile("test-data/deactivateServiceInput.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/deactivateServiceInput.json b/plans/so/integration-etsi-testing/so-simulators/sdnc-simulator/src/test/resources/test-data/deactivateServiceInput.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/deactivateServiceInput.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" + } + } +} 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 index 1040209f..71a51b84 100644 --- 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 @@ -7,7 +7,7 @@ }, "sdnc-request-header": { "svc-request-id": "04fc9f50-87b8-430d-a232-ef24bd6c4150", - "svc-action": "deactivate" + "svc-action": "delete" }, "service-information": { "onap-model-information": { |