diff options
author | waqas.ikram <waqas.ikram@est.tech> | 2019-09-18 15:35:57 +0100 |
---|---|---|
committer | waqas.ikram <waqas.ikram@est.tech> | 2019-09-18 15:35:59 +0100 |
commit | 8282312472138e981081b2239576ac3e75bce76e (patch) | |
tree | ae12f1c477572c660610a63a087f041dafba1f7f /plans/so/integration-etsi-testing/so-simulators/sdnc-simulator/src/test | |
parent | b8cb5a9d750d2bfeec274d1f955b73997a56bd52 (diff) |
Adding delete endpoint for vnf
Change-Id: If982dcf160096329df2918a38afc41ee3f322085
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')
3 files changed, 108 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 b1ede082..a338283c 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 @@ -20,11 +20,13 @@ package org.onap.so.sdncsimulator.controller; 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.so.sdncsimulator.controller.TestUtils.getInvalidRequestInput; import static org.onap.so.sdncsimulator.controller.TestUtils.getRequestInput; 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; import java.util.Optional; import org.junit.After; @@ -306,6 +308,61 @@ public class OperationsControllerTest { } + @Test + public void test_postVnfOperationInformation_successfullyRemoveVnfFromExistingServiceInCache() 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()); + + final HttpEntity<?> httpAddVnfEntity = new HttpEntity<>(getVnfRequestInput(), getHttpHeaders()); + final ResponseEntity<OutputRequest> responseAddVnfEntity = + restTemplate.exchange(getVnfUrl(), HttpMethod.POST, httpAddVnfEntity, OutputRequest.class); + assertEquals(HttpStatus.OK, responseAddVnfEntity.getStatusCode()); + + Optional<GenericResourceApiServicemodelinfrastructureService> serviceOptional = + cacheServiceProvider.getGenericResourceApiServicemodelinfrastructureService(SERVICE_INSTANCE_ID); + assertTrue(serviceOptional.isPresent()); + + GenericResourceApiServicemodelinfrastructureService service = serviceOptional.get(); + assertNotNull(service.getServiceInstanceId()); + assertNotNull(service.getServiceData().getVnfs().getVnf()); + assertNotNull(service.getServiceData()); + assertNotNull(service.getServiceData().getVnfs()); + assertNotNull(service.getServiceData().getVnfs().getVnf()); + assertFalse(service.getServiceData().getVnfs().getVnf().isEmpty()); + + final HttpEntity<?> httpRemoveVnfEntity = + new HttpEntity<>(getVnfRequestWithRequestActionDeleteVnfInput(), getHttpHeaders()); + final ResponseEntity<OutputRequest> responseRemoveVnfEntity = + restTemplate.exchange(getVnfUrl(), HttpMethod.POST, httpRemoveVnfEntity, OutputRequest.class); + assertEquals(HttpStatus.OK, responseRemoveVnfEntity.getStatusCode()); + + final OutputRequest actualOutputRequest = responseRemoveVnfEntity.getBody(); + assertNotNull(actualOutputRequest); + assertNotNull(actualOutputRequest.getOutput()); + + final Output actualObject = actualOutputRequest.getOutput(); + + assertEquals(HttpStatus.OK.toString(), actualObject.getResponseCode()); + assertEquals(Constants.YES, actualObject.getAckFinalIndicator()); + assertEquals(VNF_SVC_REQUEST_ID, actualObject.getSvcRequestId()); + + serviceOptional = + cacheServiceProvider.getGenericResourceApiServicemodelinfrastructureService(SERVICE_INSTANCE_ID); + assertTrue(serviceOptional.isPresent()); + + service = serviceOptional.get(); + assertNotNull(service.getServiceInstanceId()); + assertNotNull(service.getServiceData().getVnfs().getVnf()); + assertNotNull(service.getServiceData()); + assertNotNull(service.getServiceData().getVnfs()); + assertNotNull(service.getServiceData().getVnfs().getVnf()); + assertTrue(service.getServiceData().getVnfs().getVnf().isEmpty()); + + + } 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 220ec7d3..b43ecf4c 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 @@ -45,7 +45,7 @@ public class TestUtils { public static String getVnfRequestInput() throws IOException { return getFileAsString(getFile("test-data/vnfInput.json").toPath()); } - + public static String getVnfRequestWithSvcActionActivateInput() throws IOException { return getFileAsString(getFile("test-data/activateVnfInput.json").toPath()); } @@ -54,6 +54,10 @@ public class TestUtils { return getFileAsString(getFile("test-data/InvalidInput.json").toPath()); } + public static String getVnfRequestWithRequestActionDeleteVnfInput() throws IOException { + return getFileAsString(getFile("test-data/deleteVnfInput.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/deleteVnfInput.json b/plans/so/integration-etsi-testing/so-simulators/sdnc-simulator/src/test/resources/test-data/deleteVnfInput.json new file mode 100644 index 00000000..dda16b5d --- /dev/null +++ b/plans/so/integration-etsi-testing/so-simulators/sdnc-simulator/src/test/resources/test-data/deleteVnfInput.json @@ -0,0 +1,46 @@ +{ + "input": { + "request-information": { + "request-action": "DeleteVnfInstance", + "source": "MSO", + "request-id": "1a545ea9-2a5e-4df9-9c73-529b1d0b2012" + }, + "sdnc-request-header": { + "svc-request-id": "8fd2622b-01fc-424d-bfc8-f48bcd64e546", + "svc-notification-url": "http://so-bpmn-infra.onap:8081/mso/WorkflowMessage/SDNCCallback/fd40ea09-3245-476a-b6ff-58cb042edb9d", + "svc-action": "UNASSIGN" + }, + "service-information": { + "onap-model-information": { + "model-name": "Sol004Zip4Service", + "model-version": "1.0", + "model-uuid": "99d59273-4450-4034-9141-027f0c1a807a", + "model-invariant-uuid": "51672777-9b8d-4e5e-b488-5f9092e03a82" + }, + "subscription-service-type": "vCPE", + "service-id": "ccece8fe-13da-456a-baf6-41b3a4a2bc2b", + "global-customer-id": "NordixDemoCustomer", + "service-instance-id": "ccece8fe-13da-456a-baf6-41b3a4a2bc2b" + }, + "vnf-information": { + "onap-model-information": { + "model-name": "Sol004Zip3VSP", + "model-version": "1.0", + "model-customization-uuid": "50a90cd7-a84e-4ee1-b5ba-bfa5a26f5e15", + "model-uuid": "84b9649a-4eb9-4967-9abe-e8702f55518b", + "model-invariant-uuid": "b0f14066-2b65-40d2-b5a4-c8f2116fb5fc" + }, + "vnf-id": "dfd02fb5-d7fb-4aac-b3c4-cd6b60058701", + "vnf-name": "EsyVnfInstantiationTest2", + "vnf-type": "Sol004Zip4Service/Sol004Zip3VSP 0" + }, + "vnf-request-input": { + "aic-cloud-region": "nordixcloud", + "cloud-owner": "CloudOwner", + "tenant": "693c7729b2364a26a3ca602e6f66187d", + "vnf-network-instance-group-ids": [], + "vnf-input-parameters": {}, + "vnf-name": "EsyVnfInstantiationTest2" + } + } +}
\ No newline at end of file |