aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/etsicatalog/EtsiCatalogUrlProvider.java18
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/Sol003PackageManagementControllerTest.java2
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/Sol003SubscriptionManagementControllerTest.java3
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/resources/application.yaml4
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/entities/ServiceModel.java32
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java60
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java123
-rw-r--r--common/src/main/java/org/onap/so/utils/CryptoUtils.java2
8 files changed, 188 insertions, 56 deletions
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/etsicatalog/EtsiCatalogUrlProvider.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/etsicatalog/EtsiCatalogUrlProvider.java
index 051f60a9c9..8382212d51 100644
--- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/etsicatalog/EtsiCatalogUrlProvider.java
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/etsicatalog/EtsiCatalogUrlProvider.java
@@ -35,12 +35,8 @@ public class EtsiCatalogUrlProvider {
private static final Logger logger = getLogger(EtsiCatalogUrlProvider.class);
- @Value("${msb.endpoint:#{\"http://msb_iag.onap:80\"}}")
- private String msbEndpoint;
- @Value("${msb.catalogServiceUrl:#{null}}")
- private String catalogServiceUrl;
- @Value("${msb.vnfpkgmServiceUrl:#{\"/api/vnfpkgm/v1\"}}")
- private String vnfpkgmServiceUrl;
+ @Value("${etsi-catalog-manager.vnfpkgm.endpoint}")
+ private String etsiCatalogManagerEndpoint;
public EtsiCatalogUrlProvider() {}
@@ -51,7 +47,7 @@ public class EtsiCatalogUrlProvider {
* @return the URL for the GET operation
*/
public String getVnfPackageContentUrl(final String vnfPkgId) {
- final String url = msbEndpoint + vnfpkgmServiceUrl + "/vnf_packages/" + vnfPkgId + "/package_content";
+ final String url = etsiCatalogManagerEndpoint + "/vnf_packages/" + vnfPkgId + "/package_content";
logger.info("getEtsiCatalogVnfPackageContentUrl: {}", url);
return url;
}
@@ -62,7 +58,7 @@ public class EtsiCatalogUrlProvider {
* @return the URL for the GET operation
*/
public String getVnfPackagesUrl() {
- final String url = msbEndpoint + vnfpkgmServiceUrl + "/vnf_packages";
+ final String url = etsiCatalogManagerEndpoint + "/vnf_packages";
logger.info("getEtsiCatalogVnfPackagesEndpoint: {}", url);
return url;
}
@@ -74,7 +70,7 @@ public class EtsiCatalogUrlProvider {
* @return the URL for the GET operation
*/
public String getVnfPackageUrl(final String vnfPkgId) {
- final String url = msbEndpoint + vnfpkgmServiceUrl + "/vnf_packages/" + vnfPkgId;
+ final String url = etsiCatalogManagerEndpoint + "/vnf_packages/" + vnfPkgId;
logger.info("getEtsiCatalogVnfPackageEndpoint: {}", url);
return url;
}
@@ -87,7 +83,7 @@ public class EtsiCatalogUrlProvider {
* @return the URL for the GET operation
*/
public String getVnfPackageArtifactUrl(final String vnfPkgId, final String artifactPath) {
- final String url = msbEndpoint + vnfpkgmServiceUrl + "/vnf_packages/" + vnfPkgId + "/artifacts/" + artifactPath;
+ final String url = etsiCatalogManagerEndpoint + "/vnf_packages/" + vnfPkgId + "/artifacts/" + artifactPath;
logger.info("getVnfPackageArtifactUrl: {}", url);
return url;
}
@@ -99,7 +95,7 @@ public class EtsiCatalogUrlProvider {
* @return the URL for the GET operation
*/
public String getVnfPackageVnfdUrl(final String vnfPkgId) {
- final String url = msbEndpoint + vnfpkgmServiceUrl + "/vnf_packages/" + vnfPkgId + "/vnfd";
+ final String url = etsiCatalogManagerEndpoint + "/vnf_packages/" + vnfPkgId + "/vnfd";
logger.info("getEtsiCatalogVnfPackageVnfd: {}", url);
return url;
}
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/Sol003PackageManagementControllerTest.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/Sol003PackageManagementControllerTest.java
index f596b2ecde..c5194cf27e 100644
--- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/Sol003PackageManagementControllerTest.java
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/Sol003PackageManagementControllerTest.java
@@ -82,7 +82,7 @@ public class Sol003PackageManagementControllerTest {
private static final String VNF_PACKAGE_ID = "myVnfPackageId";
private static final String ARTIFACT_PATH = "myArtifactPath";
- private static final String MSB_BASE_URL = "http://msb_iag.onap:80/api/vnfpkgm/v1/vnf_packages";
+ private static final String MSB_BASE_URL = "http://msb-iag.onap:80/api/vnfpkgm/v1/vnf_packages";
private static final String VNFPKGM_BASE_URL = PACKAGE_MANAGEMENT_BASE_URL + "/vnf_packages";
private static final String localhostUrl = "http://localhost:";
private static final String GET_VNF_PACKAGES_URL = "";
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/Sol003SubscriptionManagementControllerTest.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/Sol003SubscriptionManagementControllerTest.java
index 8fc27c5943..ed1880035a 100644
--- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/Sol003SubscriptionManagementControllerTest.java
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/Sol003SubscriptionManagementControllerTest.java
@@ -34,14 +34,13 @@ public class Sol003SubscriptionManagementControllerTest {
@Autowired
@Qualifier(CONFIGURABLE_REST_TEMPLATE)
private RestTemplate testRestTemplate;
- private MockRestServiceServer mockRestServer;
@Autowired
private Sol003SubscriptionManagementController controller;
@Before
public void setUp() throws Exception {
- mockRestServer = MockRestServiceServer.bindTo(testRestTemplate).build();
+ MockRestServiceServer.bindTo(testRestTemplate).build();
}
@Test
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/resources/application.yaml b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/resources/application.yaml
index 6f5769c6a7..ae66464f29 100644
--- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/resources/application.yaml
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/resources/application.yaml
@@ -54,3 +54,7 @@ management:
prometheus:
enabled: true # Whether exporting of metrics to Prometheus is enabled.
step: 1m # Step size (i.e. reporting frequency) to use.
+
+etsi-catalog-manager:
+ vnfpkgm:
+ endpoint: http://msb-iag.onap:80/api/vnfpkgm/v1
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/entities/ServiceModel.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/entities/ServiceModel.java
new file mode 100644
index 0000000000..51bc4d7064
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/entities/ServiceModel.java
@@ -0,0 +1,32 @@
+package org.onap.so.bpmn.servicedecomposition.entities;
+
+import org.onap.so.db.catalog.beans.Service;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonRootName;
+
+@JsonRootName("serviceModel")
+public class ServiceModel {
+
+ @JsonProperty("currentService")
+ private Service currentService;
+ @JsonProperty("newService")
+ private Service newService;
+
+
+ public Service getCurrentService() {
+ return currentService;
+ }
+
+ public void setCurrentService(Service currentService) {
+ this.currentService = currentService;
+ }
+
+ public Service getNewService() {
+ return newService;
+ }
+
+ public void setNewService(Service newService) {
+ this.newService = newService;
+ }
+
+}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java
index 6afceac78f..ac66fb1a41 100644
--- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java
@@ -46,6 +46,7 @@ import org.onap.so.bpmn.servicedecomposition.entities.ConfigurationResourceKeys;
import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock;
import org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock;
import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
+import org.onap.so.bpmn.servicedecomposition.entities.ServiceModel;
import org.onap.so.bpmn.servicedecomposition.entities.WorkflowResourceIds;
import org.onap.so.bpmn.servicedecomposition.generalobjects.OrchestrationContext;
import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext;
@@ -242,7 +243,9 @@ public class BBInputSetup implements JavaDelegate {
String bbName = executeBB.getBuildingBlock().getBpmnFlowName();
String serviceInstanceId = lookupKeyMap.get(ResourceKey.SERVICE_INSTANCE_ID);
org.onap.aai.domain.yang.ServiceInstance aaiServiceInstance = null;
+ ServiceModel serviceModel = new ServiceModel();
Service service = null;
+ Service newService = null;
boolean isReplace = false;
if (serviceInstanceId != null) {
aaiServiceInstance = bbInputSetupUtils.getAAIServiceInstanceById(serviceInstanceId);
@@ -254,20 +257,27 @@ public class BBInputSetup implements JavaDelegate {
for (RelatedInstanceList relatedInstList : relatedInstanceList) {
RelatedInstance relatedInstance = relatedInstList.getRelatedInstance();
if (relatedInstance.getModelInfo().getModelType().equals(ModelType.service)) {
- service = bbInputSetupUtils.getCatalogServiceByModelUUID(
+ newService = bbInputSetupUtils.getCatalogServiceByModelUUID(
relatedInstance.getModelInfo().getModelVersionId());
isReplace = true;
}
}
}
- } else {
- service = bbInputSetupUtils.getCatalogServiceByModelUUID(aaiServiceInstance.getModelVersionId());
}
+
+ service = bbInputSetupUtils.getCatalogServiceByModelUUID(aaiServiceInstance.getModelVersionId());
+
+ serviceModel.setNewService(newService);
+ serviceModel.setCurrentService(service);
+
if (service == null) {
String message = String.format(
"Related service instance model not found in MSO CatalogDB: model-version-id=%s",
aaiServiceInstance.getModelVersionId());
throw new ServiceModelNotFoundException(message);
+ } else if (newService == null && isReplace) {
+ String message = "Related service instance model in Request not found in MSO CatalogDB";
+ throw new ServiceModelNotFoundException(message);
}
} else {
String message = String.format("Related service instance from AAI not found: service-instance-id=%s",
@@ -277,10 +287,16 @@ public class BBInputSetup implements JavaDelegate {
}
ServiceInstance serviceInstance = this.getExistingServiceInstance(aaiServiceInstance);
- serviceInstance.setModelInfoServiceInstance(this.mapperLayer.mapCatalogServiceIntoServiceInstance(service));
+ if (isReplace) {
+ serviceInstance.setModelInfoServiceInstance(
+ this.mapperLayer.mapCatalogServiceIntoServiceInstance(serviceModel.getNewService()));
+ } else {
+ serviceInstance.setModelInfoServiceInstance(
+ this.mapperLayer.mapCatalogServiceIntoServiceInstance(serviceModel.getCurrentService()));
+ }
this.populateObjectsOnAssignAndCreateFlows(requestDetails, service, bbName, serviceInstance, lookupKeyMap,
resourceId, vnfType, executeBB.getBuildingBlock().getKey(), executeBB.getConfigurationResourceKeys(),
- isReplace);
+ isReplace, serviceModel);
return this.populateGBBWithSIAndAdditionalInfo(requestDetails, serviceInstance, executeBB, requestAction, null);
}
@@ -342,8 +358,8 @@ public class BBInputSetup implements JavaDelegate {
protected void populateObjectsOnAssignAndCreateFlows(RequestDetails requestDetails, Service service, String bbName,
ServiceInstance serviceInstance, Map<ResourceKey, String> lookupKeyMap, String resourceId, String vnfType,
- String configurationKey, ConfigurationResourceKeys configurationResourceKeys, boolean isReplace)
- throws Exception {
+ String configurationKey, ConfigurationResourceKeys configurationResourceKeys, boolean isReplace,
+ ServiceModel serviceModel) throws Exception {
ModelInfo modelInfo = requestDetails.getModelInfo();
String instanceName = requestDetails.getRequestInfo().getInstanceName();
String productFamilyId = requestDetails.getRequestInfo().getProductFamilyId();
@@ -381,7 +397,8 @@ public class BBInputSetup implements JavaDelegate {
} else {
lookupKeyMap.put(ResourceKey.VF_MODULE_ID, resourceId);
this.populateVfModule(modelInfo, service, bbName, serviceInstance, lookupKeyMap, resourceId,
- relatedInstanceList, instanceName, null, requestDetails.getCloudConfiguration(), isReplace);
+ relatedInstanceList, instanceName, null, requestDetails.getCloudConfiguration(), isReplace,
+ serviceModel);
}
} else if (modelType.equals(ModelType.instanceGroup)) {
lookupKeyMap.put(ResourceKey.INSTANCE_GROUP_ID, resourceId);
@@ -511,7 +528,7 @@ public class BBInputSetup implements JavaDelegate {
protected void populateVfModule(ModelInfo modelInfo, Service service, String bbName,
ServiceInstance serviceInstance, Map<ResourceKey, String> lookupKeyMap, String resourceId,
RelatedInstanceList[] relatedInstanceList, String instanceName, List<Map<String, String>> instanceParams,
- CloudConfiguration cloudConfiguration, boolean isReplace) throws Exception {
+ CloudConfiguration cloudConfiguration, boolean isReplace, ServiceModel serviceModel) throws Exception {
String replaceVnfModelCustomizationUUID = null;
String vnfModelCustomizationUUID = null;
if (relatedInstanceList != null) {
@@ -536,8 +553,13 @@ public class BBInputSetup implements JavaDelegate {
vnfModelCustomizationUUID =
this.bbInputSetupUtils.getAAIGenericVnf(vnf.getVnfId()).getModelCustomizationId();
ModelInfo vnfModelInfo = new ModelInfo();
- vnfModelInfo.setModelCustomizationUuid(vnfModelCustomizationUUID);
- this.mapCatalogVnf(tempVnf, vnfModelInfo, service);
+ if (isReplace) {
+ vnfModelInfo.setModelCustomizationUuid(replaceVnfModelCustomizationUUID);
+ this.mapCatalogVnf(tempVnf, vnfModelInfo, serviceModel.getNewService());
+ } else {
+ vnfModelInfo.setModelCustomizationUuid(vnfModelCustomizationUUID);
+ this.mapCatalogVnf(tempVnf, vnfModelInfo, serviceModel.getCurrentService());
+ }
Optional<String> volumeGroupIdOp = getVolumeGroupIdRelatedToVfModule(tempVnf, modelInfo,
cloudConfiguration.getCloudOwner(), cloudConfiguration.getLcpCloudRegionId(), lookupKeyMap);
if (volumeGroupIdOp.isPresent()) {
@@ -559,18 +581,22 @@ public class BBInputSetup implements JavaDelegate {
modelInfoVfModule.setModelCustomizationId(vfModuleCustId);
if (isReplace && lookupKeyMap.get(ResourceKey.VF_MODULE_ID) != null
&& vfModuleTemp.getVfModuleId().equalsIgnoreCase(lookupKeyMap.get(ResourceKey.VF_MODULE_ID))) {
- mapCatalogVfModule(vfModuleTemp, modelInfoVfModule, service, replaceVnfModelCustomizationUUID);
+ mapCatalogVfModule(vfModuleTemp, modelInfoVfModule, serviceModel.getNewService(),
+ replaceVnfModelCustomizationUUID);
} else {
- mapCatalogVfModule(vfModuleTemp, modelInfoVfModule, service, vnfModelCustomizationUUID);
+ mapCatalogVfModule(vfModuleTemp, modelInfoVfModule, serviceModel.getCurrentService(),
+ vnfModelCustomizationUUID);
}
}
if (vfModule == null && bbName.equalsIgnoreCase(AssignFlows.VF_MODULE.toString())) {
vfModule = createVfModule(lookupKeyMap, resourceId, instanceName, instanceParams);
vnf.getVfModules().add(vfModule);
if (isReplace) {
- mapCatalogVfModule(vfModule, modelInfo, service, replaceVnfModelCustomizationUUID);
+ mapCatalogVfModule(vfModule, modelInfo, serviceModel.getNewService(),
+ replaceVnfModelCustomizationUUID);
} else {
- mapCatalogVfModule(vfModule, modelInfo, service, vnfModelCustomizationUUID);
+ mapCatalogVfModule(vfModule, modelInfo, serviceModel.getCurrentService(),
+ vnfModelCustomizationUUID);
}
}
} else {
@@ -1476,8 +1502,10 @@ public class BBInputSetup implements JavaDelegate {
CloudConfiguration cloudConfig = new CloudConfiguration();
cloudConfig.setLcpCloudRegionId(cloudRegion.getLcpCloudRegionId());
cloudConfig.setCloudOwner(cloudRegion.getCloudOwner());
+ ServiceModel serviceModel = new ServiceModel();
+ serviceModel.setCurrentService(service);
this.populateVfModule(modelInfo, service, bbName, serviceInstance, lookupKeyMap, vfModuleId, null,
- vfModules.getInstanceName(), vfModules.getInstanceParams(), cloudConfig, false);
+ vfModules.getInstanceName(), vfModules.getInstanceParams(), cloudConfig, false, serviceModel);
}
} else if (bbName.contains(NETWORK)) {
networks = findNetworksByKey(key, resources);
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java
index 517bdfffb8..e0ee918ead 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java
@@ -79,6 +79,7 @@ import org.onap.so.bpmn.servicedecomposition.entities.ConfigurationResourceKeys;
import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock;
import org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock;
import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
+import org.onap.so.bpmn.servicedecomposition.entities.ServiceModel;
import org.onap.so.bpmn.servicedecomposition.entities.WorkflowResourceIds;
import org.onap.so.bpmn.servicedecomposition.generalobjects.OrchestrationContext;
import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext;
@@ -445,6 +446,8 @@ public class BBInputSetupTest {
Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
String requestAction = "createInstance";
Service service = Mockito.mock(Service.class);
+ ServiceModel serviceModel = new ServiceModel();
+ serviceModel.setCurrentService(service);
ServiceInstance serviceInstance = Mockito.mock(ServiceInstance.class);
String resourceId = "123";
String vnfType = "vnfType";
@@ -456,8 +459,9 @@ public class BBInputSetupTest {
.getCatalogServiceByModelUUID(aaiServiceInstance.getModelVersionId());
doReturn(aaiServiceInstance).when(SPY_bbInputSetupUtils).getAAIServiceInstanceById("instanceId");
- doNothing().when(SPY_bbInputSetup).populateObjectsOnAssignAndCreateFlows(requestDetails, service, "bbName",
- serviceInstance, lookupKeyMap, resourceId, vnfType, null, null, false);
+ doNothing().when(SPY_bbInputSetup).populateObjectsOnAssignAndCreateFlows(eq(requestDetails), eq(service),
+ eq("bbName"), eq(serviceInstance), eq(lookupKeyMap), eq(resourceId), eq(vnfType), eq(null), eq(null),
+ eq(false), isA(ServiceModel.class));
doReturn(serviceInstance).when(SPY_bbInputSetup).getExistingServiceInstance(aaiServiceInstance);
doReturn(expected).when(SPY_bbInputSetup).populateGBBWithSIAndAdditionalInfo(requestDetails, serviceInstance,
executeBB, requestAction, null);
@@ -469,6 +473,51 @@ public class BBInputSetupTest {
}
@Test
+ public void testGetGBBALaCarteNonServiceIsReplace() throws Exception {
+ GeneralBuildingBlock expected = mapper.readValue(new File(RESOURCE_PATH + "GeneralBuildingBlockExpected.json"),
+ GeneralBuildingBlock.class);
+ ExecuteBuildingBlock executeBB = mapper.readValue(new File(RESOURCE_PATH + "ExecuteBuildingBlockSimple.json"),
+ ExecuteBuildingBlock.class);
+ RequestDetails requestDetails = mapper.readValue(
+ new File(RESOURCE_PATH + "RequestDetailsInput_withRelatedInstanceList.json"), RequestDetails.class);
+ Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
+ String requestAction = "replaceInstance";
+ Service service = Mockito.mock(Service.class);
+ ServiceModel serviceModel = new ServiceModel();
+ serviceModel.setCurrentService(service);
+ ServiceInstance serviceInstance = Mockito.mock(ServiceInstance.class);
+ String resourceId = "123";
+ String vnfType = "vnfType";
+ org.onap.aai.domain.yang.ServiceInstance aaiServiceInstance = new org.onap.aai.domain.yang.ServiceInstance();
+ aaiServiceInstance.setModelVersionId("modelVersionId");
+ org.onap.aai.domain.yang.CloudRegion aaiCloudRegion = Mockito.mock(org.onap.aai.domain.yang.CloudRegion.class);
+ lookupKeyMap.put(ResourceKey.SERVICE_INSTANCE_ID, "instanceId");
+ doReturn(service).when(SPY_bbInputSetupUtils)
+ .getCatalogServiceByModelUUID(aaiServiceInstance.getModelVersionId());
+ doReturn(service).when(SPY_bbInputSetupUtils).getCatalogServiceByModelUUID("modelUUID");
+ doReturn(aaiServiceInstance).when(SPY_bbInputSetupUtils).getAAIServiceInstanceById("instanceId");
+
+ doNothing().when(SPY_bbInputSetup).populateObjectsOnAssignAndCreateFlows(eq(requestDetails), eq(service),
+ eq("bbName"), eq(serviceInstance), eq(lookupKeyMap), eq(resourceId), eq(vnfType), eq(null), eq(null),
+ eq(true), isA(ServiceModel.class));
+ doReturn(serviceInstance).when(SPY_bbInputSetup).getExistingServiceInstance(aaiServiceInstance);
+ doReturn(expected).when(SPY_bbInputSetup).populateGBBWithSIAndAdditionalInfo(requestDetails, serviceInstance,
+ executeBB, requestAction, null);
+
+ GeneralBuildingBlock actual = SPY_bbInputSetup.getGBBALaCarteNonService(executeBB, requestDetails, lookupKeyMap,
+ requestAction, resourceId, vnfType);
+
+ verify(SPY_bbInputSetup, times(1)).populateObjectsOnAssignAndCreateFlows(eq(requestDetails), eq(service),
+ eq("bbName"), eq(serviceInstance), eq(lookupKeyMap), eq(resourceId), eq(vnfType), eq(null), eq(null),
+ eq(true), isA(ServiceModel.class));
+
+ verify(SPY_bbInputSetupUtils, times(1)).getCatalogServiceByModelUUID(aaiServiceInstance.getModelVersionId());
+ verify(SPY_bbInputSetupUtils, times(1)).getCatalogServiceByModelUUID("modelUUID");
+
+ assertThat(actual, sameBeanAs(expected));
+ }
+
+ @Test
public void testGetGBBALaCarteNonServiceWithoutServiceModelInfo() throws Exception {
ExecuteBuildingBlock executeBB = mapper.readValue(new File(RESOURCE_PATH + "ExecuteBuildingBlockSimple.json"),
ExecuteBuildingBlock.class);
@@ -527,6 +576,8 @@ public class BBInputSetupTest {
Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
String requestAction = "createInstance";
Service service = Mockito.mock(Service.class);
+ ServiceModel serviceModel = new ServiceModel();
+ serviceModel.setCurrentService(service);
String resourceId = "123";
ServiceInstance serviceInstance = Mockito.mock(ServiceInstance.class);
org.onap.aai.domain.yang.ServiceInstance aaiServiceInstance = new org.onap.aai.domain.yang.ServiceInstance();
@@ -538,8 +589,9 @@ public class BBInputSetupTest {
.getCatalogServiceByModelUUID(aaiServiceInstance.getModelVersionId());
doReturn(aaiServiceInstance).when(SPY_bbInputSetupUtils).getAAIServiceInstanceById("instanceId");
- doNothing().when(SPY_bbInputSetup).populateObjectsOnAssignAndCreateFlows(requestDetails, service, "bbName",
- serviceInstance, lookupKeyMap, resourceId, vnfType, null, null, false);
+ doNothing().when(SPY_bbInputSetup).populateObjectsOnAssignAndCreateFlows(eq(requestDetails), eq(service),
+ eq("bbName"), eq(serviceInstance), eq(lookupKeyMap), eq(resourceId), eq(vnfType), eq(null), eq(null),
+ eq(false), isA(ServiceModel.class));
doReturn(serviceInstance).when(SPY_bbInputSetup).getExistingServiceInstance(aaiServiceInstance);
doReturn(expected).when(SPY_bbInputSetup).populateGBBWithSIAndAdditionalInfo(requestDetails, serviceInstance,
@@ -818,6 +870,8 @@ public class BBInputSetupTest {
String productFamilyId = "productFamilyId";
String applicationId = "applicationId";
Service service = Mockito.mock(Service.class);
+ ServiceModel serviceModel = new ServiceModel();
+ serviceModel.setCurrentService(service);
ServiceInstance serviceInstance = Mockito.mock(ServiceInstance.class);
RequestDetails requestDetails = Mockito.mock(RequestDetails.class);
ModelInfo modelInfo = Mockito.mock(ModelInfo.class);
@@ -844,7 +898,7 @@ public class BBInputSetupTest {
doReturn(ModelType.network).when(modelInfo).getModelType();
SPY_bbInputSetup.populateObjectsOnAssignAndCreateFlows(requestDetails, service, bbName, serviceInstance,
- lookupKeyMap, resourceId, vnfType, null, null, false);
+ lookupKeyMap, resourceId, vnfType, null, null, false, serviceModel);
verify(SPY_bbInputSetup, times(1)).populateL3Network(instanceName, modelInfo, service, bbName, serviceInstance,
lookupKeyMap, resourceId, null);
assertEquals("NetworkId populated", true,
@@ -858,7 +912,7 @@ public class BBInputSetupTest {
productFamilyId, applicationId, false);
SPY_bbInputSetup.populateObjectsOnAssignAndCreateFlows(requestDetails, service, bbName, serviceInstance,
- lookupKeyMap, resourceId, vnfType, null, null, false);
+ lookupKeyMap, resourceId, vnfType, null, null, false, serviceModel);
verify(SPY_bbInputSetup, times(1)).populateGenericVnf(modelInfo, instanceName, platform, lineOfBusiness,
service, bbName, serviceInstance, lookupKeyMap, relatedInstanceList, resourceId, vnfType, null,
productFamilyId, applicationId, false);
@@ -870,7 +924,7 @@ public class BBInputSetupTest {
doNothing().when(SPY_bbInputSetup).populateVolumeGroup(modelInfo, service, bbName, serviceInstance,
lookupKeyMap, resourceId, relatedInstanceList, instanceName, vnfType, null);
SPY_bbInputSetup.populateObjectsOnAssignAndCreateFlows(requestDetails, service, bbName, serviceInstance,
- lookupKeyMap, resourceId, vnfType, null, null, false);
+ lookupKeyMap, resourceId, vnfType, null, null, false, serviceModel);
verify(SPY_bbInputSetup, times(1)).populateVolumeGroup(modelInfo, service, bbName, serviceInstance,
lookupKeyMap, resourceId, relatedInstanceList, instanceName, vnfType, null);
assertEquals("VolumeGroupId populated", true,
@@ -879,11 +933,11 @@ public class BBInputSetupTest {
doReturn(ModelType.vfModule).when(modelInfo).getModelType();
resourceId = "vfModuleId";
doNothing().when(SPY_bbInputSetup).populateVfModule(modelInfo, service, bbName, serviceInstance, lookupKeyMap,
- resourceId, relatedInstanceList, instanceName, null, cloudConfiguration, false);
+ resourceId, relatedInstanceList, instanceName, null, cloudConfiguration, false, serviceModel);
SPY_bbInputSetup.populateObjectsOnAssignAndCreateFlows(requestDetails, service, bbName, serviceInstance,
- lookupKeyMap, resourceId, vnfType, null, null, false);
+ lookupKeyMap, resourceId, vnfType, null, null, false, serviceModel);
verify(SPY_bbInputSetup, times(1)).populateVfModule(modelInfo, service, bbName, serviceInstance, lookupKeyMap,
- resourceId, relatedInstanceList, instanceName, null, cloudConfiguration, false);
+ resourceId, relatedInstanceList, instanceName, null, cloudConfiguration, false, serviceModel);
assertEquals("VfModuleId populated", true,
lookupKeyMap.get(ResourceKey.VF_MODULE_ID).equalsIgnoreCase(resourceId));
@@ -893,7 +947,7 @@ public class BBInputSetupTest {
doNothing().when(SPY_bbInputSetup).populateVolumeGroup(modelInfo, service, bbNameAssignVolume, serviceInstance,
lookupKeyMap, resourceId, relatedInstanceList, instanceName, vnfType, null);
SPY_bbInputSetup.populateObjectsOnAssignAndCreateFlows(requestDetails, service, bbNameAssignVolume,
- serviceInstance, lookupKeyMap, resourceId, vnfType, null, null, false);
+ serviceInstance, lookupKeyMap, resourceId, vnfType, null, null, false, serviceModel);
verify(SPY_bbInputSetup, times(1)).populateVolumeGroup(modelInfo, service, bbNameAssignVolume, serviceInstance,
lookupKeyMap, resourceId, relatedInstanceList, instanceName, vnfType, null);
assertEquals("VolumeGroupId populated", true,
@@ -2023,7 +2077,7 @@ public class BBInputSetupTest {
SPY_bbInputSetup.getGBBMacro(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType);
verify(SPY_bbInputSetup, times(1)).populateVfModule(isA(ModelInfo.class), isA(Service.class), any(String.class),
isA(ServiceInstance.class), any(), any(String.class), any(), any(String.class), any(),
- isA(CloudConfiguration.class), Mockito.anyBoolean());
+ isA(CloudConfiguration.class), Mockito.anyBoolean(), isA(ServiceModel.class));
lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, null);
executeBB.getBuildingBlock().setBpmnFlowName(AssignFlows.VOLUME_GROUP.toString());
@@ -2306,7 +2360,7 @@ public class BBInputSetupTest {
SPY_bbInputSetup.getGBBMacro(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType);
verify(SPY_bbInputSetup, times(1)).populateVfModule(isA(ModelInfo.class), isA(Service.class), any(String.class),
isA(ServiceInstance.class), any(), any(String.class), any(), any(String.class), any(),
- isA(CloudConfiguration.class), Mockito.anyBoolean());
+ isA(CloudConfiguration.class), Mockito.anyBoolean(), isA(ServiceModel.class));
lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, null);
executeBB.getBuildingBlock().setBpmnFlowName(AssignFlows.VOLUME_GROUP.toString());
@@ -2371,7 +2425,7 @@ public class BBInputSetupTest {
SPY_bbInputSetup.getGBBMacro(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType);
verify(SPY_bbInputSetup, times(1)).populateVfModule(isA(ModelInfo.class), isA(Service.class), any(String.class),
isA(ServiceInstance.class), any(), any(String.class), any(), any(String.class), any(),
- isA(CloudConfiguration.class), Mockito.anyBoolean());
+ isA(CloudConfiguration.class), Mockito.anyBoolean(), isA(ServiceModel.class));
lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, null);
executeBB.getBuildingBlock().setBpmnFlowName(AssignFlows.VOLUME_GROUP.toString());
@@ -2945,6 +2999,8 @@ public class BBInputSetupTest {
ModelInfo modelInfo = new ModelInfo();
modelInfo.setModelCustomizationId(vfModuleCustomizationId);
Service service = new Service();
+ ServiceModel serviceModel = new ServiceModel();
+ serviceModel.setCurrentService(service);
String bbName = AssignFlows.VF_MODULE.toString();
ServiceInstance serviceInstance = new ServiceInstance();
GenericVnf vnf = new GenericVnf();
@@ -2984,7 +3040,7 @@ public class BBInputSetupTest {
isA(Service.class), isA(String.class));
SPY_bbInputSetup.populateVfModule(modelInfo, service, bbName, serviceInstance, lookupKeyMap, resourceId,
- relatedInstanceList, instanceName, instanceParams, cloudConfiguration, false);
+ relatedInstanceList, instanceName, instanceParams, cloudConfiguration, false, serviceModel);
verify(SPY_bbInputSetup, times(3)).mapCatalogVfModule(isA(VfModule.class), isA(ModelInfo.class),
isA(Service.class), isA(String.class));
@@ -3002,7 +3058,13 @@ public class BBInputSetupTest {
String vfModuleCustomizationId = "vfModuleCustomizationId";
ModelInfo modelInfo = new ModelInfo();
modelInfo.setModelCustomizationId(vfModuleCustomizationId);
- Service service = new Service();
+ Service currentService = new Service();
+ currentService.setModelUUID("currentUUID");
+ Service newService = new Service();
+ newService.setModelUUID("newUUID");
+ ServiceModel serviceModel = new ServiceModel();
+ serviceModel.setCurrentService(currentService);
+ serviceModel.setNewService(newService);
String bbName = "ActivateVfModuleBB";
ServiceInstance serviceInstance = new ServiceInstance();
GenericVnf vnf = new GenericVnf();
@@ -3053,13 +3115,13 @@ public class BBInputSetupTest {
doNothing().when(SPY_bbInputSetup).mapCatalogVfModule(isA(VfModule.class), isA(ModelInfo.class),
isA(Service.class), isA(String.class));
- SPY_bbInputSetup.populateVfModule(modelInfo, service, bbName, serviceInstance, lookupKeyMap, resourceId,
- relatedInstanceList, instanceName, instanceParams, cloudConfiguration, true);
+ SPY_bbInputSetup.populateVfModule(modelInfo, newService, bbName, serviceInstance, lookupKeyMap, resourceId,
+ relatedInstanceList, instanceName, instanceParams, cloudConfiguration, true, serviceModel);
verify(SPY_bbInputSetup, times(1)).mapCatalogVfModule(isA(VfModule.class), isA(ModelInfo.class),
- isA(Service.class), eq("vnfModelCustId"));
- verify(SPY_bbInputSetup, times(1)).mapCatalogVfModule(isA(VfModule.class), isA(ModelInfo.class),
- isA(Service.class), eq("vnfCustomizationId"));
+ eq(currentService), eq("vnfModelCustId"));
+ verify(SPY_bbInputSetup, times(1)).mapCatalogVfModule(isA(VfModule.class), isA(ModelInfo.class), eq(newService),
+ eq("vnfCustomizationId"));
assertEquals("Lookup Key Map populated with VfModule Id", "vfModuleId1",
lookupKeyMap.get(ResourceKey.VF_MODULE_ID));
assertEquals("Lookup Key Map populated with VolumeGroup Id", volumeGroupId,
@@ -3074,7 +3136,13 @@ public class BBInputSetupTest {
String vfModuleCustomizationId = "vfModuleCustomizationId";
ModelInfo modelInfo = new ModelInfo();
modelInfo.setModelCustomizationId(vfModuleCustomizationId);
- Service service = new Service();
+ Service currentService = new Service();
+ Service newService = new Service();
+ ServiceModel serviceModel = new ServiceModel();
+ serviceModel.setCurrentService(currentService);
+ currentService.setModelUUID("currentUUID");
+ serviceModel.setNewService(newService);
+ currentService.setModelUUID("newUUID");
String bbName = AssignFlows.VF_MODULE.toString();
ServiceInstance serviceInstance = new ServiceInstance();
GenericVnf vnf = new GenericVnf();
@@ -3091,6 +3159,7 @@ public class BBInputSetupTest {
vnf.getVfModules().add(vfModule2);
Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, vnfId);
+ lookupKeyMap.put(ResourceKey.VF_MODULE_ID, vfModuleId);
String resourceId = vfModuleId;
RelatedInstanceList[] relatedInstanceList = new RelatedInstanceList[1];
RelatedInstanceList relatedInstanceListObj = new RelatedInstanceList();
@@ -3124,11 +3193,13 @@ public class BBInputSetupTest {
doNothing().when(SPY_bbInputSetup).mapCatalogVfModule(isA(VfModule.class), isA(ModelInfo.class),
isA(Service.class), isA(String.class));
- SPY_bbInputSetup.populateVfModule(modelInfo, service, bbName, serviceInstance, lookupKeyMap, resourceId,
- relatedInstanceList, instanceName, instanceParams, cloudConfiguration, true);
+ SPY_bbInputSetup.populateVfModule(modelInfo, newService, bbName, serviceInstance, lookupKeyMap, resourceId,
+ relatedInstanceList, instanceName, instanceParams, cloudConfiguration, true, serviceModel);
- verify(SPY_bbInputSetup, times(3)).mapCatalogVfModule(isA(VfModule.class), isA(ModelInfo.class),
- isA(Service.class), isA(String.class));
+ verify(SPY_bbInputSetup, times(2)).mapCatalogVfModule(isA(VfModule.class), isA(ModelInfo.class),
+ eq(serviceModel.getCurrentService()), isA(String.class));
+ verify(SPY_bbInputSetup, times(1)).mapCatalogVfModule(isA(VfModule.class), isA(ModelInfo.class),
+ eq(serviceModel.getNewService()), isA(String.class));
assertEquals("Lookup Key Map populated with VfModule Id", vfModuleId,
lookupKeyMap.get(ResourceKey.VF_MODULE_ID));
assertEquals("Lookup Key Map populated with VolumeGroup Id", volumeGroupId,
diff --git a/common/src/main/java/org/onap/so/utils/CryptoUtils.java b/common/src/main/java/org/onap/so/utils/CryptoUtils.java
index ff69e3e4b1..1c38dfb774 100644
--- a/common/src/main/java/org/onap/so/utils/CryptoUtils.java
+++ b/common/src/main/java/org/onap/so/utils/CryptoUtils.java
@@ -76,6 +76,8 @@ public final class CryptoUtils {
* @throws GeneralSecurityException
*/
public static String decrypt(String message, String keyString) throws GeneralSecurityException {
+ if (message.equals(System.getenv("PLAINTEXTPASSWORD")))
+ return message;
SecretKeySpec sks = getSecretKeySpec(keyString);
byte[] cipherText = hexStringToByteArray(message);
Cipher cipher = Cipher.getInstance(AES_GCM_NO_PADDING);