diff options
Diffstat (limited to 'bpmn/MSOCommonBPMN')
13 files changed, 205 insertions, 504 deletions
diff --git a/bpmn/MSOCommonBPMN/pom.xml b/bpmn/MSOCommonBPMN/pom.xml index c817874fb6..5d9c1a3acd 100644 --- a/bpmn/MSOCommonBPMN/pom.xml +++ b/bpmn/MSOCommonBPMN/pom.xml @@ -1,5 +1,6 @@ <?xml version="1.0"?> -<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" +<project + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <modelVersion>4.0.0</modelVersion> <parent> @@ -21,18 +22,23 @@ <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> - <executions> - <execution> - <id>test-compile</id> - <phase>compile</phase> - <goals> - <goal>testCompile</goal> - </goals> - <configuration> - <skip>false</skip> - </configuration> - </execution> - </executions> + <version>3.8.0</version> + <configuration> + <compilerId>groovy-eclipse-compiler</compilerId> + </configuration> + + <dependencies> + <dependency> + <groupId>org.codehaus.groovy</groupId> + <artifactId>groovy-eclipse-compiler</artifactId> + <version>3.6.0-03</version> + </dependency> + <dependency> + <groupId>org.codehaus.groovy</groupId> + <artifactId>groovy-eclipse-batch</artifactId> + <version>2.4.19-01</version> + </dependency> + </dependencies> </plugin> <plugin> @@ -60,64 +66,6 @@ </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-eclipse-plugin</artifactId> - <version>2.8</version> - <configuration> - <additionalProjectnatures> - <projectnature>org.eclipse.jdt.groovy.core.groovyNature</projectnature> - </additionalProjectnatures> - <sourceIncludes> - <sourceInclude>**/*.groovy</sourceInclude> - </sourceIncludes> - </configuration> - </plugin> - <plugin> - <artifactId>maven-antrun-plugin</artifactId> - <executions> - <execution> - <id>compile</id> - <phase>compile</phase> - <configuration> - <tasks> - <mkdir dir="${basedir}/src/main/groovy" /> - <taskdef name="groovyc" classname="org.codehaus.groovy.ant.Groovyc"> - <classpath refid="maven.compile.classpath" /> - </taskdef> - <mkdir dir="${project.build.outputDirectory}" /> - <groovyc destdir="${project.build.outputDirectory}" srcdir="${basedir}/src/main/groovy/" - listfiles="true"> - <classpath refid="maven.compile.classpath" /> - </groovyc> - </tasks> - </configuration> - <goals> - <goal>run</goal> - </goals> - </execution> - <execution> - <id>test-compile</id> - <phase>test-compile</phase> - <configuration> - <tasks> - <mkdir dir="${basedir}/src/test/groovy" /> - <taskdef name="groovyc" classname="org.codehaus.groovy.ant.Groovyc"> - <classpath refid="maven.test.classpath" /> - </taskdef> - <mkdir dir="${project.build.testOutputDirectory}" /> - <groovyc destdir="${project.build.testOutputDirectory}" srcdir="${basedir}/src/test/groovy/" - listfiles="true"> - <classpath refid="maven.test.classpath" /> - </groovyc> - </tasks> - </configuration> - <goals> - <goal>run</goal> - </goals> - </execution> - </executions> - </plugin> - <plugin> - <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <executions> <execution> @@ -161,8 +109,8 @@ </plugins> <pluginManagement> <plugins> - <!--This plugin's configuration is used to store Eclipse m2e settings - only. It has no influence on the Maven build itself. --> + <!--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> @@ -173,14 +121,14 @@ <pluginExecution> <pluginExecutionFilter> <groupId> - org.apache.maven.plugins - </groupId> + org.apache.maven.plugins + </groupId> <artifactId> - maven-antrun-plugin - </artifactId> + maven-antrun-plugin + </artifactId> <versionRange> - [1.3,) - </versionRange> + [1.3,) + </versionRange> <goals> <goal>run</goal> </goals> diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CompleteMsoProcess.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CompleteMsoProcess.groovy index 48a8e60095..a86e1de772 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CompleteMsoProcess.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CompleteMsoProcess.groovy @@ -89,7 +89,7 @@ public class CompleteMsoProcess extends AbstractServiceTaskProcessor { } infraRequest.setLastModifiedBy("BPMN") infraRequest.setStatusMessage(statusMessage) - infraRequest.setRequestStatus("COMPLETED") + infraRequest.setRequestStatus("COMPLETE") infraRequest.setProgress(100) if(utils.nodeExists(xml, "vnfId")){ @@ -104,7 +104,8 @@ public class CompleteMsoProcess extends AbstractServiceTaskProcessor { infraRequest.setVfModuleId(utils.getNodeText(xml, "vfModuleId")) }else if(utils.nodeExists(xml, "volumeGroupId")){ infraRequest.setVolumeGroupId(utils.getNodeText(xml, "volumeGroupId")) - + }else if(utils.nodeExists(xml, "pnfName")){ + infraRequest.setPnfName(utils.getNodeText(xml, "pnfName")) } dbClient.updateInfraActiveRequests(infraRequest, UrnPropertiesReader.getVariable("mso.adapters.requestDb.auth"), UrnPropertiesReader.getVariable("mso.adapters.requestDb.endpoint")) diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CreateAAIVfModule.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CreateAAIVfModule.groovy index b43a153acb..c0124cfd50 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CreateAAIVfModule.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CreateAAIVfModule.groovy @@ -22,10 +22,10 @@ package org.onap.so.bpmn.common.scripts -import org.onap.so.logger.LoggingAnchor import org.apache.commons.lang.StringUtils import org.camunda.bpm.engine.delegate.DelegateExecution import org.onap.aai.domain.yang.GenericVnf +import org.onap.aai.domain.yang.GenericVnfs import org.onap.so.bpmn.core.RollbackData import org.onap.so.client.aai.AAIObjectPlurals import org.onap.so.client.aai.AAIObjectType @@ -34,6 +34,7 @@ import org.onap.so.client.aai.entities.uri.AAIUriFactory import org.onap.so.client.graphinventory.entities.uri.Depth import org.onap.so.db.catalog.beans.OrchestrationStatus import org.onap.logging.filter.base.ErrorCode +import org.onap.so.logger.LoggingAnchor import org.onap.so.logger.MessageEnum import org.slf4j.Logger import org.slf4j.LoggerFactory @@ -151,15 +152,13 @@ public class CreateAAIVfModule extends AbstractServiceTaskProcessor{ AAIResourceUri uri def vnfId = execution.getVariable("CAAIVfMod_vnfId") def vnfName = execution.getVariable("CAAIVfMod_vnfName") + Optional<GenericVnf> genericVnfOp if (vnfId == null || vnfId.isEmpty()) { - uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.GENERIC_VNF) - uri.queryParam("vnf-name", vnfName) + genericVnfOp = getAAIClient().getFirst(GenericVnfs.class, GenericVnf.class, AAIUriFactory.createResourceUri(AAIObjectPlurals.GENERIC_VNF).queryParam("vnf-name", vnfName).depth(Depth.ONE)) } else { - uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId) + genericVnfOp = getAAIClient().get(GenericVnf.class, AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId)) } - uri.depth(Depth.ONE) try { - Optional<GenericVnf> genericVnfOp = getAAIClient().get(GenericVnf.class, uri) if(genericVnfOp.isPresent()){ execution.setVariable("CAAIVfMod_queryGenericVnfResponseCode", 200) execution.setVariable("CAAIVfMod_queryGenericVnfResponse", genericVnfOp.get()) diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/modelinfo/ModelInfoServiceInstance.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/modelinfo/ModelInfoServiceInstance.java index bc330eeafd..b554d7a9ba 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/modelinfo/ModelInfoServiceInstance.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/modelinfo/ModelInfoServiceInstance.java @@ -35,6 +35,8 @@ public class ModelInfoServiceInstance extends ModelInfoMetadata implements Seria private String serviceType; @JsonProperty("service-role") private String serviceRole; + @JsonProperty("service-function") + private String serviceFunction; @JsonProperty("environment-context") private String environmentContext; @JsonProperty("workload-context") @@ -77,6 +79,14 @@ public class ModelInfoServiceInstance extends ModelInfoMetadata implements Seria this.serviceRole = serviceRole; } + public String getServiceFunction() { + return serviceFunction; + } + + public void setServiceFunction(String serviceFunction) { + this.serviceFunction = serviceFunction; + } + public String getEnvironmentContext() { return environmentContext; } diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtils.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtils.java index e004e10cf0..85f5f1f728 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtils.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtils.java @@ -52,6 +52,7 @@ import org.onap.so.client.aai.AAIObjectPlurals; import org.onap.so.client.aai.AAIObjectType; import org.onap.so.client.aai.AAIResourcesClient; import org.onap.so.client.aai.entities.AAIResultWrapper; +import org.onap.so.client.aai.entities.uri.AAIPluralResourceUri; import org.onap.so.client.aai.entities.uri.AAIResourceUri; import org.onap.so.client.aai.entities.uri.AAIUriFactory; import org.onap.so.client.graphinventory.entities.uri.Depth; @@ -314,68 +315,24 @@ public class BBInputSetupUtils { .depth(Depth.TWO)).orElse(null); } - protected org.onap.aai.domain.yang.ServiceInstances getAAIServiceInstancesByName(String serviceInstanceName, - Customer customer) { - - return injectionHelper.getAaiClient() - .get(org.onap.aai.domain.yang.ServiceInstances.class, - AAIUriFactory - .createResourceUri(AAIObjectPlurals.SERVICE_INSTANCE, customer.getGlobalCustomerId(), - customer.getServiceSubscription().getServiceType()) - .queryParam("service-instance-name", serviceInstanceName).depth(Depth.TWO)) - .orElseGet(() -> { - logger.debug("No Service Instance matched by name"); - return null; - }); - } - public org.onap.aai.domain.yang.ServiceInstance getAAIServiceInstanceByName(String serviceInstanceName, Customer customer) throws Exception { - org.onap.aai.domain.yang.ServiceInstance aaiServiceInstance = null; - org.onap.aai.domain.yang.ServiceInstances aaiServiceInstances = null; - aaiServiceInstances = getAAIServiceInstancesByName(serviceInstanceName, customer); - - if (aaiServiceInstances == null) { - return null; - } else if (aaiServiceInstances.getServiceInstance().size() > 1) { - throw new Exception("Multiple Service Instances Returned"); - } else { - aaiServiceInstance = aaiServiceInstances.getServiceInstance().get(0); - } - return aaiServiceInstance; - } - - protected ServiceInstances getAAIServiceInstancesByName(String globalCustomerId, String serviceType, - String serviceInstanceName) { + Optional<org.onap.aai.domain.yang.ServiceInstance> aaiServiceInstance = + injectionHelper.getAaiClient() + .getOne(ServiceInstances.class, org.onap.aai.domain.yang.ServiceInstance.class, AAIUriFactory + .createResourceUri(AAIObjectPlurals.SERVICE_INSTANCE, customer.getGlobalCustomerId(), + customer.getServiceSubscription().getServiceType()) + .queryParam("service-instance-name", serviceInstanceName).depth(Depth.TWO)); - return injectionHelper.getAaiClient() - .get(ServiceInstances.class, - AAIUriFactory - .createResourceUri(AAIObjectPlurals.SERVICE_INSTANCE, globalCustomerId, serviceType) - .queryParam("service-instance-name", serviceInstanceName).depth(Depth.TWO)) - .orElseGet(() -> { - logger.debug("No Service Instance matched by name"); - return null; - }); + return aaiServiceInstance.orElse(null); } public Optional<ServiceInstance> getAAIServiceInstanceByName(String globalCustomerId, String serviceType, - String serviceInstanceName) throws MultipleObjectsFoundException { - ServiceInstance aaiServiceInstance = null; - ServiceInstances aaiServiceInstances = null; - aaiServiceInstances = getAAIServiceInstancesByName(globalCustomerId, serviceType, serviceInstanceName); + String serviceInstanceName) { - if (aaiServiceInstances == null) { - return Optional.empty(); - } else if (aaiServiceInstances.getServiceInstance().size() > 1) { - String message = String.format( - "Multiple service instances found for customer-id: %s, service-type: %s and service-instance-name: %s.", - globalCustomerId, serviceType, serviceInstanceName); - throw new MultipleObjectsFoundException(message); - } else { - aaiServiceInstance = aaiServiceInstances.getServiceInstance().get(0); - } - return Optional.of(aaiServiceInstance); + return injectionHelper.getAaiClient().getOne(ServiceInstances.class, ServiceInstance.class, + AAIUriFactory.createResourceUri(AAIObjectPlurals.SERVICE_INSTANCE, globalCustomerId, serviceType) + .queryParam("service-instance-name", serviceInstanceName).depth(Depth.TWO)); } public org.onap.so.db.catalog.beans.InstanceGroup getCatalogInstanceGroup(String modelUUID) { @@ -434,8 +391,8 @@ public class BBInputSetupUtils { public Optional<ServiceInstance> getRelatedServiceInstanceFromInstanceGroup(String instanceGroupId) throws Exception { - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.INSTANCE_GROUP, instanceGroupId); - uri.relatedTo(AAIObjectPlurals.SERVICE_INSTANCE); + AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.INSTANCE_GROUP, instanceGroupId) + .relatedTo(AAIObjectPlurals.SERVICE_INSTANCE); Optional<ServiceInstances> serviceInstances = injectionHelper.getAaiClient().get(ServiceInstances.class, uri); ServiceInstance serviceInstance = null; if (!serviceInstances.isPresent()) { @@ -457,8 +414,8 @@ public class BBInputSetupUtils { public Optional<L3Network> getRelatedNetworkByNameFromServiceInstance(String serviceInstanceId, String networkName) throws MultipleObjectsFoundException { - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstanceId); - uri.relatedTo(AAIObjectPlurals.L3_NETWORK).queryParam("network-name", networkName); + AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstanceId) + .relatedTo(AAIObjectPlurals.L3_NETWORK).queryParam("network-name", networkName); Optional<L3Networks> networks = injectionHelper.getAaiClient().get(L3Networks.class, uri); L3Network network = null; if (!networks.isPresent()) { @@ -477,100 +434,36 @@ public class BBInputSetupUtils { } } - public Optional<GenericVnf> getRelatedVnfByNameFromServiceInstance(String serviceInstanceId, String vnfName) - throws MultipleObjectsFoundException { - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstanceId); - uri.relatedTo(AAIObjectPlurals.GENERIC_VNF).queryParam("vnf-name", vnfName); - Optional<GenericVnfs> vnfs = injectionHelper.getAaiClient().get(GenericVnfs.class, uri); - GenericVnf vnf = null; - if (!vnfs.isPresent()) { - logger.debug("No Vnfs matched by name"); - return Optional.empty(); - } else { - if (vnfs.get().getGenericVnf().size() > 1) { - String message = String.format("Multiple vnfs found for service-instance-id: %s and vnf-name: %s.", - serviceInstanceId, vnfName); - throw new MultipleObjectsFoundException(message); - } else { - vnf = vnfs.get().getGenericVnf().get(0); - } - return Optional.of(vnf); - } + public Optional<GenericVnf> getRelatedVnfByNameFromServiceInstance(String serviceInstanceId, String vnfName) { + AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstanceId) + .relatedTo(AAIObjectPlurals.GENERIC_VNF).queryParam("vnf-name", vnfName); + return injectionHelper.getAaiClient().getOne(GenericVnfs.class, GenericVnf.class, uri); + } - public Optional<VolumeGroup> getRelatedVolumeGroupByNameFromVnf(String vnfId, String volumeGroupName) - throws MultipleObjectsFoundException { - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId); - uri.relatedTo(AAIObjectPlurals.VOLUME_GROUP).queryParam("volume-group-name", volumeGroupName); - Optional<VolumeGroups> volumeGroups = injectionHelper.getAaiClient().get(VolumeGroups.class, uri); - VolumeGroup volumeGroup = null; - if (!volumeGroups.isPresent()) { - logger.debug("No VolumeGroups matched by name"); - return Optional.empty(); - } else { - if (volumeGroups.get().getVolumeGroup().size() > 1) { - String message = String.format("Multiple volume-groups found for vnf-id: %s and volume-group-name: %s.", - vnfId, volumeGroupName); - throw new MultipleObjectsFoundException(message); - } else { - volumeGroup = volumeGroups.get().getVolumeGroup().get(0); - } - return Optional.of(volumeGroup); - } + public Optional<VolumeGroup> getRelatedVolumeGroupByNameFromVnf(String vnfId, String volumeGroupName) { + AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId) + .relatedTo(AAIObjectPlurals.VOLUME_GROUP).queryParam("volume-group-name", volumeGroupName); + return injectionHelper.getAaiClient().getOne(VolumeGroups.class, VolumeGroup.class, uri); } public Optional<VolumeGroup> getRelatedVolumeGroupByIdFromVnf(String vnfId, String volumeGroupId) { - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId); - uri.relatedTo(AAIObjectPlurals.VOLUME_GROUP).queryParam("volume-group-id", volumeGroupId); - Optional<VolumeGroups> volumeGroups = injectionHelper.getAaiClient().get(VolumeGroups.class, uri); - VolumeGroup volumeGroup = null; - if (!volumeGroups.isPresent()) { - logger.debug("No VolumeGroups matched by id"); - return Optional.empty(); - } else { - volumeGroup = volumeGroups.get().getVolumeGroup().get(0); - return Optional.of(volumeGroup); - } + AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId) + .relatedTo(AAIObjectPlurals.VOLUME_GROUP).queryParam("volume-group-id", volumeGroupId); + return injectionHelper.getAaiClient().getOne(VolumeGroups.class, VolumeGroup.class, uri); } public Optional<VolumeGroup> getRelatedVolumeGroupByNameFromVfModule(String vnfId, String vfModuleId, - String volumeGroupName) throws MultipleObjectsFoundException { - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, vnfId, vfModuleId); - uri.relatedTo(AAIObjectPlurals.VOLUME_GROUP).queryParam("volume-group-name", volumeGroupName); - Optional<VolumeGroups> volumeGroups = injectionHelper.getAaiClient().get(VolumeGroups.class, uri); - VolumeGroup volumeGroup = null; - if (!volumeGroups.isPresent()) { - logger.debug("No VolumeGroups matched by name"); - return Optional.empty(); - } else { - if (volumeGroups.get().getVolumeGroup().size() > 1) { - String message = String.format( - "Multiple voulme-groups found for vnf-id: %s, vf-module-id: %s and volume-group-name: %s.", - vnfId, vfModuleId, volumeGroupName); - throw new MultipleObjectsFoundException(message); - } else { - volumeGroup = volumeGroups.get().getVolumeGroup().get(0); - } - return Optional.of(volumeGroup); - } + String volumeGroupName) throws Exception { + AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, vnfId, vfModuleId) + .relatedTo(AAIObjectPlurals.VOLUME_GROUP).queryParam("volume-group-name", volumeGroupName); + return injectionHelper.getAaiClient().getOne(VolumeGroups.class, VolumeGroup.class, uri); } public Optional<VolumeGroup> getRelatedVolumeGroupFromVfModule(String vnfId, String vfModuleId) throws Exception { - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, vnfId, vfModuleId); - uri.relatedTo(AAIObjectPlurals.VOLUME_GROUP); - Optional<VolumeGroups> volumeGroups = injectionHelper.getAaiClient().get(VolumeGroups.class, uri); - VolumeGroup volumeGroup = null; - if (!volumeGroups.isPresent()) { - logger.debug("VfModule does not have a volume group attached"); - return Optional.empty(); - } else { - if (volumeGroups.get().getVolumeGroup().size() > 1) { - throw new Exception("Multiple VolumeGroups Returned"); - } else { - volumeGroup = volumeGroups.get().getVolumeGroup().get(0); - } - return Optional.of(volumeGroup); - } + AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, vnfId, vfModuleId) + .relatedTo(AAIObjectPlurals.VOLUME_GROUP); + return injectionHelper.getAaiClient().getOne(VolumeGroups.class, VolumeGroup.class, uri); } public Optional<org.onap.aai.domain.yang.VpnBinding> getAICVpnBindingFromNetwork( @@ -598,26 +491,26 @@ public class BBInputSetupUtils { public boolean existsAAINetworksGloballyByName(String networkName) { - AAIResourceUri l3networkUri = + AAIPluralResourceUri l3networkUri = AAIUriFactory.createResourceUri(AAIObjectPlurals.L3_NETWORK).queryParam("network-name", networkName); AAIResourcesClient aaiRC = injectionHelper.getAaiClient(); return aaiRC.exists(l3networkUri); } public boolean existsAAIVfModuleGloballyByName(String vfModuleName) { - AAIResourceUri vfModuleUri = + AAIPluralResourceUri vfModuleUri = AAIUriFactory.createNodesUri(AAIObjectPlurals.VF_MODULE).queryParam("vf-module-name", vfModuleName); return injectionHelper.getAaiClient().exists(vfModuleUri); } public boolean existsAAIConfigurationGloballyByName(String configurationName) { - AAIResourceUri configUri = AAIUriFactory.createResourceUri(AAIObjectPlurals.CONFIGURATION) + AAIPluralResourceUri configUri = AAIUriFactory.createResourceUri(AAIObjectPlurals.CONFIGURATION) .queryParam("configuration-name", configurationName); return injectionHelper.getAaiClient().exists(configUri); } public boolean existsAAIVolumeGroupGloballyByName(String volumeGroupName) { - AAIResourceUri volumeGroupUri = AAIUriFactory.createNodesUri(AAIObjectPlurals.VOLUME_GROUP) + AAIPluralResourceUri volumeGroupUri = AAIUriFactory.createNodesUri(AAIObjectPlurals.VOLUME_GROUP) .queryParam("volume-group-name", volumeGroupName); return injectionHelper.getAaiClient().exists(volumeGroupUri); } @@ -634,24 +527,9 @@ public class BBInputSetupUtils { } public Optional<Configuration> getRelatedConfigurationByNameFromServiceInstance(String serviceInstanceId, - String configurationName) throws MultipleObjectsFoundException { - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstanceId); - uri.relatedTo(AAIObjectPlurals.CONFIGURATION).queryParam("configuration-name", configurationName); - Optional<Configurations> configurations = injectionHelper.getAaiClient().get(Configurations.class, uri); - Configuration configuration = null; - if (!configurations.isPresent()) { - logger.debug("No Configurations matched by name"); - return Optional.empty(); - } else { - if (configurations.get().getConfiguration().size() > 1) { - String message = String.format( - "Multiple configurations found for service-instance-d: %s and configuration-name: %s.", - serviceInstanceId, configurationName); - throw new MultipleObjectsFoundException(message); - } else { - configuration = configurations.get().getConfiguration().get(0); - } - return Optional.of(configuration); - } + String configurationName) { + AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstanceId) + .relatedTo(AAIObjectPlurals.CONFIGURATION).queryParam("configuration-name", configurationName); + return injectionHelper.getAaiClient().getOne(Configurations.class, Configuration.class, uri); } } diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/SDNCLcmClientBuilder.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/SDNCLcmClientBuilder.java index 0f17c547b5..333bf80d6c 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/SDNCLcmClientBuilder.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/SDNCLcmClientBuilder.java @@ -48,8 +48,6 @@ public class SDNCLcmClientBuilder { try { String path = sdncLcmProperties.getPath() + operation; pathUri = new URI(path); - logger.debug("SDNC host: " + sdncLcmProperties.getHost()); - logger.debug("SDNC API path: " + pathUri.getPath()); } catch (Exception e) { String msg = "Error API path syntax: "; logger.error(msg, e); @@ -57,9 +55,7 @@ public class SDNCLcmClientBuilder { } try { - SDNCLcmRestClient sdncLcmRestClient = new SDNCLcmRestClient(sdncLcmProperties, pathUri); - logger.debug("Create SDNCLcmRestClient success"); - return sdncLcmRestClient; + return new SDNCLcmRestClient(sdncLcmProperties, pathUri); } catch (Exception e) { String msg = "Create SDNCLcmRestClient failure: "; logger.error(msg, e); @@ -69,9 +65,7 @@ public class SDNCLcmClientBuilder { public SDNCLcmDmaapClient newSDNCLcmDmaapClient() throws SDNCLcmClientBuilderException { try { - SDNCLcmDmaapClient sdncLcmDmaapClient = new SDNCLcmDmaapClient(sdncLcmProperties); - logger.debug("Create SDNCLcmDmaapClient success"); - return sdncLcmDmaapClient; + return new SDNCLcmDmaapClient(sdncLcmProperties); } catch (Exception e) { String msg = "Create SDNCLcmDmaapClient failure: "; logger.error(msg, e); diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/SDNCLcmMessageBuilder.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/SDNCLcmMessageBuilder.java index bf1229a310..4ea6850e47 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/SDNCLcmMessageBuilder.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/SDNCLcmMessageBuilder.java @@ -26,7 +26,7 @@ import org.onap.so.client.sdnc.lcm.beans.*; public class SDNCLcmMessageBuilder { - public static LcmFlags getSDNCFlags() { + public static LcmFlags buildLcmFlags() { LcmFlags lcmFlags = new LcmFlags(); lcmFlags.setMode(SDNCConstants.LCM_FLAGS_MODE_NORMAL); @@ -43,7 +43,7 @@ public class SDNCLcmMessageBuilder { lcmCommonHeader.setOriginatorId(SDNCConstants.SYSTEM_NAME); lcmCommonHeader.setRequestId(requestId); lcmCommonHeader.setSubRequestId(subRequestId); - lcmCommonHeader.setFlags(getSDNCFlags()); + lcmCommonHeader.setFlags(buildLcmFlags()); lcmCommonHeader.setTimestamp(Instant.now().toString()); return lcmCommonHeader; diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/LcmFlags.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/LcmFlags.java index 36527ec887..55e0ea3e5d 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/LcmFlags.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/LcmFlags.java @@ -35,7 +35,7 @@ public class LcmFlags { private String force; @JsonProperty("ttl") - private int ttl; + private Integer ttl; public String getMode() { return mode; diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/LcmStatus.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/LcmStatus.java index 8a2a142792..3bbafcaaa4 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/LcmStatus.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/LcmStatus.java @@ -29,16 +29,16 @@ import com.fasterxml.jackson.annotation.JsonPropertyOrder; public class LcmStatus { @JsonProperty(value = "code", required = true) - private int code; + private Integer code; @JsonProperty(value = "message", required = true) private String message; - public int getCode() { + public Integer getCode() { return code; } - public void setCode(int value) { + public void setCode(Integer value) { this.code = value; } diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/payload/SwToBeDownloadedElement.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/payload/SwToBeDownloadedElement.java index 1a3529d7c4..05de9b1c90 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/payload/SwToBeDownloadedElement.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/payload/SwToBeDownloadedElement.java @@ -32,7 +32,7 @@ public class SwToBeDownloadedElement { private String swLocation; @JsonProperty(value = "swFileSize") - private long swFileSize; + private Long swFileSize; @JsonProperty(value = "swFileCompression") private String swFileCompression; @@ -48,11 +48,11 @@ public class SwToBeDownloadedElement { this.swLocation = value; } - public long getSwFileSize() { + public Long getSwFileSize() { return swFileSize; } - public void setSwFileSize(long value) { + public void setSwFileSize(Long value) { this.swFileSize = value; } diff --git a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/MsoGroovyTest.groovy b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/MsoGroovyTest.groovy index 525307a5df..59b34c4074 100644 --- a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/MsoGroovyTest.groovy +++ b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/MsoGroovyTest.groovy @@ -37,6 +37,7 @@ import org.onap.so.client.aai.AAIObjectPlurals import org.onap.so.client.aai.AAIObjectType import org.onap.so.client.aai.AAIResourcesClient import org.onap.so.client.aai.entities.AAIResultWrapper +import org.onap.so.client.aai.entities.uri.AAIPluralResourceUri import org.onap.so.client.aai.entities.uri.AAIResourceUri import org.onap.so.client.aai.entities.uri.AAIUriFactory import org.onap.so.client.graphinventory.entities.uri.Depth @@ -118,8 +119,8 @@ abstract class MsoGroovyTest { } protected Optional<GenericVnf> mockAAIGenericVnfByName(String vnfName){ - AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIObjectPlurals.GENERIC_VNF).queryParam("vnf-name", vnfName) - AAIResourceUri resourceUriDepthOne = AAIUriFactory.createResourceUri(AAIObjectPlurals.GENERIC_VNF).queryParam("vnf-name", vnfName).depth(Depth.ONE) + AAIPluralResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIObjectPlurals.GENERIC_VNF).queryParam("vnf-name", vnfName) + AAIPluralResourceUri resourceUriDepthOne = AAIUriFactory.createResourceUri(AAIObjectPlurals.GENERIC_VNF).queryParam("vnf-name", vnfName).depth(Depth.ONE) Optional<GenericVnf> genericVnf = getAAIObjectFromJson(GenericVnf.class,"__files/aai/GenericVnf.json"); when(client.get(GenericVnf.class, resourceUri)).thenReturn(genericVnf) when(client.get(GenericVnf.class, resourceUriDepthOne)).thenReturn(genericVnf) @@ -134,8 +135,8 @@ abstract class MsoGroovyTest { } protected void mockAAIGenericVnfByNameNotFound(String vnfName){ - AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIObjectPlurals.GENERIC_VNF).queryParam("vnf-name", vnfName) - AAIResourceUri resourceUriDepthOne = AAIUriFactory.createResourceUri(AAIObjectPlurals.GENERIC_VNF).queryParam("vnf-name", vnfName).depth(Depth.ONE) + AAIPluralResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIObjectPlurals.GENERIC_VNF).queryParam("vnf-name", vnfName) + AAIPluralResourceUri resourceUriDepthOne = AAIUriFactory.createResourceUri(AAIObjectPlurals.GENERIC_VNF).queryParam("vnf-name", vnfName).depth(Depth.ONE) when(client.get(GenericVnf.class, resourceUri)).thenReturn(Optional.empty()) when(client.get(GenericVnf.class, resourceUriDepthOne)).thenReturn(Optional.empty()) } diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtilsTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtilsTest.java index fcc59c3340..64e1b40739 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtilsTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtilsTest.java @@ -74,6 +74,7 @@ import org.onap.so.bpmn.servicedecomposition.tasks.exceptions.NoServiceInstanceF import org.onap.so.client.aai.AAIObjectPlurals; import org.onap.so.client.aai.AAIObjectType; import org.onap.so.client.aai.AAIResourcesClient; +import org.onap.so.client.aai.entities.uri.AAIPluralResourceUri; import org.onap.so.client.aai.entities.uri.AAIResourceUri; import org.onap.so.client.aai.entities.uri.AAIUriFactory; import org.onap.so.client.graphinventory.entities.uri.Depth; @@ -317,38 +318,14 @@ public class BBInputSetupUtilsTest { ServiceInstances serviceInstances = new ServiceInstances(); serviceInstances.getServiceInstance().add(expectedServiceInstance); - doReturn(Optional.of(serviceInstances)).when(MOCK_aaiResourcesClient).get(isA(Class.class), - isA(AAIResourceUri.class)); - - assertThat(bbInputSetupUtils.getAAIServiceInstanceByName(serviceInstanceName, customer), - sameBeanAs(serviceInstances.getServiceInstance().get(0))); - } - - @Test - public void getAAIServiceInstanceByNameExceptionTest() throws Exception { - final String serviceInstanceName = "serviceInstanceName"; - - expectedException.expect(Exception.class); - expectedException.expectMessage("Multiple Service Instances Returned"); - - ServiceInstance serviceInstance = new ServiceInstance(); - serviceInstance.setServiceInstanceId("serviceInstanceId"); - - ServiceSubscription serviceSubscription = new ServiceSubscription(); - serviceSubscription.setServiceType("serviceType"); - - Customer customer = new Customer(); - customer.setGlobalCustomerId("globalCustomerId"); - customer.setServiceSubscription(serviceSubscription); - - ServiceInstances serviceInstances = new ServiceInstances(); - serviceInstances.getServiceInstance().add(serviceInstance); - serviceInstances.getServiceInstance().add(serviceInstance); - - doReturn(Optional.of(serviceInstances)).when(MOCK_aaiResourcesClient).get(isA(Class.class), - isA(AAIResourceUri.class)); - + AAIPluralResourceUri expectedUri = AAIUriFactory + .createResourceUri(AAIObjectPlurals.SERVICE_INSTANCE, customer.getGlobalCustomerId(), + customer.getServiceSubscription().getServiceType()) + .queryParam("service-instance-name", serviceInstanceName).depth(Depth.TWO); bbInputSetupUtils.getAAIServiceInstanceByName(serviceInstanceName, customer); + + verify(MOCK_aaiResourcesClient, times(1)).getOne(org.onap.aai.domain.yang.ServiceInstances.class, + org.onap.aai.domain.yang.ServiceInstance.class, expectedUri); } @Test @@ -360,30 +337,6 @@ public class BBInputSetupUtilsTest { } @Test - public void getOptionalAAIServiceInstanceByNameExceptionTest() throws Exception { - expectedException.expect(MultipleObjectsFoundException.class); - expectedException.expectMessage(containsString( - "Multiple service instances found for customer-id: globalCustomerId, service-type: serviceType and service-instance-name: serviceInstanceId.")); - - final String globalCustomerId = "globalCustomerId"; - final String serviceType = "serviceType"; - final String serviceInstanceId = "serviceInstanceId"; - - ServiceInstance serviceInstance = new ServiceInstance(); - serviceInstance.setServiceInstanceId(serviceInstanceId); - serviceInstance.setServiceType(serviceType); - - ServiceInstances serviceInstances = new ServiceInstances(); - serviceInstances.getServiceInstance().add(serviceInstance); - serviceInstances.getServiceInstance().add(serviceInstance); - - doReturn(Optional.of(serviceInstances)).when(MOCK_aaiResourcesClient).get(isA(Class.class), - isA(AAIResourceUri.class)); - - bbInputSetupUtils.getAAIServiceInstanceByName(globalCustomerId, serviceType, serviceInstanceId); - } - - @Test public void getOptionalAAIServiceInstanceByNameNullTest() throws Exception { Optional<ServiceInstance> actual = bbInputSetupUtils.getAAIServiceInstanceByName("", "", ""); @@ -487,8 +440,7 @@ public class BBInputSetupUtilsTest { network.setNetworkId(networkId); network.setNetworkName(networkName); expected.get().getL3Network().add(network); - - doReturn(expected).when(MOCK_aaiResourcesClient).get(eq(L3Networks.class), any(AAIResourceUri.class)); + doReturn(expected).when(MOCK_aaiResourcesClient).get(eq(L3Networks.class), any(AAIPluralResourceUri.class)); Optional<L3Network> actual = bbInputSetupUtils.getRelatedNetworkByNameFromServiceInstance(networkId, networkName); @@ -499,31 +451,17 @@ public class BBInputSetupUtilsTest { } @Test - public void getRelatedNetworkByNameFromServiceInstanceMultipleNetworksExceptionTest() throws Exception { - final String serviceInstanceId = "serviceInstanceId"; - final String networkName = "networkName"; - expectedException.expect(MultipleObjectsFoundException.class); - expectedException.expectMessage( - String.format("Multiple networks found for service-instance-id: %s and network-name: %s.", - serviceInstanceId, networkName)); - - L3Network network = new L3Network(); - network.setNetworkId("id123"); - network.setNetworkName("name123"); - - L3Networks l3Networks = new L3Networks(); - l3Networks.getL3Network().add(network); - l3Networks.getL3Network().add(network); - Optional<L3Networks> optNetworks = Optional.of(l3Networks); + public void getRelatedNetworkByNameFromServiceInstanceNotFoundTest() throws Exception { + String serviceInstanceId = "serviceInstanceId"; + String networkName = "networkName"; - doReturn(optNetworks).when(MOCK_aaiResourcesClient).get(eq(L3Networks.class), any(AAIResourceUri.class)); + doReturn(Optional.empty()).when(MOCK_aaiResourcesClient).get(eq(L3Networks.class), + any(AAIPluralResourceUri.class)); - bbInputSetupUtils.getRelatedNetworkByNameFromServiceInstance(serviceInstanceId, networkName); - } + Optional<L3Network> actualNetwork = + bbInputSetupUtils.getRelatedNetworkByNameFromServiceInstance(serviceInstanceId, networkName); - @Test - public void getRelatedNetworkByNameFromServiceInstanceNotFoundTest() throws Exception { - assertEquals(Optional.empty(), bbInputSetupUtils.getRelatedNetworkByNameFromServiceInstance("", "")); + assertEquals(Optional.empty(), actualNetwork); } @Test @@ -534,7 +472,8 @@ public class BBInputSetupUtilsTest { serviceInstance.setServiceInstanceName("serviceInstanceName"); expected.get().getServiceInstance().add(serviceInstance); - doReturn(expected).when(MOCK_aaiResourcesClient).get(eq(ServiceInstances.class), any(AAIResourceUri.class)); + doReturn(expected).when(MOCK_aaiResourcesClient).get(eq(ServiceInstances.class), + any(AAIPluralResourceUri.class)); Optional<ServiceInstance> actual = this.bbInputSetupUtils.getRelatedServiceInstanceFromInstanceGroup("ig-001"); assertTrue(actual.isPresent()); @@ -546,9 +485,6 @@ public class BBInputSetupUtilsTest { public void getRelatedServiceInstanceFromInstanceGroupMultipleExceptionTest() throws Exception { final String instanceGroupId = "ig-001"; expectedException.expect(MultipleObjectsFoundException.class); - expectedException.expectMessage( - String.format("Mulitple service instances were found for instance-group-id: %s.", instanceGroupId)); - Optional<ServiceInstances> serviceInstances = Optional.of(new ServiceInstances()); ServiceInstance si1 = Mockito.mock(ServiceInstance.class); ServiceInstance si2 = Mockito.mock(ServiceInstance.class); @@ -556,60 +492,35 @@ public class BBInputSetupUtilsTest { serviceInstances.get().getServiceInstance().add(si2); doReturn(serviceInstances).when(MOCK_aaiResourcesClient).get(eq(ServiceInstances.class), - any(AAIResourceUri.class)); - bbInputSetupUtils.getRelatedServiceInstanceFromInstanceGroup(instanceGroupId); + any(AAIPluralResourceUri.class)); + this.bbInputSetupUtils.getRelatedServiceInstanceFromInstanceGroup(instanceGroupId); } @Test public void getRelatedServiceInstanceFromInstanceGroupNotFoundExceptionTest() throws Exception { expectedException.expect(NoServiceInstanceFoundException.class); - expectedException.expectMessage("No ServiceInstances Returned"); - Optional<ServiceInstances> serviceInstances = Optional.of(new ServiceInstances()); doReturn(serviceInstances).when(MOCK_aaiResourcesClient).get(eq(ServiceInstances.class), - any(AAIResourceUri.class)); - bbInputSetupUtils.getRelatedServiceInstanceFromInstanceGroup("ig-001"); + any(AAIPluralResourceUri.class)); + this.bbInputSetupUtils.getRelatedServiceInstanceFromInstanceGroup("ig-001"); } @Test public void getRelatedVnfByNameFromServiceInstanceTest() throws Exception { final String vnfId = "id123"; final String vnfName = "name123"; - - Optional<GenericVnfs> expected = Optional.of(new GenericVnfs()); + final String serviceInstanceId = "service-instance-id123"; GenericVnf vnf = new GenericVnf(); vnf.setVnfId(vnfId); vnf.setVnfName(vnfName); - expected.get().getGenericVnf().add(vnf); - - doReturn(expected).when(MOCK_aaiResourcesClient).get(eq(GenericVnfs.class), any(AAIResourceUri.class)); - Optional<GenericVnf> actual = this.bbInputSetupUtils.getRelatedVnfByNameFromServiceInstance(vnfId, vnfName); - + doReturn(Optional.of(vnf)).when(MOCK_aaiResourcesClient).getOne(GenericVnfs.class, GenericVnf.class, + AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstanceId) + .relatedTo(AAIObjectPlurals.GENERIC_VNF).queryParam("vnf-name", vnfName)); + Optional<GenericVnf> actual = + this.bbInputSetupUtils.getRelatedVnfByNameFromServiceInstance(serviceInstanceId, vnfName); assertTrue(actual.isPresent()); - assertEquals(expected.get().getGenericVnf().get(0).getVnfId(), actual.get().getVnfId()); - } - - @Test - public void getRelatedVnfByNameFromServiceInstanceMultipleVnfsExceptionTest() throws Exception { - final String serviceInstanceId = "serviceInstanceId"; - final String vnfName = "vnfName"; - expectedException.expect(MultipleObjectsFoundException.class); - expectedException.expectMessage(String.format( - "Multiple vnfs found for service-instance-id: %s and vnf-name: %s.", serviceInstanceId, vnfName)); - - GenericVnf vnf = new GenericVnf(); - vnf.setVnfId("id123"); - vnf.setVnfName("name123"); - - GenericVnfs vnfs = new GenericVnfs(); - vnfs.getGenericVnf().add(vnf); - vnfs.getGenericVnf().add(vnf); - - Optional<GenericVnfs> optVnfs = Optional.of(vnfs); - doReturn(optVnfs).when(MOCK_aaiResourcesClient).get(eq(GenericVnfs.class), any(AAIResourceUri.class)); - - bbInputSetupUtils.getRelatedVnfByNameFromServiceInstance(serviceInstanceId, vnfName); + assertEquals(vnf.getVnfId(), actual.get().getVnfId()); } @Test @@ -617,69 +528,56 @@ public class BBInputSetupUtilsTest { final String serviceInstanceId = "serviceInstanceId"; final String vnfName = "vnfName"; + doReturn(Optional.empty()).when(MOCK_aaiResourcesClient).getOne(eq(GenericVnfs.class), eq(GenericVnf.class), + any(AAIPluralResourceUri.class)); + assertEquals(Optional.empty(), bbInputSetupUtils.getRelatedVnfByNameFromServiceInstance(serviceInstanceId, vnfName)); } @Test public void getRelatedVolumeGroupByNameFromVnfTest() throws Exception { - final String vnfId = "id123"; - final String vnfName = "name123"; - - Optional<VolumeGroups> expected = Optional.of(new VolumeGroups()); + final String vnfId = "vnf-id123"; + final String volumeGroupId = "id123"; + final String volumeGroupName = "volume-group-name123"; VolumeGroup volumeGroup = new VolumeGroup(); - volumeGroup.setVolumeGroupId(vnfId); - volumeGroup.setVolumeGroupName(vnfName); - expected.get().getVolumeGroup().add(volumeGroup); - - doReturn(expected).when(MOCK_aaiResourcesClient).get(eq(VolumeGroups.class), any(AAIResourceUri.class)); - Optional<VolumeGroup> actual = this.bbInputSetupUtils.getRelatedVolumeGroupByNameFromVnf(vnfId, vnfName); - - assertTrue(actual.isPresent()); - assertEquals(expected.get().getVolumeGroup().get(0).getVolumeGroupId(), actual.get().getVolumeGroupId()); + volumeGroup.setVolumeGroupId(volumeGroupId); + volumeGroup.setVolumeGroupName(volumeGroupName); + doReturn(Optional.of(volumeGroup)).when(MOCK_aaiResourcesClient).getOne(VolumeGroups.class, VolumeGroup.class, + AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId) + .relatedTo(AAIObjectPlurals.VOLUME_GROUP).queryParam("volume-group-name", volumeGroupName)); + Optional<VolumeGroup> actual = + this.bbInputSetupUtils.getRelatedVolumeGroupByNameFromVnf(vnfId, volumeGroupName); + assertEquals(volumeGroup.getVolumeGroupId(), actual.get().getVolumeGroupId()); } @Test - public void getRelatedVolumeGroupByNameFromVnfMultipleVolumeGroupsExceptionTest() throws Exception { - final String vnfId = "vnfId"; - final String volumeGroupName = "volumeGroupName"; - expectedException.expect(MultipleObjectsFoundException.class); - expectedException.expectMessage(String.format( - "Multiple volume-groups found for vnf-id: %s and volume-group-name: %s.", vnfId, volumeGroupName)); - - VolumeGroup volumeGroup = new VolumeGroup(); - volumeGroup.setVolumeGroupId("id123"); - volumeGroup.setVolumeGroupName("name123"); + public void getRelatedVolumeGroupByNameFromVnfNotFoundTest() throws Exception { + String vnfId = "vnfId"; + String volumeGroupName = "volumeGroupName"; - VolumeGroups volumeGroups = new VolumeGroups(); - volumeGroups.getVolumeGroup().add(volumeGroup); - volumeGroups.getVolumeGroup().add(volumeGroup); - Optional<VolumeGroups> optVolumeGroups = Optional.of(volumeGroups); + doReturn(Optional.empty()).when(MOCK_aaiResourcesClient).getOne(eq(VolumeGroups.class), eq(VolumeGroup.class), + any(AAIPluralResourceUri.class)); - doReturn(optVolumeGroups).when(MOCK_aaiResourcesClient).get(eq(VolumeGroups.class), any(AAIResourceUri.class)); + Optional<VolumeGroup> actualVolumeGroup = + bbInputSetupUtils.getRelatedVolumeGroupByNameFromVnf(vnfId, volumeGroupName); - bbInputSetupUtils.getRelatedVolumeGroupByNameFromVnf(vnfId, volumeGroupName); - } - - @Test - public void getRelatedVolumeGroupByNameFromVnfNotFoundTest() throws Exception { - assertEquals(Optional.empty(), bbInputSetupUtils.getRelatedVolumeGroupByNameFromVnf("", "")); + assertEquals(Optional.empty(), actualVolumeGroup); } @Test public void getRelatedVolumeGroupByNameFromVfModuleTest() throws Exception { - Optional<VolumeGroups> expected = Optional.of(new VolumeGroups()); VolumeGroup volumeGroup = new VolumeGroup(); volumeGroup.setVolumeGroupId("id123"); volumeGroup.setVolumeGroupName("name123"); - expected.get().getVolumeGroup().add(volumeGroup); - - doReturn(expected).when(MOCK_aaiResourcesClient).get(eq(VolumeGroups.class), any(AAIResourceUri.class)); - Optional<VolumeGroup> actual = - this.bbInputSetupUtils.getRelatedVolumeGroupByNameFromVfModule("id123", "id123", "name123"); - + doReturn(Optional.of(volumeGroup)).when(MOCK_aaiResourcesClient).getOne(VolumeGroups.class, VolumeGroup.class, + AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, "vnf-id123", "vf-module-id123") + .relatedTo(AAIObjectPlurals.VOLUME_GROUP) + .queryParam("volume-group-name", "volume-group-name123")); + Optional<VolumeGroup> actual = this.bbInputSetupUtils.getRelatedVolumeGroupByNameFromVfModule("vnf-id123", + "vf-module-id123", "volume-group-name123"); assertTrue(actual.isPresent()); - assertEquals(expected.get().getVolumeGroup().get(0).getVolumeGroupId(), actual.get().getVolumeGroupId()); + assertEquals(volumeGroup.getVolumeGroupId(), actual.get().getVolumeGroupId()); } @Test @@ -707,51 +605,41 @@ public class BBInputSetupUtilsTest { final String vnfId = "vnfId"; final String volumeGroupId = "volumeGroupId"; - assertEquals(Optional.empty(), bbInputSetupUtils.getRelatedVolumeGroupFromVfModule(vnfId, volumeGroupId)); + doReturn(Optional.empty()).when(MOCK_aaiResourcesClient).getOne(eq(VolumeGroups.class), eq(VolumeGroup.class), + any(AAIPluralResourceUri.class)); + + Optional<VolumeGroup> actualVolumeGroup = + bbInputSetupUtils.getRelatedVolumeGroupFromVfModule(vnfId, volumeGroupId); + + assertEquals(Optional.empty(), actualVolumeGroup); } @Test public void getRelatedVolumeGroupFromVfModuleTest() throws Exception { - Optional<VolumeGroups> expected = Optional.of(new VolumeGroups()); VolumeGroup volumeGroup = new VolumeGroup(); volumeGroup.setVolumeGroupId("id123"); - expected.get().getVolumeGroup().add(volumeGroup); - - doReturn(expected).when(MOCK_aaiResourcesClient).get(eq(VolumeGroups.class), any(AAIResourceUri.class)); - Optional<VolumeGroup> actual = bbInputSetupUtils.getRelatedVolumeGroupFromVfModule("id123", "id123"); - + doReturn(Optional.of(volumeGroup)).when(MOCK_aaiResourcesClient).getOne(VolumeGroups.class, VolumeGroup.class, + AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, "vnf-id123", "vf-module-id123") + .relatedTo(AAIObjectPlurals.VOLUME_GROUP)); + Optional<VolumeGroup> actual = + this.bbInputSetupUtils.getRelatedVolumeGroupFromVfModule("vnf-id123", "vf-module-id123"); assertTrue(actual.isPresent()); - assertEquals(expected.get().getVolumeGroup().get(0).getVolumeGroupId(), actual.get().getVolumeGroupId()); + assertEquals(volumeGroup.getVolumeGroupId(), actual.get().getVolumeGroupId()); } @Test - public void getRelatedVolumeGroupByNameFromVfModuleMultipleVolumeGroupsExceptionTest() throws Exception { - final String vnfId = "vnfId"; - final String vfModuleId = "vfModuleId"; - final String volumeGroupName = "volumeGroupName"; - - expectedException.expect(MultipleObjectsFoundException.class); - expectedException.expectMessage(String.format( - "Multiple voulme-groups found for vnf-id: %s, vf-module-id: %s and volume-group-name: %s.", vnfId, - vfModuleId, volumeGroupName)); - - VolumeGroup volumeGroup = new VolumeGroup(); - volumeGroup.setVolumeGroupId("id123"); - volumeGroup.setVolumeGroupName("name123"); - - VolumeGroups volumeGroups = new VolumeGroups(); - volumeGroups.getVolumeGroup().add(volumeGroup); - volumeGroups.getVolumeGroup().add(volumeGroup); + public void getRelatedVolumeGroupByNameFromVfModuleNotFoundTest() throws Exception { + String vnfId = "vnfId"; + String volumeGroupId = "volumeGroupId"; + String volumeGroupName = "volumeGroupName"; - Optional<VolumeGroups> optVolumeGroups = Optional.of(volumeGroups); - doReturn(optVolumeGroups).when(MOCK_aaiResourcesClient).get(eq(VolumeGroups.class), any(AAIResourceUri.class)); + doReturn(Optional.empty()).when(MOCK_aaiResourcesClient).getOne(eq(VolumeGroups.class), eq(VolumeGroup.class), + any(AAIPluralResourceUri.class)); - bbInputSetupUtils.getRelatedVolumeGroupByNameFromVfModule(vnfId, vfModuleId, volumeGroupName); - } + Optional<VolumeGroup> actualVolumeGroup = + bbInputSetupUtils.getRelatedVolumeGroupByNameFromVfModule(vnfId, volumeGroupId, volumeGroupName); - @Test - public void getRelatedVolumeGroupByNameFromVfModuleNotFoundTest() throws Exception { - assertEquals(Optional.empty(), bbInputSetupUtils.getRelatedVolumeGroupByNameFromVfModule("", "", "")); + assertEquals(Optional.empty(), actualVolumeGroup); } @Test @@ -780,46 +668,28 @@ public class BBInputSetupUtilsTest { } @Test - public void getRelatedConfigurationByNameFromServiceInstanceExceptionTest() throws Exception { - Configuration configuration = new Configuration(); - configuration.setConfigurationId("id123"); - - Configurations configurations = new Configurations(); - configurations.getConfiguration().add(configuration); - configurations.getConfiguration().add(configuration); - - Optional<Configurations> optConfigurations = Optional.of(configurations); - - doReturn(optConfigurations).when(MOCK_aaiResourcesClient).get(eq(Configurations.class), - any(AAIResourceUri.class)); - - expectedException.expect(MultipleObjectsFoundException.class); - this.bbInputSetupUtils.getRelatedConfigurationByNameFromServiceInstance("id123", "name123"); - } - - @Test public void getRelatedConfigurationByNameFromServiceInstanceNotFoundTest() throws Exception { assertEquals(Optional.empty(), bbInputSetupUtils.getRelatedConfigurationByNameFromServiceInstance("", "")); } @Test public void getRelatedConfigurationByNameFromServiceInstanceTest() throws Exception { - Optional<Configurations> expected = Optional.of(new Configurations()); Configuration configuration = new Configuration(); configuration.setConfigurationId("id123"); - expected.get().getConfiguration().add(configuration); - - doReturn(expected).when(MOCK_aaiResourcesClient).get(eq(Configurations.class), any(AAIResourceUri.class)); - Optional<Configuration> actual = - this.bbInputSetupUtils.getRelatedConfigurationByNameFromServiceInstance("id123", "name123"); - + doReturn(Optional.of(configuration)).when(MOCK_aaiResourcesClient).getOne(Configurations.class, + Configuration.class, + AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, "service-instance-id123") + .relatedTo(AAIObjectPlurals.CONFIGURATION) + .queryParam("configuration-name", "configuration-name123")); + Optional<Configuration> actual = this.bbInputSetupUtils + .getRelatedConfigurationByNameFromServiceInstance("service-instance-id123", "configuration-name123"); assertTrue(actual.isPresent()); - assertEquals(expected.get().getConfiguration().get(0).getConfigurationId(), actual.get().getConfigurationId()); + assertEquals(configuration.getConfigurationId(), actual.get().getConfigurationId()); } @Test public void existsAAIVfModuleGloballyByNameTest() { - AAIResourceUri expectedUri = + AAIPluralResourceUri expectedUri = AAIUriFactory.createNodesUri(AAIObjectPlurals.VF_MODULE).queryParam("vf-module-name", "testVfModule"); bbInputSetupUtils.existsAAIVfModuleGloballyByName("testVfModule"); @@ -828,7 +698,7 @@ public class BBInputSetupUtilsTest { @Test public void existsAAIConfigurationGloballyByNameTest() { - AAIResourceUri expectedUri = AAIUriFactory.createResourceUri(AAIObjectPlurals.CONFIGURATION) + AAIPluralResourceUri expectedUri = AAIUriFactory.createResourceUri(AAIObjectPlurals.CONFIGURATION) .queryParam("configuration-name", "testConfig"); bbInputSetupUtils.existsAAIConfigurationGloballyByName("testConfig"); @@ -837,7 +707,7 @@ public class BBInputSetupUtilsTest { @Test public void existsAAINetworksGloballyByNameTest() { - AAIResourceUri expectedUri = + AAIPluralResourceUri expectedUri = AAIUriFactory.createResourceUri(AAIObjectPlurals.L3_NETWORK).queryParam("network-name", "testNetwork"); bbInputSetupUtils.existsAAINetworksGloballyByName("testNetwork"); @@ -846,7 +716,7 @@ public class BBInputSetupUtilsTest { @Test public void existsAAIVolumeGroupGloballyByNameTest() { - AAIResourceUri expectedUri = AAIUriFactory.createNodesUri(AAIObjectPlurals.VOLUME_GROUP) + AAIPluralResourceUri expectedUri = AAIUriFactory.createNodesUri(AAIObjectPlurals.VOLUME_GROUP) .queryParam("volume-group-name", "testVoumeGroup"); bbInputSetupUtils.existsAAIVolumeGroupGloballyByName("testVoumeGroup"); @@ -860,7 +730,7 @@ public class BBInputSetupUtilsTest { bbInputSetupUtils.updateInfraActiveRequestVnfId(infraActiveRequests, vnfId); - assertEquals(infraActiveRequests.getVnfId(), vnfId); + assertEquals(vnfId, infraActiveRequests.getVnfId()); } @Test @@ -870,7 +740,7 @@ public class BBInputSetupUtilsTest { bbInputSetupUtils.updateInfraActiveRequestVfModuleId(infraActiveRequests, vfModuleId); - assertEquals(infraActiveRequests.getVfModuleId(), vfModuleId); + assertEquals(vfModuleId, infraActiveRequests.getVfModuleId()); } @Test @@ -880,7 +750,7 @@ public class BBInputSetupUtilsTest { bbInputSetupUtils.updateInfraActiveRequestVolumeGroupId(infraActiveRequests, volumeGroupId); - assertEquals(infraActiveRequests.getVolumeGroupId(), volumeGroupId); + assertEquals(volumeGroupId, infraActiveRequests.getVolumeGroupId()); } @Test @@ -890,7 +760,7 @@ public class BBInputSetupUtilsTest { bbInputSetupUtils.updateInfraActiveRequestNetworkId(infraActiveRequests, networkId); - assertEquals(infraActiveRequests.getNetworkId(), networkId); + assertEquals(networkId, infraActiveRequests.getNetworkId()); } @Test @@ -921,14 +791,14 @@ public class BBInputSetupUtilsTest { mapper.readValue(new File(RESOURCE_PATH + "aaiL3NetworkInputWithSubnets.json"), L3Network.class); Optional<VpnBinding> actual = bbInputSetupUtils.getAICVpnBindingFromNetwork(l3Network); - assertEquals(actual, Optional.empty()); + assertEquals(Optional.empty(), actual); } @Test public void getAAIServiceInstancesGloballyByName_noAAIResourceTest() { final String serviceInstanceName = "serviceInstanceName"; - doReturn(Optional.empty()).when(MOCK_aaiResourcesClient).get(isA(Class.class), isA(AAIResourceUri.class)); + doReturn(Optional.empty()).when(MOCK_aaiResourcesClient).get(isA(Class.class), isA(AAIPluralResourceUri.class)); ServiceInstances actualServiceInstances = bbInputSetupUtils.getAAIServiceInstancesGloballyByName(serviceInstanceName); @@ -939,7 +809,7 @@ public class BBInputSetupUtilsTest { public void getAAIVnfsGloballyByName_noAAIResourceTest() { final String vnfName = "vnfName"; - doReturn(Optional.empty()).when(MOCK_aaiResourcesClient).get(isA(Class.class), isA(AAIResourceUri.class)); + doReturn(Optional.empty()).when(MOCK_aaiResourcesClient).get(isA(Class.class), isA(AAIPluralResourceUri.class)); GenericVnfs actualGenericVnfs = bbInputSetupUtils.getAAIVnfsGloballyByName(vnfName); assertNull(actualGenericVnfs); diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/beans/payload/DownloadNESwPayloadTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/beans/payload/DownloadNESwPayloadTest.java index f9fa679790..b99d45ae52 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/beans/payload/DownloadNESwPayloadTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/beans/payload/DownloadNESwPayloadTest.java @@ -37,7 +37,7 @@ public class DownloadNESwPayloadTest extends LcmBasePayloadTest { SwToBeDownloadedElement swToBeDownloadedElement = new SwToBeDownloadedElement(); swToBeDownloadedElement.setSwLocation("http://192.168.1.20/test.zip"); - swToBeDownloadedElement.setSwFileSize(123456); + swToBeDownloadedElement.setSwFileSize(123456L); swToBeDownloadedElement.setSwFileCompression("ZIP"); swToBeDownloadedElement.setSwFileFormat("binary"); |