diff options
author | Marcus Williams <marcus.williams@intel.com> | 2019-04-09 23:04:21 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2019-04-09 23:04:21 +0000 |
commit | ed66a29ce8e0068740466e13fa6517791cce9aeb (patch) | |
tree | e407712a7106dd09262a0eda27b035412fbf3326 /adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test | |
parent | 1d9a4a6444f1a192ae69aa1f9c5df908c34ad164 (diff) | |
parent | 0a866176d0a9c221d699998131d498b78f0c7aed (diff) |
Merge "Add sending create request to VNFM"
Diffstat (limited to 'adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test')
5 files changed, 93 insertions, 86 deletions
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/HealthCheckTest.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/HealthCheckTest.java index c25d8257d8..07c471ec87 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/HealthCheckTest.java +++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/HealthCheckTest.java @@ -20,8 +20,6 @@ package org.onap.so.adapters.vnfmadapter.rest; -import static org.junit.Assert.assertEquals; -import java.net.URI; import org.junit.Test; import org.junit.runner.RunWith; import org.onap.so.adapters.vnfmadapter.VnfmAdapterApplication; @@ -33,6 +31,8 @@ import org.springframework.http.RequestEntity; import org.springframework.http.ResponseEntity; import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.junit4.SpringRunner; +import java.net.URI; +import static org.junit.Assert.assertEquals; @RunWith(SpringRunner.class) @SpringBootTest(classes = VnfmAdapterApplication.class, webEnvironment = WebEnvironment.RANDOM_PORT) diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/Sol003GrantControllerTest.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/Sol003GrantControllerTest.java index 21c6eff6b0..7e87e669e2 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/Sol003GrantControllerTest.java +++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/Sol003GrantControllerTest.java @@ -20,24 +20,14 @@ package org.onap.so.adapters.vnfmadapter.rest; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.doReturn; -import static org.onap.so.client.RestTemplateConfig.CONFIGURABLE_REST_TEMPLATE; -import java.util.Optional; +import com.google.gson.Gson; import org.hamcrest.BaseMatcher; import org.hamcrest.Description; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.hamcrest.MockitoHamcrest; -import org.onap.aai.domain.yang.EsrSystemInfo; -import org.onap.aai.domain.yang.EsrSystemInfoList; -import org.onap.aai.domain.yang.GenericVnf; -import org.onap.aai.domain.yang.Relationship; -import org.onap.aai.domain.yang.RelationshipData; -import org.onap.aai.domain.yang.RelationshipList; +import org.onap.aai.domain.yang.*; import org.onap.so.adapters.vnfmadapter.VnfmAdapterApplication; import org.onap.so.adapters.vnfmadapter.extclients.vnfm.grant.model.GrantRequest; import org.onap.so.adapters.vnfmadapter.extclients.vnfm.grant.model.GrantRequest.OperationEnum; @@ -59,7 +49,12 @@ import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.web.client.MockRestServiceServer; import org.springframework.web.client.RestTemplate; -import com.google.gson.Gson; +import java.util.Optional; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.doReturn; +import static org.onap.so.client.RestTemplateConfig.CONFIGURABLE_REST_TEMPLATE; @RunWith(SpringRunner.class) @SpringBootTest(classes = VnfmAdapterApplication.class, webEnvironment = WebEnvironment.RANDOM_PORT) 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 aa089e1348..363780dcc5 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 @@ -20,25 +20,7 @@ package org.onap.so.adapters.vnfmadapter.rest; -import static org.junit.Assert.assertEquals; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.doReturn; -import static org.mockito.Mockito.timeout; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyZeroInteractions; -import static org.onap.so.client.RestTemplateConfig.CONFIGURABLE_REST_TEMPLATE; -import static org.springframework.test.web.client.match.MockRestRequestMatchers.requestTo; -import static org.springframework.test.web.client.response.MockRestResponseCreators.withStatus; -import static org.springframework.test.web.client.response.MockRestResponseCreators.withSuccess; import com.google.gson.Gson; -import java.net.URI; -import java.net.URISyntaxException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Optional; -import javax.inject.Inject; import org.hamcrest.BaseMatcher; import org.hamcrest.Description; import org.junit.Before; @@ -54,13 +36,8 @@ import org.onap.so.adapters.vnfmadapter.extclients.aai.AaiHelper; import org.onap.so.adapters.vnfmadapter.extclients.aai.OamIpAddressSource; import org.onap.so.adapters.vnfmadapter.extclients.aai.OamIpAddressSource.OamIpAddressType; import org.onap.so.adapters.vnfmadapter.extclients.vim.model.AccessInfo; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.lcn.model.LcnVnfLcmOperationOccurrenceNotificationAffectedVnfcs; +import org.onap.so.adapters.vnfmadapter.extclients.vnfm.lcn.model.*; import org.onap.so.adapters.vnfmadapter.extclients.vnfm.lcn.model.LcnVnfLcmOperationOccurrenceNotificationAffectedVnfcs.ChangeTypeEnum; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.lcn.model.LcnVnfLcmOperationOccurrenceNotificationComputeResource; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.lcn.model.LcnVnfLcmOperationOccurrenceNotificationLinks; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.lcn.model.LcnVnfLcmOperationOccurrenceNotificationLinksVnfInstance; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.lcn.model.VnfIdentifierCreationNotification; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.lcn.model.VnfLcmOperationOccurrenceNotification; import org.onap.so.adapters.vnfmadapter.extclients.vnfm.lcn.model.VnfLcmOperationOccurrenceNotification.OperationEnum; import org.onap.so.adapters.vnfmadapter.extclients.vnfm.lcn.model.VnfLcmOperationOccurrenceNotification.OperationStateEnum; import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse201; @@ -82,6 +59,17 @@ import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.web.client.MockRestServiceServer; import org.springframework.web.client.RestTemplate; +import javax.inject.Inject; +import java.net.URI; +import java.net.URISyntaxException; +import java.util.*; +import static org.junit.Assert.assertEquals; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.*; +import static org.onap.so.client.RestTemplateConfig.CONFIGURABLE_REST_TEMPLATE; +import static org.springframework.test.web.client.match.MockRestRequestMatchers.requestTo; +import static org.springframework.test.web.client.response.MockRestResponseCreators.withStatus; +import static org.springframework.test.web.client.response.MockRestResponseCreators.withSuccess; @RunWith(SpringRunner.class) @SpringBootTest(classes = VnfmAdapterApplication.class, webEnvironment = WebEnvironment.RANDOM_PORT) 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 c69b483592..39572c73cd 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 @@ -20,21 +20,7 @@ package org.onap.so.adapters.vnfmadapter.rest; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.doReturn; -import static org.mockito.Mockito.verify; -import static org.onap.so.client.RestTemplateConfig.CONFIGURABLE_REST_TEMPLATE; -import static org.springframework.test.web.client.match.MockRestRequestMatchers.content; -import static org.springframework.test.web.client.match.MockRestRequestMatchers.requestTo; -import static org.springframework.test.web.client.response.MockRestResponseCreators.withBadRequest; -import static org.springframework.test.web.client.response.MockRestResponseCreators.withStatus; -import static org.springframework.test.web.client.response.MockRestResponseCreators.withSuccess; import com.google.gson.Gson; -import java.net.URI; -import java.util.Optional; import org.hamcrest.BaseMatcher; import org.hamcrest.Description; import org.junit.Before; @@ -42,28 +28,16 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.ArgumentCaptor; import org.mockito.hamcrest.MockitoHamcrest; -import org.onap.aai.domain.yang.EsrSystemInfo; -import org.onap.aai.domain.yang.EsrSystemInfoList; -import org.onap.aai.domain.yang.EsrVnfm; -import org.onap.aai.domain.yang.EsrVnfmList; -import org.onap.aai.domain.yang.GenericVnf; -import org.onap.aai.domain.yang.Relationship; -import org.onap.aai.domain.yang.RelationshipData; -import org.onap.aai.domain.yang.RelationshipList; +import org.onap.aai.domain.yang.*; import org.onap.so.adapters.vnfmadapter.VnfmAdapterApplication; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse200; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse2001; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse201; +import org.onap.so.adapters.vnfmadapter.extclients.SdcPackageProvider; +import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.*; import org.onap.so.adapters.vnfmadapter.rest.exceptions.VnfmNotFoundException; import org.onap.so.client.aai.AAIResourcesClient; import org.onap.so.client.aai.entities.uri.AAIResourceUri; import org.onap.vnfmadapter.v1.model.CreateVnfRequest; -import org.onap.vnfmadapter.v1.model.CreateVnfResponse; -import org.onap.vnfmadapter.v1.model.DeleteVnfResponse; -import org.onap.vnfmadapter.v1.model.OperationEnum; -import org.onap.vnfmadapter.v1.model.OperationStateEnum; -import org.onap.vnfmadapter.v1.model.QueryJobResponse; import org.onap.vnfmadapter.v1.model.Tenant; +import org.onap.vnfmadapter.v1.model.*; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.boot.test.context.SpringBootTest; @@ -82,6 +56,16 @@ import org.springframework.web.client.RestTemplate; import org.threeten.bp.LocalDateTime; import org.threeten.bp.OffsetDateTime; import org.threeten.bp.ZoneOffset; +import java.net.URI; +import java.util.Optional; +import static org.junit.Assert.*; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.verify; +import static org.onap.so.client.RestTemplateConfig.CONFIGURABLE_REST_TEMPLATE; +import static org.springframework.test.web.client.match.MockRestRequestMatchers.content; +import static org.springframework.test.web.client.match.MockRestRequestMatchers.requestTo; +import static org.springframework.test.web.client.response.MockRestResponseCreators.*; @RunWith(SpringRunner.class) @SpringBootTest(classes = VnfmAdapterApplication.class, webEnvironment = WebEnvironment.RANDOM_PORT) @@ -107,6 +91,9 @@ public class VnfmAdapterControllerTest { @MockBean AAIResourcesClient aaiResourcesClient; + @MockBean + SdcPackageProvider sdcPackageProvider; + @Autowired VnfmAdapterController controller; Gson gson = new Gson(); @@ -128,11 +115,16 @@ public class VnfmAdapterControllerTest { final String expectedsubscriptionRequest = "{\"filter\":{\"vnfInstanceSubscriptionFilter\":{\"vnfInstanceIds\":[\"vnfId\"]},\"notificationTypes\":[\"VnfLcmOperationOccurrenceNotification\"]},\"callbackUri\":\"https://so-vnfm-adapter.onap:30406/so/vnfm-adapter/v1/lcn/VnfLcmOperationOccurrenceNotification\",\"authentication\":{\"authType\":[\"BASIC\"],\"paramsBasic\":{\"userName\":\"vnfm\",\"password\":\"$2a$10$Fh9ffgPw2vnmsghsRD3ZauBL1aKXebigbq3BB1RPWtE62UDILsjke\"}}}"; final InlineResponse2001 subscriptionResponse = new InlineResponse2001(); + + final InlineResponse201 createResponse = createCreateResponse(); + mockRestServer.expect(requestTo("http://vnfm2:8080/vnf_instances")) + .andRespond(withSuccess(gson.toJson(createResponse), MediaType.APPLICATION_JSON)); + mockRestServer.expect(requestTo("http://vnfm2:8080/subscriptions")) .andExpect(content().json(expectedsubscriptionRequest)) .andRespond(withSuccess(gson.toJson(subscriptionResponse), MediaType.APPLICATION_JSON)); - mockRestServer.expect(requestTo("http://dummy.value/until/create/implememted/vnfId/instantiate")) + mockRestServer.expect(requestTo("http://vnfm2:8080/vnf_instances/vnfId/instantiate")) .andRespond(withStatus(HttpStatus.ACCEPTED).contentType(MediaType.APPLICATION_JSON) .location(new URI("http://vnfm2:8080/vnf_lcm_op_occs/123456"))); @@ -163,12 +155,20 @@ public class VnfmAdapterControllerTest { assertEquals("/network/generic-vnfs/generic-vnf/myTestVnfId", uriArgument.getValue().build().toString()); assertEquals("myTestVnfId", genericVnfArgument.getValue().getVnfId()); - assertEquals(1, genericVnfArgument.getValue().getRelationshipList().getRelationship().size()); - final Relationship createdRelationship = + assertEquals(2, genericVnfArgument.getValue().getRelationshipList().getRelationship().size()); + final Relationship vnfmRelationship = genericVnfArgument.getValue().getRelationshipList().getRelationship().get(0); - assertEquals("esr-vnfm", createdRelationship.getRelatedTo()); - assertEquals("tosca.relationships.DependsOn", createdRelationship.getRelationshipLabel()); - assertEquals("/aai/v15/external-system/esr-vnfm-list/esr-vnfm/vnfm2", createdRelationship.getRelatedLink()); + assertEquals("esr-vnfm", vnfmRelationship.getRelatedTo()); + assertEquals("tosca.relationships.DependsOn", vnfmRelationship.getRelationshipLabel()); + assertEquals("/aai/v15/external-system/esr-vnfm-list/esr-vnfm/vnfm2", vnfmRelationship.getRelatedLink()); + + final Relationship tenantRelationship = + genericVnfArgument.getValue().getRelationshipList().getRelationship().get(1); + assertEquals("tenant", tenantRelationship.getRelatedTo()); + assertEquals( + "/aai/v15/cloud-infrastructure/cloud-regions/cloud-region/myTestCloudOwner/myTestRegion/tenants/tenant/myTestTenantId", + tenantRelationship.getRelatedLink()); + // check the job status @@ -223,9 +223,13 @@ public class VnfmAdapterControllerTest { setUpVnfmsInMockAai(); setUpVimInMockAai(); + final InlineResponse201 createResponse = createCreateResponse(); + mockRestServer.expect(requestTo("http://vnfm2:8080/vnf_instances")) + .andRespond(withSuccess(gson.toJson(createResponse), MediaType.APPLICATION_JSON)); + mockRestServer.expect(requestTo("http://vnfm2:8080/subscriptions")).andRespond(withBadRequest()); - mockRestServer.expect(requestTo("http://dummy.value/until/create/implememted/vnfId/instantiate")) + mockRestServer.expect(requestTo("http://vnfm2:8080/vnf_instances/vnfId/instantiate")) .andRespond(withStatus(HttpStatus.ACCEPTED).contentType(MediaType.APPLICATION_JSON) .location(new URI("http://vnfm2:8080/vnf_lcm_op_occs/123456"))); @@ -469,6 +473,19 @@ public class VnfmAdapterControllerTest { + CLOUD_OWNER + "/" + REGION + "/esr-system-info-list"))); } + private InlineResponse201 createCreateResponse() { + final InlineResponse201 createResponse = new InlineResponse201(); + createResponse.setVnfdId("myTestVnfd"); + final InlineResponse201Links links = new InlineResponse201Links(); + final InlineResponse201LinksSelf self = new InlineResponse201LinksSelf(); + self.setHref("http://vnfm2:8080/vnf_instances/vnfId"); + links.setSelf(self); + createResponse.setLinks(links); + createResponse.setId("vnfId"); + return createResponse; + } + + private class AaiResourceUriMatcher extends BaseMatcher<AAIResourceUri> { final String uriAsString; diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/resources/application-test.yaml b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/resources/application-test.yaml index e69e90173d..3afc542a1b 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/resources/application-test.yaml +++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/resources/application-test.yaml @@ -14,20 +14,27 @@ spring: security: usercredentials: - - username: test - password: '$2a$12$Zi3AuYcZoZO/gBQyUtST2.F5N6HqcTtaNci2Et.ufsQhski56srIu' - role: BPEL-Client - - username: vnfm - password: '$2a$10$Fh9ffgPw2vnmsghsRD3ZauBL1aKXebigbq3BB1RPWtE62UDILsjke' - role: BPEL-Client - + - username: test + password: '$2a$12$Zi3AuYcZoZO/gBQyUtST2.F5N6HqcTtaNci2Et.ufsQhski56srIu' + role: BPEL-Client + - username: vnfm + password: '$2a$10$Fh9ffgPw2vnmsghsRD3ZauBL1aKXebigbq3BB1RPWtE62UDILsjke' + role: BPEL-Client + mso: key: 07a7159d3bf51a0e53be7a8f89699be7 - + aai: auth: 2A11B07DB6214A839394AA1EC5844695F5114FC407FF5422625FB00175A3DCB8A1FF745F22867EFA72D5369D599BBD88DA8BED4233CF5586 endpoint: https://aai.onap:8443 version: v15 - + +sdc: + username: sdcUser + password: sdcPassword + key: adadadadad + endpoint: http://sdc.onap/1234A + + vnfmadapter: - endpoint: https://so-vnfm-adapter.onap:30406
\ No newline at end of file + endpoint: https://so-vnfm-adapter.onap:30406 |