diff options
Diffstat (limited to 'adapters')
15 files changed, 112 insertions, 247 deletions
diff --git a/adapters/mso-catalog-db-adapter/pom.xml b/adapters/mso-catalog-db-adapter/pom.xml index a51aa66afa..9745935925 100644 --- a/adapters/mso-catalog-db-adapter/pom.xml +++ b/adapters/mso-catalog-db-adapter/pom.xml @@ -85,40 +85,6 @@ </plugins> <pluginManagement> <plugins> - <!--This plugin's configuration is used to store Eclipse m2e settings - only. It has no influence on the Maven build itself. --> - <plugin> - <groupId>org.eclipse.m2e</groupId> - <artifactId>lifecycle-mapping</artifactId> - <version>1.0.0</version> - <configuration> - <lifecycleMappingMetadata> - <pluginExecutions> - <pluginExecution> - <pluginExecutionFilter> - <groupId> - org.jvnet.jax-ws-commons - </groupId> - <artifactId> - jaxws-maven-plugin - </artifactId> - <versionRange> - [2.3,) - </versionRange> - <goals> - <goal>wsgen</goal> - </goals> - </pluginExecutionFilter> - <action> - <ignore> - </ignore> - </action> - </pluginExecution> - </pluginExecutions> - </lifecycleMappingMetadata> - </configuration> - </plugin> - <plugin> <groupId>org.jacoco</groupId> <artifactId>jacoco-maven-plugin</artifactId> diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/WebMvcConfig.java b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/WebMvcConfig.java index ff0f8dc432..cd3b2a377b 100644 --- a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/WebMvcConfig.java +++ b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/WebMvcConfig.java @@ -22,6 +22,7 @@ package org.onap.so.adapters.catalogdb; import org.onap.logging.filter.spring.LoggingInterceptor; +import org.onap.logging.filter.spring.StatusLoggingInterceptor; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; @@ -34,11 +35,18 @@ import org.springframework.web.servlet.handler.MappedInterceptor; public class WebMvcConfig extends WebMvcConfigurerAdapter { @Autowired - LoggingInterceptor loggingInterceptor; + private LoggingInterceptor loggingInterceptor; + + @Autowired + private StatusLoggingInterceptor statusLoggingInterceptor; @Bean public MappedInterceptor mappedLoggingInterceptor() { return new MappedInterceptor(new String[] {"/**"}, loggingInterceptor); } + @Bean + public MappedInterceptor mappedStatusLoggingInterceptor() { + return new MappedInterceptor(new String[] {"/**"}, statusLoggingInterceptor); + } } diff --git a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java index f82c7acd38..707a2a45af 100644 --- a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java +++ b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java @@ -22,6 +22,7 @@ package org.onap.so.db.catalog.client; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; @@ -733,4 +734,12 @@ public class CatalogDbClientTest extends CatalogDbAdapterBaseTest { assertNull(workflow); } + @Test + public void getCloudSites() { + List<CloudSite> cloudSites = client.getCloudSites(); + assertNotNull(cloudSites); + assertNotEquals(0, cloudSites.size()); + } + + } diff --git a/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/application/MSORequestDBApplication.java b/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/application/MSORequestDBApplication.java index e1dc4cab66..3a14b2ff84 100644 --- a/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/application/MSORequestDBApplication.java +++ b/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/application/MSORequestDBApplication.java @@ -41,7 +41,6 @@ import net.javacrumbs.shedlock.spring.ScheduledLockConfigurationBuilder; * @since Version 1.0 * */ - @SpringBootApplication(scanBasePackages = {"org.onap.so", "org.onap.logging.filter"}) @EnableScheduling @EnableMBeanExport(registration = RegistrationPolicy.IGNORE_EXISTING) diff --git a/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/application/WebMvcConfig.java b/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/application/WebMvcConfig.java index c0dfbe08ef..9135d31ac3 100644 --- a/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/application/WebMvcConfig.java +++ b/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/application/WebMvcConfig.java @@ -22,6 +22,7 @@ package org.onap.so.adapters.requestsdb.application; import org.onap.logging.filter.spring.LoggingInterceptor; +import org.onap.logging.filter.spring.StatusLoggingInterceptor; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; @@ -34,11 +35,18 @@ import org.springframework.web.servlet.handler.MappedInterceptor; public class WebMvcConfig extends WebMvcConfigurerAdapter { @Autowired - LoggingInterceptor loggingInterceptor; + private LoggingInterceptor loggingInterceptor; + + @Autowired + private StatusLoggingInterceptor statusLoggingInterceptor; @Bean public MappedInterceptor mappedLoggingInterceptor() { return new MappedInterceptor(new String[] {"/**"}, loggingInterceptor); } + @Bean + public MappedInterceptor mappedStatusLoggingInterceptor() { + return new MappedInterceptor(new String[] {"/**"}, statusLoggingInterceptor); + } } diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/aai/AaiHelper.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/aai/AaiHelper.java index 110bbabdb2..fc9efef947 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/aai/AaiHelper.java +++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/aai/AaiHelper.java @@ -31,14 +31,10 @@ 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.Vserver; import org.onap.so.adapters.vnfmadapter.extclients.vnfm.lcn.model.LcnVnfLcmOperationOccurrenceNotificationAffectedVnfcs; import org.onap.so.adapters.vnfmadapter.rest.exceptions.TenantNotFoundException; import org.onap.so.adapters.vnfmadapter.rest.exceptions.VnfmNotFoundException; -import org.onap.so.client.aai.AAIObjectType; -import org.onap.so.client.aai.AAIVersion; -import org.onap.so.client.aai.entities.uri.AAIUriFactory; import org.onap.vnfmadapter.v1.model.Tenant; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -61,38 +57,6 @@ public class AaiHelper { } /** - * Add a relationship to the given generic VNF to the given VNFM. - * - * @param vnf the generic VNF - * @param vnfmId the ID of the VNFM - */ - public void addRelationshipFromGenericVnfToVnfm(final GenericVnf vnf, final String vnfmId) { - if (vnf.getRelationshipList() == null) { - vnf.setRelationshipList(new RelationshipList()); - } - final RelationshipList vnfmRelationshiplist = vnf.getRelationshipList(); - vnfmRelationshiplist.getRelationship().add(createRelationshipToVnfm(vnfmId)); - - } - - private Relationship createRelationshipToVnfm(final String vnfmId) { - final Relationship relationship = new Relationship(); - relationship.setRelatedTo("esr-vnfm"); - relationship.setRelationshipLabel("tosca.relationships.DependsOn"); - relationship.setRelatedLink("/aai/" + AAIVersion.LATEST - + AAIUriFactory.createResourceUri(AAIObjectType.VNFM, vnfmId).build().toString()); - relationship.getRelationshipData().add(createRelationshipData("esr-vnfm.vnfm-id", vnfmId)); - return relationship; - } - - private RelationshipData createRelationshipData(final String key, final String value) { - final RelationshipData data = new RelationshipData(); - data.setRelationshipKey(key); - data.setRelationshipValue(value); - return data; - } - - /** * Get the VNFM assigned for use for the given generic VNF. * * @param vnf the generic VNF @@ -242,30 +206,6 @@ public class AaiHelper { return vserver; } - /** - * Add a relationship to the given vserver to the given VNF. - * - * @param vnf the vserver - * @param vnfmId the ID of the VNF - */ - public void addRelationshipFromVserverVnfToGenericVnf(final Vserver vserver, final String vnfId) { - if (vserver.getRelationshipList() == null) { - vserver.setRelationshipList(new RelationshipList()); - } - final RelationshipList vserverRelationshiplist = vserver.getRelationshipList(); - vserverRelationshiplist.getRelationship().add(createRelationshipToGenericVnf(vnfId)); - } - - private Relationship createRelationshipToGenericVnf(final String vnfId) { - final Relationship relationship = new Relationship(); - relationship.setRelatedTo("generic-vnf"); - relationship.setRelationshipLabel("tosca.relationships.HostedOn"); - relationship.setRelatedLink("/aai/" + AAIVersion.LATEST - + AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId).build().toString()); - relationship.getRelationshipData().add(createRelationshipData("generic-vnf.vnf-id", vnfId)); - return relationship; - } - public void setOamIpAddressSource(final String vnfId, final OamIpAddressSource oamIpAddressSource) { mapOfVnfIdToOamIpAddressHolder.put(vnfId, oamIpAddressSource); } @@ -274,32 +214,4 @@ public class AaiHelper { return mapOfVnfIdToOamIpAddressHolder.get(vnfId); } - /** - * Add a relationship to the given tenant to the given VNF. - * - * @param vnf the generic vnf - * @param tenant the Tenant - */ - - public void addRelationshipFromGenericVnfToTenant(final GenericVnf vnf, final Tenant tenant) { - if (vnf.getRelationshipList() == null) { - vnf.setRelationshipList(new RelationshipList()); - } - final RelationshipList vnfmRelationshiplist = vnf.getRelationshipList(); - vnfmRelationshiplist.getRelationship().add(createRelationshipToTenant(tenant)); - } - - private Relationship createRelationshipToTenant(final Tenant tenant) { - final Relationship relationship = new Relationship(); - relationship.setRelatedTo("tenant"); - relationship.setRelatedLink("/aai/" + AAIVersion.LATEST + AAIUriFactory.createResourceUri(AAIObjectType.TENANT, - tenant.getCloudOwner(), tenant.getRegionName(), tenant.getTenantId()).build().toString()); - relationship.getRelationshipData() - .add(createRelationshipData("cloud-region.cloud-owner", tenant.getCloudOwner())); - relationship.getRelationshipData() - .add(createRelationshipData("cloud-region.cloud-region-id", tenant.getRegionName())); - relationship.getRelationshipData().add(createRelationshipData("tenant.tenant-id", tenant.getTenantId())); - return relationship; - } - } diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/aai/AaiServiceProvider.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/aai/AaiServiceProvider.java index 7021c02511..d19190d88e 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/aai/AaiServiceProvider.java +++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/aai/AaiServiceProvider.java @@ -72,12 +72,22 @@ public interface AaiServiceProvider { EsrVnfm invokeGetVnfm(final String vnfmId); /** - * Invoke a PUT request for a generic vnf. + * Invoke a PATCH request for a generic vnf. * * @param vnf the generic vnf * @return */ - void invokePutGenericVnf(GenericVnf vnf); + void invokePatchGenericVnf(GenericVnf vnf); + + /** + * Invoke a PUT request for a relationship from a generic vnf to a VNFM. + * + * @param vnf the generic vnf + * @param vnfmId the ID of the VNFM + * @return + */ + void invokePutGenericVnfToVnfmRelationship(GenericVnf vnf, final String vnfmId); + /** * Invoke a PUT request for a vserver. @@ -92,6 +102,19 @@ public interface AaiServiceProvider { final Vserver vserver); /** + * Invoke a PUT request for a relationship from a vserver to a generic vnf. + * + * @param cloudOwner the cloud owner + * @param cloudRegion the cloud region the vserver is deployed on + * @param tenantId the ID of the tenant the vserver is deployed on + * @param vserver the vserver + * @param vnfId the ID of the generic vnf + * @return + */ + void invokePutVserverToVnfRelationship(final String cloudOwner, final String cloudRegion, final String tenantId, + final Vserver vserver, final String vnfId); + + /** * Invoke a DELETE request for a vserver. * * @param cloudOwner the cloud owner diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/aai/AaiServiceProviderImpl.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/aai/AaiServiceProviderImpl.java index 019a08af78..6dc6020834 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/aai/AaiServiceProviderImpl.java +++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/aai/AaiServiceProviderImpl.java @@ -98,12 +98,18 @@ public class AaiServiceProviderImpl implements AaiServiceProvider { } @Override - public void invokePutGenericVnf(final GenericVnf vnf) { + public void invokePatchGenericVnf(final GenericVnf vnf) { aaiClientProvider.getAaiClient() .update(AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnf.getVnfId()), vnf); } @Override + public void invokePutGenericVnfToVnfmRelationship(final GenericVnf vnf, final String vnfmId) { + aaiClientProvider.getAaiClient().connect(AAIUriFactory.createResourceUri(AAIObjectType.VNFM, vnfmId), + AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnf.getVnfId())); + } + + @Override public void invokePutVserver(final String cloudOwner, final String cloudRegion, final String tenant, final Vserver vserver) { aaiClientProvider.getAaiClient().create(AAIUriFactory.createResourceUri(AAIObjectType.VSERVER, cloudOwner, @@ -111,6 +117,16 @@ public class AaiServiceProviderImpl implements AaiServiceProvider { } @Override + public void invokePutVserverToVnfRelationship(final String cloudOwner, final String cloudRegion, + final String tenant, final Vserver vserver, final String vnfId) { + aaiClientProvider.getAaiClient() + .connect( + AAIUriFactory.createResourceUri(AAIObjectType.VSERVER, cloudOwner, cloudRegion, tenant, + vserver.getVserverId()), + AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId)); + } + + @Override public void invokeDeleteVserver(final String cloudOwner, final String cloudRegion, final String tenant, final String vserverId) { aaiClientProvider.getAaiClient().delete( diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmServiceProviderConfiguration.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmServiceProviderConfiguration.java index b621759b59..ae9316cfdf 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmServiceProviderConfiguration.java +++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmServiceProviderConfiguration.java @@ -42,6 +42,7 @@ import org.apache.http.impl.client.HttpClients; import org.apache.http.ssl.SSLContextBuilder; import org.onap.aai.domain.yang.EsrSystemInfo; import org.onap.aai.domain.yang.EsrVnfm; +import org.onap.logging.filter.spring.SpringClientPayloadFilter; import org.onap.so.adapters.vnfmadapter.extclients.vnfm.lcn.JSON; import org.onap.so.configuration.rest.BasicHttpHeadersProvider; import org.onap.so.logging.jaxrs.filter.SOSpringClientFilter; @@ -173,7 +174,8 @@ public class VnfmServiceProviderConfiguration { private void removeSpringClientFilter(final RestTemplate restTemplate) { ListIterator<ClientHttpRequestInterceptor> interceptorIterator = restTemplate.getInterceptors().listIterator(); while (interceptorIterator.hasNext()) { - if (interceptorIterator.next() instanceof SOSpringClientFilter) { + ClientHttpRequestInterceptor interceptor = interceptorIterator.next(); + if (interceptor instanceof SOSpringClientFilter || interceptor instanceof SpringClientPayloadFilter) { interceptorIterator.remove(); } } diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/lifecycle/LifecycleManager.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/lifecycle/LifecycleManager.java index 0aad91e5be..461c15a512 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/lifecycle/LifecycleManager.java +++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/lifecycle/LifecycleManager.java @@ -81,21 +81,25 @@ public class LifecycleManager { * @return the response to the request */ public CreateVnfResponse createVnf(final String vnfIdInAai, final CreateVnfRequest request) { - final GenericVnf genericVnf = getGenericVnfFromAai(vnfIdInAai); + GenericVnf genericVnf = getGenericVnfFromAai(vnfIdInAai); EsrVnfm vnfm = aaiHelper.getAssignedVnfm(genericVnf); checkIfVnfAlreadyExistsInVnfm(vnfm, genericVnf); if (vnfm == null) { vnfm = aaiHelper.selectVnfm(genericVnf); - aaiHelper.addRelationshipFromGenericVnfToVnfm(genericVnf, vnfm.getVnfmId()); + aaiServiceProvider.invokePutGenericVnfToVnfmRelationship(genericVnf, vnfm.getVnfmId()); } - aaiHelper.addRelationshipFromGenericVnfToTenant(genericVnf, request.getTenant()); final InlineResponse201 vnfmResponse = sendCreateRequestToVnfm(request, genericVnf, vnfIdInAai, vnfm); logger.info("Create response: {}", vnfmResponse); genericVnf.setSelflink(getSelfLink(vnfmResponse, vnfm)); - aaiServiceProvider.invokePutGenericVnf(genericVnf); + + GenericVnf genericVnfPatch = new GenericVnf(); + genericVnfPatch.setVnfId(genericVnf.getVnfId()); + genericVnfPatch.setSelflink(genericVnf.getSelflink()); + aaiServiceProvider.invokePatchGenericVnf(genericVnfPatch); + final String vnfIdInVnfm = vnfmResponse.getId(); final OamIpAddressSource oamIpAddressSource = extractOamIpAddressSource(request); diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/notificationhandling/NotificationHandler.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/notificationhandling/NotificationHandler.java index eb912c8775..7a6bbfe0d9 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/notificationhandling/NotificationHandler.java +++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/notificationhandling/NotificationHandler.java @@ -97,10 +97,12 @@ public class NotificationHandler implements Runnable { private void handleVnfInstantiateCompleted() { final GenericVnf genericVnf = aaiServiceProvider .invokeQueryGenericVnf(vnfInstance.getLinks().getSelf().getHref()).getGenericVnf().get(0); - setOamIpAddress(genericVnf, vnfInstance); - genericVnf.setOrchestrationStatus("Created"); - aaiServiceProvider.invokePutGenericVnf(genericVnf); + final GenericVnf genericVnfPatch = new GenericVnf(); + genericVnfPatch.setVnfId(genericVnf.getVnfId()); + setOamIpAddress(genericVnfPatch, vnfInstance); + genericVnfPatch.setOrchestrationStatus("Created"); + aaiServiceProvider.invokePatchGenericVnf(genericVnfPatch); addVservers(vnfLcmOperationOccurrenceNotification, genericVnf.getVnfId(), vnfInstance.getVimConnectionInfo()); @@ -162,9 +164,12 @@ public class NotificationHandler implements Runnable { jobManager.notificationProcessedForOperation(vnfLcmOperationOccurrenceNotification.getVnfLcmOpOccId(), deleteSuccessful); jobManager.vnfDeleted(vnfLcmOperationOccurrenceNotification.getVnfLcmOpOccId()); - genericVnf.setOrchestrationStatus("Assigned"); - genericVnf.setSelflink(""); - aaiServiceProvider.invokePutGenericVnf(genericVnf); + + final GenericVnf genericVnfPatch = new GenericVnf(); + genericVnfPatch.setVnfId(genericVnf.getVnfId()); + genericVnfPatch.setOrchestrationStatus("Assigned"); + genericVnfPatch.setSelflink(""); + aaiServiceProvider.invokePatchGenericVnf(genericVnfPatch); } } @@ -180,10 +185,11 @@ public class NotificationHandler implements Runnable { getVimConnectionInfo(vimConnectionIdToVimConnectionInfo, vnfc); if (ChangeTypeEnum.ADDED.equals(vnfc.getChangeType())) { final Vserver vserver = aaiHelper.createVserver(vnfc); - aaiHelper.addRelationshipFromVserverVnfToGenericVnf(vserver, vnfId); - aaiServiceProvider.invokePutVserver(getCloudOwner(vimConnectionInfo), getCloudRegion(vimConnectionInfo), getTenant(vimConnectionInfo), vserver); + + aaiServiceProvider.invokePutVserverToVnfRelationship(getCloudOwner(vimConnectionInfo), + getCloudRegion(vimConnectionInfo), getTenant(vimConnectionInfo), vserver, vnfId); } } } 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 89a2c102f4..f83e9c94d2 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 @@ -212,12 +212,16 @@ public class Sol003LcnControllerTest { final Vserver vserver = (Vserver) bodyArgument2.getAllValues().get(0); assertEquals("myVnfc1", vserver.getVserverId()); - final Relationship relationship = vserver.getRelationshipList().getRelationship().get(0); - assertEquals("generic-vnf", relationship.getRelatedTo()); - assertEquals("tosca.relationships.HostedOn", relationship.getRelationshipLabel()); - assertEquals("/aai/v15/network/generic-vnfs/generic-vnf/myTestVnfId", relationship.getRelatedLink()); - assertEquals("generic-vnf.vnf-id", relationship.getRelationshipData().get(0).getRelationshipKey()); - assertEquals("myTestVnfId", relationship.getRelationshipData().get(0).getRelationshipValue()); + + final ArgumentCaptor<AAIResourceUri> uriArgument1Connect = ArgumentCaptor.forClass(AAIResourceUri.class); + final ArgumentCaptor<AAIResourceUri> uriArgument2Connect = ArgumentCaptor.forClass(AAIResourceUri.class); + verify(aaiResourcesClient, timeout(1000)).connect(uriArgument1Connect.capture(), uriArgument2Connect.capture()); + assertEquals( + "/cloud-infrastructure/cloud-regions/cloud-region/" + CLOUD_OWNER + "/" + REGION + "/tenants/tenant/" + + TENANT_ID + "/vservers/vserver/myVnfc1", + uriArgument1Connect.getAllValues().get(0).build().toString()); + assertEquals("/network/generic-vnfs/generic-vnf/myTestVnfId", + uriArgument2Connect.getAllValues().get(0).build().toString()); } @Test 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 fe55907420..297f74433e 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 @@ -25,6 +25,7 @@ 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.timeout; 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; @@ -175,20 +176,14 @@ public class VnfmAdapterControllerTest { assertEquals("/network/generic-vnfs/generic-vnf/myTestVnfId", uriArgument.getValue().build().toString()); assertEquals("myTestVnfId", genericVnfArgument.getValue().getVnfId()); - assertEquals(2, genericVnfArgument.getValue().getRelationshipList().getRelationship().size()); - final Relationship vnfmRelationship = - genericVnfArgument.getValue().getRelationshipList().getRelationship().get(0); - 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()); + final ArgumentCaptor<AAIResourceUri> uriArgument1Connect = ArgumentCaptor.forClass(AAIResourceUri.class); + final ArgumentCaptor<AAIResourceUri> uriArgument2Connect = ArgumentCaptor.forClass(AAIResourceUri.class); + verify(aaiResourcesClient, timeout(1000)).connect(uriArgument1Connect.capture(), uriArgument2Connect.capture()); + assertEquals("/external-system/esr-vnfm-list/esr-vnfm/vnfm2", + uriArgument1Connect.getAllValues().get(0).build().toString()); + assertEquals("/network/generic-vnfs/generic-vnf/myTestVnfId", + uriArgument2Connect.getAllValues().get(0).build().toString()); // check the job status diff --git a/adapters/mso-workflow-message-adapter/src/test/java/org/onap/so/adapters/workflowmessage/BPRestCallbackTest.java b/adapters/mso-workflow-message-adapter/src/test/java/org/onap/so/adapters/workflowmessage/BPRestCallbackTest.java deleted file mode 100644 index 21917c3d2c..0000000000 --- a/adapters/mso-workflow-message-adapter/src/test/java/org/onap/so/adapters/workflowmessage/BPRestCallbackTest.java +++ /dev/null @@ -1,42 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2018 Huawei Technologies Co., Ltd. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.adapters.workflowmessage; - -import org.apache.http.entity.ContentType; -import org.junit.Test; -import org.mockito.Mock; - -import static junit.framework.Assert.assertFalse; - -public class BPRestCallbackTest { - - @Mock - ContentType contentType; - - @Test - public void testSendExceptionCase() { - - BPRestCallback test = new BPRestCallback(); - test.send("workflowMessageUrl/", "messageType", "correlator", contentType,"message"); - assertFalse(test.send("workflowMessageUrl/", "messageType", "correlator", contentType,"message")); - - } - } diff --git a/adapters/mso-workflow-message-adapter/src/test/java/org/onap/so/adapters/workflowmessage/WMAdapterRestTest.java b/adapters/mso-workflow-message-adapter/src/test/java/org/onap/so/adapters/workflowmessage/WMAdapterRestTest.java deleted file mode 100644 index 08728fa339..0000000000 --- a/adapters/mso-workflow-message-adapter/src/test/java/org/onap/so/adapters/workflowmessage/WMAdapterRestTest.java +++ /dev/null @@ -1,45 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2018 Huawei Technologies Co., Ltd. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - *l - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.adapters.workflowmessage; - -import org.junit.Assert; -import org.junit.Test; - -public class WMAdapterRestTest { - - @Test(expected = ClassFormatError.class) - public void testHealthCheckException() throws Exception { - - WMAdapterRest test = new WMAdapterRest(); - test.healthcheck("34388737-cdad-4d96-ae6f-39d08024b495"); - Assert.assertFalse(true); - - } - - @Test(expected = ClassFormatError.class) - public void testReceiveWorkflowMsgException() throws Exception { - WMAdapterRest test = new WMAdapterRest(); - test.receiveWorkflowMessage("contentTypeHeader", "messageType", "correlator", "content"); - Assert.assertFalse(true); - - } -} - |