diff options
author | Byung-Woo Jun <byung-woo.jun@est.tech> | 2019-08-01 17:47:33 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2019-08-01 17:47:33 +0000 |
commit | 15c7bc833ae91ed2590370dd001d5361149aef9a (patch) | |
tree | 90203b6dab62f4bf1bb906d300ebd9c5007e5fd2 /adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test | |
parent | 0bf3a7f44ca4f0101c972029c7254606793627ad (diff) | |
parent | c91aac4825b873442f0636ef9f4cb4f3c1a675ef (diff) |
Merge "Add oauth for calls from VNFM adapter to VNFM"
Diffstat (limited to 'adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test')
2 files changed, 56 insertions, 27 deletions
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/Sol003LcnControllerTest.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/Sol003LcnControllerTest.java index aeb7cd3540..89a2c102f4 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/Sol003LcnControllerTest.java +++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/Sol003LcnControllerTest.java @@ -46,6 +46,8 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.ArgumentCaptor; import org.mockito.hamcrest.MockitoHamcrest; +import org.onap.aai.domain.yang.EsrSystemInfoList; +import org.onap.aai.domain.yang.EsrVnfm; import org.onap.aai.domain.yang.GenericVnf; import org.onap.aai.domain.yang.GenericVnfs; import org.onap.aai.domain.yang.Relationship; @@ -169,6 +171,7 @@ public class Sol003LcnControllerTest { .andRespond(withSuccess(gson.toJson(vnfInstance), MediaType.APPLICATION_JSON)); final GenericVnf genericVnf = createGenericVnf("vnfmType1"); + addRelationshipFromGenericVnfToVnfm(genericVnf, "vnfm1"); final List<GenericVnf> listOfGenericVnfs = new ArrayList<>(); listOfGenericVnfs.add(genericVnf); final GenericVnfs genericVnfs = new GenericVnfs(); @@ -176,6 +179,12 @@ public class Sol003LcnControllerTest { doReturn(Optional.of(genericVnfs)).when(aaiResourcesClient).get(eq(GenericVnfs.class), MockitoHamcrest.argThat(new AaiResourceUriMatcher( "/network/generic-vnfs?selflink=http%3A%2F%2Fvnfm%3A8080%2Fvnfs%2FmyTestVnfIdOnVnfm"))); + EsrVnfm vnfm = new EsrVnfm(); + vnfm.setVnfmId("vnfm1"); + final EsrSystemInfoList esrSystemInfoList = new EsrSystemInfoList(); + vnfm.setEsrSystemInfoList(esrSystemInfoList); + doReturn(Optional.of(vnfm)).when(aaiResourcesClient).get(eq(EsrVnfm.class), MockitoHamcrest + .argThat(new AaiResourceUriMatcher("/external-system/esr-vnfm-list/esr-vnfm/vnfm1?depth=1"))); final ResponseEntity<Void> response = controller.lcnVnfLcmOperationOccurrenceNotificationPost(vnfLcmOperationOccurrenceNotification); @@ -226,6 +235,7 @@ public class Sol003LcnControllerTest { .andRespond(withStatus(HttpStatus.NO_CONTENT).contentType(MediaType.APPLICATION_JSON)); final GenericVnf genericVnf = createGenericVnf("vnfmType1"); + addRelationshipFromGenericVnfToVnfm(genericVnf, "vnfm1"); genericVnf.setSelflink("http://vnfm:8080/vnfs/myTestVnfIdOnVnfm"); final List<GenericVnf> listOfGenericVnfs = new ArrayList<>(); listOfGenericVnfs.add(genericVnf); @@ -236,6 +246,12 @@ public class Sol003LcnControllerTest { doReturn(Optional.of(genericVnfs)).when(aaiResourcesClient).get(eq(GenericVnfs.class), MockitoHamcrest.argThat(new AaiResourceUriMatcher( "/network/generic-vnfs?selflink=http%3A%2F%2Fvnfm%3A8080%2Fvnfs%2FmyTestVnfIdOnVnfm"))); + EsrVnfm vnfm = new EsrVnfm(); + vnfm.setVnfmId("vnfm1"); + final EsrSystemInfoList esrSystemInfoList = new EsrSystemInfoList(); + vnfm.setEsrSystemInfoList(esrSystemInfoList); + doReturn(Optional.of(vnfm)).when(aaiResourcesClient).get(eq(EsrVnfm.class), MockitoHamcrest + .argThat(new AaiResourceUriMatcher("/external-system/esr-vnfm-list/esr-vnfm/vnfm1?depth=1"))); final ResponseEntity<Void> response = controller.lcnVnfLcmOperationOccurrenceNotificationPost(vnfLcmOperationOccurrenceNotification); @@ -323,6 +339,22 @@ public class Sol003LcnControllerTest { return genericVnf; } + private void addRelationshipFromGenericVnfToVnfm(final GenericVnf genericVnf, final String vnfmId) { + final Relationship relationshipToVnfm = new Relationship(); + relationshipToVnfm.setRelatedLink("/aai/v15/external-system/esr-vnfm-list/esr-vnfm/" + vnfmId); + relationshipToVnfm.setRelatedTo("esr-vnfm"); + final RelationshipData relationshipData = new RelationshipData(); + relationshipData.setRelationshipKey("esr-vnfm.vnfm-id"); + relationshipData.setRelationshipValue(vnfmId); + relationshipToVnfm.getRelationshipData().add(relationshipData); + + if (genericVnf.getRelationshipList() == null) { + final RelationshipList relationshipList = new RelationshipList(); + genericVnf.setRelationshipList(relationshipList); + } + genericVnf.getRelationshipList().getRelationship().add(relationshipToVnfm); + } + private void addRelationshipFromGenericVnfToVserver(final GenericVnf genericVnf, final String vserverId) { final Relationship relationshipToVserver = new Relationship(); relationshipToVserver.setRelatedTo("vserver"); @@ -343,9 +375,11 @@ public class Sol003LcnControllerTest { relationshipData4.setRelationshipValue(TENANT_ID); relationshipToVserver.getRelationshipData().add(relationshipData4); - final RelationshipList relationshipList = new RelationshipList(); - relationshipList.getRelationship().add(relationshipToVserver); - genericVnf.setRelationshipList(relationshipList); + if (genericVnf.getRelationshipList() == null) { + final RelationshipList relationshipList = new RelationshipList(); + genericVnf.setRelationshipList(relationshipList); + } + genericVnf.getRelationshipList().getRelationship().add(relationshipToVserver); } private class AaiResourceUriMatcher extends BaseMatcher<AAIResourceUri> { diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/VnfmAdapterControllerTest.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/VnfmAdapterControllerTest.java index b48de30f88..b45a13362d 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/VnfmAdapterControllerTest.java +++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/VnfmAdapterControllerTest.java @@ -214,6 +214,8 @@ public class VnfmAdapterControllerTest { final GenericVnf genericVnf = setUpGenericVnfInMockAai("vnfmType1"); addSelfLinkToGenericVnf(genericVnf); + addRelationshipFromGenericVnfToVnfm(genericVnf, "vnfm1"); + setUpVnfmsInMockAai(); final InlineResponse201 reponse = new InlineResponse201(); mockRestServer.expect(requestTo(new URI("http://vnfm:8080/vnfs/myTestVnfIdOnVnfm"))) @@ -239,7 +241,7 @@ public class VnfmAdapterControllerTest { final CreateVnfRequest createVnfRequest = new CreateVnfRequest().name("myTestName").tenant(tenant); final GenericVnf genericVnf = setUpGenericVnfInMockAai("vnfmType2"); - addRelationshipFromGenericVnfToVnfm(genericVnf, "vnfm1"); + addRelationshipFromGenericVnfToVnfm(genericVnf, "vnfm2"); setUpVnfmsInMockAai(); setUpVimInMockAai(); @@ -279,24 +281,25 @@ public class VnfmAdapterControllerTest { public void deleteVnf_ValidRequest_Returns202AndJobId() throws Exception { final TestRestTemplate restTemplate = new TestRestTemplate("test", "test"); - final GenericVnf genericVnf = setUpGenericVnfInMockAai("vnfmType"); + final GenericVnf genericVnf = setUpGenericVnfInMockAai("vnfmType1"); addSelfLinkToGenericVnf(genericVnf); - addRelationshipFromGenericVnfToVnfm(genericVnf, "vnfm"); + addRelationshipFromGenericVnfToVnfm(genericVnf, "vnfm1"); + setUpVnfmsInMockAai(); mockRestServer.expect(requestTo("http://vnfm:8080/vnfs/myTestVnfIdOnVnfm/terminate")) .andRespond(withStatus(HttpStatus.ACCEPTED).contentType(MediaType.APPLICATION_JSON) - .location(new URI("http://vnfm2:8080/vnf_lcm_op_occs/1234567"))); + .location(new URI("http://vnfm1:8080/vnf_lcm_op_occs/1234567"))); final InlineResponse200 firstOperationQueryResponse = createOperationQueryResponse( org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse200.OperationEnum.TERMINATE, org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse200.OperationStateEnum.PROCESSING); - mockRestServer.expect(requestTo("http://vnfm:8080/vnf_lcm_op_occs/1234567")) + mockRestServer.expect(requestTo("http://vnfm1:8080/vnf_lcm_op_occs/1234567")) .andRespond(withSuccess(gson.toJson(firstOperationQueryResponse), MediaType.APPLICATION_JSON)); final InlineResponse200 secondOperationQueryReponse = createOperationQueryResponse( org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse200.OperationEnum.TERMINATE, org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse200.OperationStateEnum.COMPLETED); - mockRestServer.expect(requestTo("http://vnfm:8080/vnf_lcm_op_occs/1234567")) + mockRestServer.expect(requestTo("http://vnfm1:8080/vnf_lcm_op_occs/1234567")) .andRespond(withSuccess(gson.toJson(secondOperationQueryReponse), MediaType.APPLICATION_JSON)); final RequestEntity<Void> request = RequestEntity @@ -308,16 +311,6 @@ public class VnfmAdapterControllerTest { assertEquals(202, deleteVnfResponse.getStatusCode().value()); assertNotNull(deleteVnfResponse.getBody().getJobId()); - final EsrSystemInfo esrSystemInfo = new EsrSystemInfo(); - esrSystemInfo.setServiceUrl("http://vnfm:8080"); - esrSystemInfo.setType("vnfmType"); - esrSystemInfo.setSystemType("VNFM"); - final EsrSystemInfoList esrSystemInfoList = new EsrSystemInfoList(); - esrSystemInfoList.getEsrSystemInfo().add(esrSystemInfo); - - doReturn(Optional.of(esrSystemInfoList)).when(aaiResourcesClient).get(eq(EsrSystemInfoList.class), - MockitoHamcrest.argThat(new AaiResourceUriMatcher("/external-system/esr-vnfm-list/esr-vnfm/..."))); - final ResponseEntity<QueryJobResponse> firstJobQueryResponse = controller.jobQuery(deleteVnfResponse.getBody().getJobId(), "", "so", "1213"); assertEquals(OperationEnum.TERMINATE, firstJobQueryResponse.getBody().getOperation()); @@ -367,9 +360,10 @@ public class VnfmAdapterControllerTest { public void deleteVnf_ErrorStatusCodeFromVnfm_Returns500() throws Exception { final TestRestTemplate restTemplate = new TestRestTemplate("test", "test"); - final GenericVnf genericVnf = setUpGenericVnfInMockAai("vnfmType"); + final GenericVnf genericVnf = setUpGenericVnfInMockAai("vnfmType1"); addSelfLinkToGenericVnf(genericVnf); - addRelationshipFromGenericVnfToVnfm(genericVnf, "vnfm"); + addRelationshipFromGenericVnfToVnfm(genericVnf, "vnfm1"); + setUpVnfmsInMockAai(); mockRestServer.expect(requestTo("http://vnfm:8080/vnfs/myTestVnfIdOnVnfm/terminate")) .andRespond(withStatus(HttpStatus.BAD_REQUEST).contentType(MediaType.APPLICATION_JSON)); @@ -419,12 +413,7 @@ public class VnfmAdapterControllerTest { private void addRelationshipFromGenericVnfToVnfm(final GenericVnf genericVnf, final String vnfmId) { final Relationship relationshipToVnfm = new Relationship(); - relationshipToVnfm.setRelatedLink( - "/aai/v15/external-system/esr-vnfm-li// final InlineResponse201 vnfInstance = new InlineResponse201();\n" - + "// vnfInstance.setInstantiationState(InstantiationStateEnum.NOT_INSTANTIATED);\n" - + "// mockRestServer.expect(requestTo(\"http://dummy.value/until/create/implememted/vnfId\"))\n" - + "// .andRespond(withSuccess(gson.toJson(vnfInstance), MediaType.APPLICATION_JSON));st/esr-vnfm/" - + vnfmId); + relationshipToVnfm.setRelatedLink("/aai/v15/external-system/esr-vnfm-list/esr-vnfm/" + vnfmId); relationshipToVnfm.setRelatedTo("esr-vnfm"); final RelationshipData relationshipData = new RelationshipData(); relationshipData.setRelationshipKey("esr-vnfm.vnfm-id"); @@ -465,6 +454,12 @@ public class VnfmAdapterControllerTest { esrVnfmList.getEsrVnfm().add(esrVnfm1); esrVnfmList.getEsrVnfm().add(esrVnfm2); + doReturn(Optional.of(esrVnfm1)).when(aaiResourcesClient).get(eq(EsrVnfm.class), MockitoHamcrest + .argThat(new AaiResourceUriMatcher("/external-system/esr-vnfm-list/esr-vnfm/vnfm1?depth=1"))); + + doReturn(Optional.of(esrVnfm2)).when(aaiResourcesClient).get(eq(EsrVnfm.class), MockitoHamcrest + .argThat(new AaiResourceUriMatcher("/external-system/esr-vnfm-list/esr-vnfm/vnfm2?depth=1"))); + doReturn(Optional.of(esrVnfmList)).when(aaiResourcesClient).get(eq(EsrVnfmList.class), MockitoHamcrest.argThat(new AaiResourceUriMatcher("/external-system/esr-vnfm-list"))); |