summaryrefslogtreecommitdiffstats
path: root/bpmn
diff options
context:
space:
mode:
authorMax Benjamin <max.benjamin@att.com>2020-01-22 14:11:13 +0000
committerGerrit Code Review <gerrit@onap.org>2020-01-22 14:11:13 +0000
commit66781db64d1839f283ce99278393f2c65baf9263 (patch)
tree81645f586d0727181c3552a8a605ab3766d344b1 /bpmn
parentd9691b0c73b0d9cace84ca1ed7b0a30ccecc3fbd (diff)
parent48fbeba2e552d6de26ed1f638ec7736c35d18019 (diff)
Merge "Add fluent setters for BuildingBlocks and ExecuteBuildingBlock"
Diffstat (limited to 'bpmn')
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/entities/BuildingBlock.java30
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/entities/ExecuteBuildingBlock.java43
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java2
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayer.java12
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/BBPojoTest.java2
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/entities/ExecuteBuildingBlockTest.java53
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupExistingServiceTest.java139
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupPopulateMethodsTest.java283
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java825
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BaseBBInputSetupTestHelper.java47
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BuildingBlockTest.java68
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildingBlockRainyDayTest.java (renamed from bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildlingBlockRainyDayTest.java)11
-rw-r--r--bpmn/MSOCommonBPMN/src/test/resources/__files/BuildingBlock/BuildingBlockAllParameters.json9
-rw-r--r--bpmn/MSOCommonBPMN/src/test/resources/__files/BuildingBlock/BuildingBlockSimple.json4
-rw-r--r--bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/ExecuteBuildingBlockExtended.json8
-rw-r--r--bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/GeneralBuildingBlockWithVnf.json127
-rw-r--r--bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/ExecuteBuildingBlockTest.java16
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/activity/ExecuteActivity.java34
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java99
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java21
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBFailureTest.java6
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksTest.java261
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksUpdateReqDbTest.java12
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java101
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/MultiStageSkipListenerTest.java10
25 files changed, 1397 insertions, 826 deletions
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/entities/BuildingBlock.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/entities/BuildingBlock.java
index c1591ad984..aa1d845ef8 100644
--- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/entities/BuildingBlock.java
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/entities/BuildingBlock.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -27,7 +27,7 @@ import com.fasterxml.jackson.annotation.JsonRootName;
@JsonRootName("buildingBlock")
public class BuildingBlock implements Serializable {
- private static final long serialVersionUID = -1144315411128866052L;
+ private static final long serialVersionUID = -1144315411128866053L;
@JsonProperty("mso-id")
private String msoId;
@@ -48,56 +48,62 @@ public class BuildingBlock implements Serializable {
return bpmnFlowName;
}
- public void setBpmnFlowName(String bpmnFlowName) {
+ public BuildingBlock setBpmnFlowName(String bpmnFlowName) {
this.bpmnFlowName = bpmnFlowName;
+ return this;
}
public String getMsoId() {
return msoId;
}
- public void setMsoId(String msoId) {
+ public BuildingBlock setMsoId(String msoId) {
this.msoId = msoId;
+ return this;
}
public String getKey() {
return key;
}
- public void setKey(String key) {
+ public BuildingBlock setKey(String key) {
this.key = key;
+ return this;
}
- public Boolean getIsVirtualLink() {
+ public Boolean isVirtualLink() {
return isVirtualLink;
}
- public void setIsVirtualLink(Boolean isVirtualLink) {
+ public BuildingBlock setIsVirtualLink(Boolean isVirtualLink) {
this.isVirtualLink = isVirtualLink;
+ return this;
}
public String getVirtualLinkKey() {
return virtualLinkKey;
}
- public void setVirtualLinkKey(String virtualLinkKey) {
+ public BuildingBlock setVirtualLinkKey(String virtualLinkKey) {
this.virtualLinkKey = virtualLinkKey;
+ return this;
}
public String getBpmnScope() {
return bpmnScope;
}
- public void setBpmnScope(String scope) {
+ public BuildingBlock setBpmnScope(String scope) {
this.bpmnScope = scope;
+ return this;
}
public String getBpmnAction() {
return bpmnAction;
}
- public void setBpmnAction(String action) {
+ public BuildingBlock setBpmnAction(String action) {
this.bpmnAction = action;
+ return this;
}
-
}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/entities/ExecuteBuildingBlock.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/entities/ExecuteBuildingBlock.java
index f1de0cc6f6..abd301fa4d 100644
--- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/entities/ExecuteBuildingBlock.java
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/entities/ExecuteBuildingBlock.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -24,10 +24,8 @@ import java.io.Serializable;
import org.onap.so.serviceinstancebeans.RequestDetails;
public class ExecuteBuildingBlock implements Serializable {
- /**
- *
- */
- private static final long serialVersionUID = 1L;
+
+ private static final long serialVersionUID = 2L;
private BuildingBlock buildingBlock;
private String requestId;
private String apiVersion;
@@ -44,87 +42,98 @@ public class ExecuteBuildingBlock implements Serializable {
return buildingBlock;
}
- public void setBuildingBlock(BuildingBlock buildingBlock) {
+ public ExecuteBuildingBlock setBuildingBlock(BuildingBlock buildingBlock) {
this.buildingBlock = buildingBlock;
+ return this;
}
public String getRequestId() {
return requestId;
}
- public void setRequestId(String requestId) {
+ public ExecuteBuildingBlock setRequestId(String requestId) {
this.requestId = requestId;
+ return this;
}
public String getApiVersion() {
return apiVersion;
}
- public void setApiVersion(String apiVersion) {
+ public ExecuteBuildingBlock setApiVersion(String apiVersion) {
this.apiVersion = apiVersion;
+ return this;
}
public String getResourceId() {
return resourceId;
}
- public void setResourceId(String resourceId) {
+ public ExecuteBuildingBlock setResourceId(String resourceId) {
this.resourceId = resourceId;
+ return this;
}
public String getRequestAction() {
return requestAction;
}
- public void setRequestAction(String requestAction) {
+ public ExecuteBuildingBlock setRequestAction(String requestAction) {
this.requestAction = requestAction;
+ return this;
}
public Boolean isaLaCarte() {
return aLaCarte;
}
- public void setaLaCarte(Boolean aLaCarte) {
+ public ExecuteBuildingBlock setaLaCarte(Boolean aLaCarte) {
this.aLaCarte = aLaCarte;
+ return this;
}
public String getVnfType() {
return vnfType;
}
- public void setVnfType(String vnfType) {
+ public ExecuteBuildingBlock setVnfType(String vnfType) {
this.vnfType = vnfType;
+ return this;
}
public Boolean isHoming() {
return homing;
}
- public void setHoming(Boolean homing) {
+ public ExecuteBuildingBlock setHoming(Boolean homing) {
this.homing = homing;
+ return this;
}
public WorkflowResourceIds getWorkflowResourceIds() {
return workflowResourceIds;
}
- public void setWorkflowResourceIds(WorkflowResourceIds workflowResourceIds) {
+ public ExecuteBuildingBlock setWorkflowResourceIds(WorkflowResourceIds workflowResourceIds) {
this.workflowResourceIds = workflowResourceIds;
+ return this;
}
public RequestDetails getRequestDetails() {
return requestDetails;
}
- public void setRequestDetails(RequestDetails requestDetails) {
+ public ExecuteBuildingBlock setRequestDetails(RequestDetails requestDetails) {
this.requestDetails = requestDetails;
+ return this;
}
public ConfigurationResourceKeys getConfigurationResourceKeys() {
return configurationResourceKeys;
}
- public void setConfigurationResourceKeys(ConfigurationResourceKeys configurationResourceKeys) {
+ public ExecuteBuildingBlock setConfigurationResourceKeys(ConfigurationResourceKeys configurationResourceKeys) {
this.configurationResourceKeys = configurationResourceKeys;
+ return this;
}
}
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 ac66fb1a41..8293cbc10e 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
@@ -1189,7 +1189,7 @@ public class BBInputSetup implements JavaDelegate {
if (bbName.contains(NETWORK) && !bbName.contains(NETWORK_COLLECTION)) {
String networkId = lookupKeyMap.get(ResourceKey.NETWORK_ID);
ModelInfo networkModelInfo = new ModelInfo();
- if ((!Boolean.TRUE.equals(executeBB.getBuildingBlock().getIsVirtualLink()))) {
+ if ((!Boolean.TRUE.equals(executeBB.getBuildingBlock().isVirtualLink()))) {
NetworkResourceCustomization networkCust = getNetworkCustomizationByKey(key, service);
if (networkCust != null) {
networkModelInfo.setModelCustomizationUuid(networkCust.getModelCustomizationUUID());
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayer.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayer.java
index ea48c78dc0..28ec71b13f 100644
--- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayer.java
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayer.java
@@ -22,12 +22,6 @@
package org.onap.so.bpmn.servicedecomposition.tasks;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Optional;
import org.modelmapper.ModelMapper;
import org.modelmapper.convention.MatchingStrategies;
import org.onap.so.bpmn.servicedecomposition.bbobjects.AggregateRoute;
@@ -92,6 +86,12 @@ import org.onap.so.serviceinstancebeans.RequestDetails;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
@Component("BBInputSetupMapperLayer")
public class BBInputSetupMapperLayer {
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/BBPojoTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/BBPojoTest.java
index d7c5ec9d55..14bae82dde 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/BBPojoTest.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/BBPojoTest.java
@@ -20,7 +20,6 @@
package org.onap.so.bpmn.servicedecomposition;
-import org.junit.Test;
import com.openpojo.reflection.PojoClass;
import com.openpojo.reflection.PojoClassFilter;
import com.openpojo.reflection.filters.FilterNonConcrete;
@@ -32,6 +31,7 @@ import com.openpojo.validation.rule.impl.NoPrimitivesRule;
import com.openpojo.validation.rule.impl.SerializableMustHaveSerialVersionUIDRule;
import com.openpojo.validation.test.impl.GetterTester;
import com.openpojo.validation.test.impl.SetterTester;
+import org.junit.Test;
public class BBPojoTest {
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/entities/ExecuteBuildingBlockTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/entities/ExecuteBuildingBlockTest.java
new file mode 100644
index 0000000000..c8699d66e7
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/entities/ExecuteBuildingBlockTest.java
@@ -0,0 +1,53 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2020 Nokia Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.so.bpmn.servicedecomposition.entities;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.junit.Test;
+import java.io.File;
+import java.io.IOException;
+import static org.assertj.core.api.Assertions.assertThat;
+
+public class ExecuteBuildingBlockTest {
+ private static final String RESOURCE_PATH = "src/test/resources/__files/ExecuteBuildingBlock/";
+ private ObjectMapper mapper = new ObjectMapper();
+
+ @Test
+ public void should_properlyDeserializeGivenJsonFile() throws IOException {
+ // given
+ // when
+ ExecuteBuildingBlock resultEBB = mapper.readValue(new File(RESOURCE_PATH + "ExecuteBuildingBlockExtended.json"),
+ ExecuteBuildingBlock.class);
+ BuildingBlock resultBB = resultEBB.getBuildingBlock();
+ // then
+ assertThat(resultBB.getMsoId()).isEqualTo("msoId");
+ assertThat(resultBB.getBpmnFlowName()).isEqualTo("bbName");
+ assertThat(resultEBB.getRequestId()).isEqualTo("requestId");
+ assertThat(resultEBB.isaLaCarte()).isTrue();
+ assertThat(resultEBB.getApiVersion()).isNull();
+ assertThat(resultEBB.getResourceId()).isNull();
+ assertThat(resultEBB.getRequestAction()).isNull();
+ assertThat(resultEBB.getVnfType()).isNull();
+ assertThat(resultEBB.isHoming()).isFalse();
+ assertThat(resultEBB.getWorkflowResourceIds()).isNull();
+ assertThat(resultEBB.getRequestDetails()).isNull();
+ assertThat(resultEBB.getConfigurationResourceKeys()).isNull();
+ }
+}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupExistingServiceTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupExistingServiceTest.java
new file mode 100644
index 0000000000..fbb67cb923
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupExistingServiceTest.java
@@ -0,0 +1,139 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2020 Nokia Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.bpmn.servicedecomposition.tasks;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.MockitoAnnotations;
+import org.mockito.Spy;
+import org.onap.aai.domain.yang.CloudRegion;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
+import org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock;
+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.db.catalog.beans.Service;
+import org.onap.so.serviceinstancebeans.CloudConfiguration;
+import org.onap.so.serviceinstancebeans.RequestDetails;
+import java.io.File;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Map;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.isA;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.onap.so.bpmn.servicedecomposition.tasks.BaseBBInputSetupTestHelper.prepareLookupKeyMap;
+
+@RunWith(Parameterized.class)
+public class BBInputSetupExistingServiceTest {
+ private String requestAction;
+ private String bpmnFlowName;
+ private String key;
+ private static final String RESOURCE_PATH = "src/test/resources/__files/ExecuteBuildingBlock/";
+
+ protected ObjectMapper mapper = new ObjectMapper();
+
+ @Spy
+ @InjectMocks
+ private BBInputSetup SPY_bbInputSetup = new BBInputSetup();
+
+ @Mock
+ private BBInputSetupUtils bbInputSetupUtils;
+
+ @Mock
+ private BBInputSetupMapperLayer bbInputSetupMapperLayer;
+
+ @Rule
+ public ExpectedException expectedException = ExpectedException.none();
+
+ public BBInputSetupExistingServiceTest(String requestAction, String bpmnFlowName, String key) {
+ this.requestAction = requestAction;
+ this.bpmnFlowName = bpmnFlowName;
+ this.key = key;
+ }
+
+ @Before
+ public void setup() {
+ MockitoAnnotations.initMocks(this);
+ }
+
+ @Parameterized.Parameters
+ public static Collection input() {
+ return Arrays
+ .asList(new Object[][] {{"deleteInstance", "DeleteNetworkBB", "ab153b6e-c364-44c0-bef6-1f2982117f04"},
+ {"activateInstance", "ActivateNetworkBB", "ab153b6e-c364-44c0-bef6-1f2982117f04"},
+ {"unassignInstance", "UnassignNetworkBB", "ab153b6e-c364-44c0-bef6-1f2982117f04"},
+ {"activateFabricConfiguration", "ActivateFabricConfigurationBB",
+ "ab153b6e-c364-44c0-bef6-134534656234"}});
+ }
+
+ @Test
+ public void test_getGBBMacro_getGBBMacroExistingService_shouldBeCalled() throws Exception {
+ // given
+ String resourceId = "123";
+ String vnfType = "vnfType";
+ String requestAction = this.requestAction;
+ Service service = Mockito.mock(Service.class);
+ GeneralBuildingBlock gBB = mapper.readValue(new File(RESOURCE_PATH + "GeneralBuildingBlockExpected.json"),
+ GeneralBuildingBlock.class);
+ ServiceInstance serviceInstance = gBB.getServiceInstance();
+ Map<ResourceKey, String> lookupKeyMap = prepareLookupKeyMap();
+ org.onap.aai.domain.yang.ServiceInstance aaiServiceInstance = new org.onap.aai.domain.yang.ServiceInstance();
+ aaiServiceInstance.setModelVersionId("modelVersionId");
+ CloudConfiguration cloudConfig = new CloudConfiguration();
+ cloudConfig.setLcpCloudRegionId("lcpCloudRegionId");
+ CloudRegion aaiCloudRegion = Mockito.mock(CloudRegion.class);
+
+ RequestDetails requestDetails = mapper
+ .readValue(new File(RESOURCE_PATH + "RequestDetailsInput_serviceMacro.json"), RequestDetails.class);
+ requestDetails.getRequestParameters().setUserParams(null);
+ requestDetails.setCloudConfiguration(cloudConfig);
+ ExecuteBuildingBlock executeBB = mapper.readValue(new File(RESOURCE_PATH + "ExecuteBuildingBlockSimple.json"),
+ ExecuteBuildingBlock.class);
+ executeBB.setRequestDetails(requestDetails);
+ BuildingBlock buildingBlock = executeBB.getBuildingBlock();
+ buildingBlock.setBpmnFlowName(this.bpmnFlowName).setKey(this.key);
+
+ doReturn(service).when(bbInputSetupUtils).getCatalogServiceByModelUUID(aaiServiceInstance.getModelVersionId());
+ doReturn(aaiServiceInstance).when(bbInputSetupUtils)
+ .getAAIServiceInstanceById(lookupKeyMap.get(ResourceKey.SERVICE_INSTANCE_ID));
+ doReturn(serviceInstance).when(SPY_bbInputSetup).getExistingServiceInstance(aaiServiceInstance);
+ doReturn(gBB).when(SPY_bbInputSetup).populateGBBWithSIAndAdditionalInfo(requestDetails, serviceInstance,
+ executeBB, requestAction, null);
+ doReturn(aaiCloudRegion).when(bbInputSetupUtils).getCloudRegion(requestDetails.getCloudConfiguration());
+ // when
+ SPY_bbInputSetup.getGBBMacro(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType);
+ // then
+ verify(SPY_bbInputSetup, times(1)).getGBBMacroExistingService(isA(ExecuteBuildingBlock.class), any(),
+ any(String.class), isA(String.class), isA(CloudConfiguration.class));
+ }
+}
+
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupPopulateMethodsTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupPopulateMethodsTest.java
new file mode 100644
index 0000000000..7d45b643e3
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupPopulateMethodsTest.java
@@ -0,0 +1,283 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2020 Nokia Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.so.bpmn.servicedecomposition.tasks;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.mockito.ArgumentMatchers;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.MockitoAnnotations;
+import org.mockito.Spy;
+import org.onap.aai.domain.yang.GenericVnf;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
+import org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock;
+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.db.catalog.beans.ConfigurationResourceCustomization;
+import org.onap.so.db.catalog.beans.Service;
+import org.onap.so.db.request.beans.InfraActiveRequests;
+import org.onap.so.serviceinstancebeans.CloudConfiguration;
+import org.onap.so.serviceinstancebeans.ModelInfo;
+import org.onap.so.serviceinstancebeans.RequestDetails;
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.ArgumentMatchers.isA;
+import static org.mockito.Mockito.doNothing;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.onap.so.bpmn.servicedecomposition.tasks.BaseBBInputSetupTestHelper.prepareConfigurationResourceKeys;
+import static org.onap.so.bpmn.servicedecomposition.tasks.BaseBBInputSetupTestHelper.prepareLookupKeyMap;
+
+@RunWith(Parameterized.class)
+public class BBInputSetupPopulateMethodsTest {
+ private static final String RESOURCE_PATH = "src/test/resources/__files/ExecuteBuildingBlock/";
+
+ private String resourceId;
+ private String requestAction;
+ private Service service;
+ private String vnfType;
+
+ protected ObjectMapper mapper = new ObjectMapper();
+
+ @Spy
+ @InjectMocks
+ private BBInputSetup SPY_bbInputSetup = new BBInputSetup();
+
+ @Mock
+ private BBInputSetupUtils bbInputSetupUtils;
+
+ @Spy
+ private BBInputSetupMapperLayer SPY_bbInputSetupMapperLayer;
+
+ @Rule
+ public ExpectedException expectedException = ExpectedException.none();
+
+ public BBInputSetupPopulateMethodsTest(String vnfType) {
+ this.vnfType = vnfType;
+ }
+
+ @Before
+ public void setup() {
+ MockitoAnnotations.initMocks(this);
+ }
+
+ @Parameterized.Parameters
+ public static Collection input() {
+ return Arrays.asList(new Object[] {"vnfType", null});
+ }
+
+ @Before
+ public void init() {
+ resourceId = "123";
+ requestAction = "createInstance";
+ service = Mockito.mock(Service.class);
+ }
+
+ @Test
+ public void test_getGBBMacro_populateL3Network_shouldBeCalled() throws Exception {
+ // given
+ GeneralBuildingBlock gBB = mapper.readValue(new File(RESOURCE_PATH + "GeneralBuildingBlockExpected.json"),
+ GeneralBuildingBlock.class);
+ Map<ResourceKey, String> lookupKeyMap = prepareLookupKeyMap();
+
+ ConfigurationResourceKeys configResourceKeys = prepareConfigurationResourceKeys();
+ RequestDetails requestDetails = mapper
+ .readValue(new File(RESOURCE_PATH + "RequestDetailsInput_serviceMacro.json"), RequestDetails.class);
+ ExecuteBuildingBlock executeBB = mapper.readValue(new File(RESOURCE_PATH + "ExecuteBuildingBlockSimple.json"),
+ ExecuteBuildingBlock.class);
+ executeBB.setConfigurationResourceKeys(configResourceKeys).setRequestDetails(requestDetails);
+ BuildingBlock buildingBlock = executeBB.getBuildingBlock();
+ buildingBlock.setBpmnFlowName(AssignFlows.NETWORK_MACRO.toString())
+ .setKey("ab153b6e-c364-44c0-bef6-1f2982117f04");
+
+ doReturn(gBB).when(SPY_bbInputSetup).getGBBALaCarteService(executeBB, requestDetails, lookupKeyMap,
+ requestAction, lookupKeyMap.get(ResourceKey.SERVICE_INSTANCE_ID));
+ doReturn(service).when(bbInputSetupUtils)
+ .getCatalogServiceByModelUUID(gBB.getServiceInstance().getModelInfoServiceInstance().getModelUuid());
+ // when
+ SPY_bbInputSetup.getGBBMacro(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType);
+ // then
+ verify(SPY_bbInputSetup, times(1)).populateL3Network(any(String.class), isA(ModelInfo.class),
+ isA(Service.class), any(String.class), isA(ServiceInstance.class), any(), any(String.class), any());
+ }
+
+ @Test
+ public void test_getGBBMacro_populateGenericVnf_shouldBeCalled() throws Exception {
+ // given
+ GeneralBuildingBlock gBB = mapper.readValue(new File(RESOURCE_PATH + "GeneralBuildingBlockExpected.json"),
+ GeneralBuildingBlock.class);
+ RequestDetails requestDetails = mapper
+ .readValue(new File(RESOURCE_PATH + "RequestDetailsInput_serviceMacro.json"), RequestDetails.class);
+ InfraActiveRequests request = Mockito.mock(InfraActiveRequests.class);
+ GenericVnf aaiVnf = new GenericVnf();
+ aaiVnf.setModelCustomizationId("modelCustId");
+ Map<ResourceKey, String> lookupKeyMap = prepareLookupKeyMap();
+
+ ExecuteBuildingBlock executeBB = mapper.readValue(new File(RESOURCE_PATH + "ExecuteBuildingBlockSimple.json"),
+ ExecuteBuildingBlock.class);
+ BuildingBlock buildingBlock = executeBB.getBuildingBlock();
+ buildingBlock.setBpmnFlowName(AssignFlows.VNF.toString()).setKey("ab153b6e-c364-44c0-bef6-1f2982117f04");
+
+ doReturn(gBB).when(SPY_bbInputSetup).getGBBALaCarteService(executeBB, requestDetails, lookupKeyMap,
+ requestAction, lookupKeyMap.get(ResourceKey.SERVICE_INSTANCE_ID));
+ doReturn(request).when(bbInputSetupUtils).getInfraActiveRequest(executeBB.getRequestId());
+ doReturn(service).when(bbInputSetupUtils)
+ .getCatalogServiceByModelUUID(gBB.getServiceInstance().getModelInfoServiceInstance().getModelUuid());
+ doNothing().when(bbInputSetupUtils).updateInfraActiveRequestVnfId(request,
+ lookupKeyMap.get(ResourceKey.GENERIC_VNF_ID));
+ doReturn(aaiVnf).when(bbInputSetupUtils).getAAIGenericVnf(any(String.class));
+
+ // when
+ SPY_bbInputSetup.getGBBMacro(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType);
+ // then
+ verify(SPY_bbInputSetup, times(1)).populateGenericVnf(isA(ModelInfo.class), any(String.class),
+ isA(org.onap.so.serviceinstancebeans.Platform.class),
+ isA(org.onap.so.serviceinstancebeans.LineOfBusiness.class), isA(Service.class), any(String.class),
+ isA(ServiceInstance.class), any(), any(), any(String.class), eq(vnfType), any(), any(String.class),
+ any(String.class), eq(false));
+ }
+
+ @Test
+ public void test_getGBBMacro_populateVfModule_shouldBeCalled() throws Exception {
+ // given
+ GeneralBuildingBlock gBB = mapper.readValue(new File(RESOURCE_PATH + "GeneralBuildingBlockWithVnf.json"),
+ GeneralBuildingBlock.class);
+ RequestDetails requestDetails = mapper
+ .readValue(new File(RESOURCE_PATH + "RequestDetailsInput_serviceMacro.json"), RequestDetails.class);
+ GenericVnf aaiVnf = new GenericVnf();
+ aaiVnf.setModelCustomizationId("modelCustId");
+ Map<ResourceKey, String> lookupKeyMap = prepareLookupKeyMap();
+ lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, null);
+
+ ConfigurationResourceKeys configResourceKeys = prepareConfigurationResourceKeys();
+ ExecuteBuildingBlock executeBB = mapper.readValue(new File(RESOURCE_PATH + "ExecuteBuildingBlockSimple.json"),
+ ExecuteBuildingBlock.class);
+ executeBB.setConfigurationResourceKeys(configResourceKeys).setRequestDetails(requestDetails);
+ BuildingBlock buildingBlock = executeBB.getBuildingBlock();
+ buildingBlock.setBpmnFlowName(AssignFlows.VF_MODULE.toString()).setKey("a25e8e8c-58b8-4eec-810c-97dcc1f5cb7f");
+
+ doReturn(gBB).when(SPY_bbInputSetup).getGBBALaCarteService(executeBB, requestDetails, lookupKeyMap,
+ requestAction, lookupKeyMap.get(ResourceKey.SERVICE_INSTANCE_ID));
+ doReturn(service).when(bbInputSetupUtils)
+ .getCatalogServiceByModelUUID(gBB.getServiceInstance().getModelInfoServiceInstance().getModelUuid());
+ doReturn("vnfId").when(SPY_bbInputSetup).getVnfId(executeBB, lookupKeyMap);
+ doReturn(aaiVnf).when(bbInputSetupUtils).getAAIGenericVnf(any(String.class));
+ // when
+ SPY_bbInputSetup.getGBBMacro(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType);
+ // then
+ 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(ServiceModel.class));
+ }
+
+ @Test
+ public void test_getGBBMacro_populateVolumeGroup_shouldBeCalled() throws Exception {
+ // given
+ GeneralBuildingBlock gBB = mapper.readValue(new File(RESOURCE_PATH + "GeneralBuildingBlockWithVnf.json"),
+ GeneralBuildingBlock.class);
+ RequestDetails requestDetails = mapper
+ .readValue(new File(RESOURCE_PATH + "RequestDetailsInput_serviceMacro.json"), RequestDetails.class);
+ GenericVnf aaiVnf = new GenericVnf();
+ aaiVnf.setModelCustomizationId("modelCustId");
+ Map<ResourceKey, String> lookupKeyMap = prepareLookupKeyMap();
+ lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, null);
+
+ ExecuteBuildingBlock executeBB = mapper.readValue(new File(RESOURCE_PATH + "ExecuteBuildingBlockSimple.json"),
+ ExecuteBuildingBlock.class);
+ BuildingBlock buildingBlock = executeBB.getBuildingBlock();
+ buildingBlock.setBpmnFlowName(AssignFlows.VOLUME_GROUP.toString())
+ .setKey("72d9d1cd-f46d-447a-abdb-451d6fb05fa8");
+
+ doReturn(gBB).when(SPY_bbInputSetup).getGBBALaCarteService(executeBB, requestDetails, lookupKeyMap,
+ requestAction, lookupKeyMap.get(ResourceKey.SERVICE_INSTANCE_ID));
+ doReturn(service).when(bbInputSetupUtils)
+ .getCatalogServiceByModelUUID(gBB.getServiceInstance().getModelInfoServiceInstance().getModelUuid());
+ doReturn("vnfId").when(SPY_bbInputSetup).getVnfId(executeBB, lookupKeyMap);
+ doReturn(aaiVnf).when(bbInputSetupUtils).getAAIGenericVnf(any(String.class));
+ // when
+ SPY_bbInputSetup.getGBBMacro(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType);
+ // then
+ verify(SPY_bbInputSetup, times(1)).populateVolumeGroup(isA(ModelInfo.class), isA(Service.class),
+ any(String.class), isA(ServiceInstance.class), any(), any(String.class), ArgumentMatchers.isNull(),
+ ArgumentMatchers.isNull(), eq(vnfType), any());
+ }
+
+ @Test
+ public void test_getGBBMacro_populateConfiguration_shouldBeCalled() throws Exception {
+ // given
+ String requestAction = "createInstance";
+ Service service = Mockito.mock(Service.class);
+ GeneralBuildingBlock gBB = mapper.readValue(new File(RESOURCE_PATH + "GeneralBuildingBlockExpected.json"),
+ GeneralBuildingBlock.class);
+ RequestDetails requestDetails = mapper
+ .readValue(new File(RESOURCE_PATH + "RequestDetailsInput_serviceMacro.json"), RequestDetails.class);
+ GenericVnf aaiVnf = new GenericVnf();
+ aaiVnf.setModelCustomizationId("modelCustId");
+ Map<ResourceKey, String> lookupKeyMap = prepareLookupKeyMap();
+
+ ConfigurationResourceKeys configResourceKeys = prepareConfigurationResourceKeys();
+ ExecuteBuildingBlock executeBB = mapper.readValue(new File(RESOURCE_PATH + "ExecuteBuildingBlockSimple.json"),
+ ExecuteBuildingBlock.class);
+ executeBB.setConfigurationResourceKeys(configResourceKeys).setRequestDetails(requestDetails);
+ BuildingBlock buildingBlock = executeBB.getBuildingBlock();
+ buildingBlock.setBpmnFlowName("AssignFabricConfigurationBB").setKey("72d9d1cd-f46d-447a-abdb-451d6fb05fa9");
+
+ Configuration configuration = new Configuration();
+ configuration.setConfigurationId("configurationId");
+ gBB.getServiceInstance().getConfigurations().add(configuration);
+ List<ConfigurationResourceCustomization> configurationCustList = new ArrayList<>();
+ ConfigurationResourceCustomization configurationCust = new ConfigurationResourceCustomization();
+ configurationCust.setModelCustomizationUUID("72d9d1cd-f46d-447a-abdb-451d6fb05fa9");
+ configurationCustList.add(configurationCust);
+
+ doReturn(configurationCustList).when(service).getConfigurationCustomizations();
+ doReturn(gBB).when(SPY_bbInputSetup).getGBBALaCarteService(executeBB, requestDetails, lookupKeyMap,
+ requestAction, lookupKeyMap.get(ResourceKey.SERVICE_INSTANCE_ID));
+ doReturn(service).when(bbInputSetupUtils)
+ .getCatalogServiceByModelUUID(gBB.getServiceInstance().getModelInfoServiceInstance().getModelUuid());
+ doNothing().when(SPY_bbInputSetup).populateConfiguration(isA(ModelInfo.class), isA(Service.class),
+ any(String.class), isA(ServiceInstance.class), any(), any(String.class), ArgumentMatchers.isNull(),
+ isA(ConfigurationResourceKeys.class), isA(RequestDetails.class));
+ // when
+ SPY_bbInputSetup.getGBBMacro(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType);
+ // then
+ verify(SPY_bbInputSetup, times(1)).populateConfiguration(isA(ModelInfo.class), isA(Service.class),
+ any(String.class), isA(ServiceInstance.class), any(), any(String.class), ArgumentMatchers.isNull(),
+ isA(ConfigurationResourceKeys.class), isA(RequestDetails.class));
+ }
+}
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 e0ee918ead..16cdb7a3e9 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
@@ -6,6 +6,8 @@
* ================================================================================
* Modifications Copyright (c) 2019 Samsung
* ================================================================================
+ * Modifications Copyright (c) 2020 Nokia
+ * ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@@ -22,30 +24,12 @@
package org.onap.so.bpmn.servicedecomposition.tasks;
-import static com.shazam.shazamcrest.MatcherAssert.assertThat;
-import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.eq;
-import static org.mockito.ArgumentMatchers.isA;
-import static org.mockito.Mockito.doNothing;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Optional;
+import com.fasterxml.jackson.core.JsonParseException;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.JsonMappingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.junit.Assert;
-import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
@@ -114,7 +98,6 @@ import org.onap.so.db.catalog.beans.VfModuleCustomization;
import org.onap.so.db.catalog.beans.VnfResourceCustomization;
import org.onap.so.db.catalog.beans.VnfcInstanceGroupCustomization;
import org.onap.so.db.request.beans.InfraActiveRequests;
-import org.onap.so.db.request.client.RequestsDbClient;
import org.onap.so.serviceinstancebeans.CloudConfiguration;
import org.onap.so.serviceinstancebeans.ModelInfo;
import org.onap.so.serviceinstancebeans.ModelType;
@@ -125,10 +108,28 @@ import org.onap.so.serviceinstancebeans.RequestInfo;
import org.onap.so.serviceinstancebeans.RequestParameters;
import org.onap.so.serviceinstancebeans.Resources;
import org.onap.so.serviceinstancebeans.SubscriberInfo;
-import com.fasterxml.jackson.core.JsonParseException;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.JsonMappingException;
-import com.fasterxml.jackson.databind.ObjectMapper;
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import static com.shazam.shazamcrest.MatcherAssert.assertThat;
+import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.ArgumentMatchers.isA;
+import static org.mockito.Mockito.doNothing;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.onap.so.bpmn.servicedecomposition.tasks.BaseBBInputSetupTestHelper.prepareConfigurationResourceKeys;
+import static org.onap.so.bpmn.servicedecomposition.tasks.BaseBBInputSetupTestHelper.prepareLookupKeyMap;
@RunWith(MockitoJUnitRunner.class)
public class BBInputSetupTest {
@@ -136,7 +137,6 @@ public class BBInputSetupTest {
protected ObjectMapper mapper = new ObjectMapper();
private static final String CLOUD_OWNER = "CloudOwner";
- private static final String REQUEST_ID = "b20bbd26-af25-4a50-a9fe-222a3c0f9771";
@Spy
@InjectMocks
@@ -151,19 +151,9 @@ public class BBInputSetupTest {
@Spy
private BBInputSetupMapperLayer bbInputSetupMapperLayer;
- @Mock
- private RequestsDbClient requestsDbClient;
-
@Rule
public ExpectedException expectedException = ExpectedException.none();
- @Before
- public void setup() {
- SPY_bbInputSetup.setBbInputSetupUtils(SPY_bbInputSetupUtils);
- SPY_bbInputSetup.setMapperLayer(bbInputSetupMapperLayer);
- SPY_bbInputSetup.setCloudInfoFromAAI(SPY_cloudInfoFromAAI);
- }
-
@Test
public void testGetVolumeGroupIdRelatedToVfModule() {
String expected = "volumeGroupId";
@@ -292,7 +282,7 @@ public class BBInputSetupTest {
}
@Test
- public void testSetHomingFlag() throws JsonParseException, JsonMappingException, IOException {
+ public void testSetHomingFlag() throws IOException {
GeneralBuildingBlock expected = mapper.readValue(new File(RESOURCE_PATH + "GeneralBuildingBlockExpected.json"),
GeneralBuildingBlock.class);
Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
@@ -315,11 +305,9 @@ public class BBInputSetupTest {
@Test
public void testGetExecuteBBFromExecution() throws IOException {
- ExecuteBuildingBlock expected = new ExecuteBuildingBlock();
- BuildingBlock bb = new BuildingBlock();
- bb.setBpmnFlowName("AssignServiceInstanceBB");
- expected.setBuildingBlock(bb);
- expected.setRequestId("00032ab7-3fb3-42e5-965d-8ea592502017");
+ BuildingBlock bb = new BuildingBlock().setBpmnFlowName("AssignServiceInstanceBB");
+ ExecuteBuildingBlock expected =
+ new ExecuteBuildingBlock().setBuildingBlock(bb).setRequestId("00032ab7-3fb3-42e5-965d-8ea592502017");
DelegateExecution execution = Mockito.mock(DelegateExecution.class);
doReturn(expected).when(execution).getVariable(any(String.class));
ExecuteBuildingBlock actual = SPY_bbInputSetup.getExecuteBBFromExecution(execution);
@@ -331,8 +319,7 @@ public class BBInputSetupTest {
GeneralBuildingBlock expected = mapper.readValue(new File(RESOURCE_PATH + "GeneralBuildingBlockExpected.json"),
GeneralBuildingBlock.class);
- ExecuteBuildingBlock executeBB = new ExecuteBuildingBlock();
- executeBB.setRequestId("requestId");
+ ExecuteBuildingBlock executeBB = new ExecuteBuildingBlock().setRequestId("requestId");
RequestDetails requestDetails = new RequestDetails();
ModelInfo modelInfo = new ModelInfo();
modelInfo.setModelType(ModelType.service);
@@ -360,8 +347,7 @@ public class BBInputSetupTest {
GeneralBuildingBlock expected = mapper
.readValue(new File(RESOURCE_PATH + "GeneralBuildingBlockCMExpected.json"), GeneralBuildingBlock.class);
- ExecuteBuildingBlock executeBB = new ExecuteBuildingBlock();
- executeBB.setRequestId("requestId");
+ ExecuteBuildingBlock executeBB = new ExecuteBuildingBlock().setRequestId("requestId");
RequestDetails requestDetails = new RequestDetails();
requestDetails.setModelInfo(null);
RequestParameters requestParams = new RequestParameters();
@@ -1038,11 +1024,8 @@ public class BBInputSetupTest {
OwningEntity owningEntity = mapper.readValue(new File(RESOURCE_PATH + "OwningEntity.json"), OwningEntity.class);
Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
- ExecuteBuildingBlock executeBB = new ExecuteBuildingBlock();
- executeBB.setaLaCarte(true);
- BuildingBlock buildingBlock = new BuildingBlock();
- buildingBlock.setBpmnFlowName(AssignFlows.SERVICE_INSTANCE.toString());
- executeBB.setBuildingBlock(buildingBlock);
+ BuildingBlock buildingBlock = new BuildingBlock().setBpmnFlowName(AssignFlows.SERVICE_INSTANCE.toString());
+ ExecuteBuildingBlock executeBB = new ExecuteBuildingBlock().setaLaCarte(true).setBuildingBlock(buildingBlock);
RequestDetails requestDetails = new RequestDetails();
RequestInfo reqInfo = new RequestInfo();
reqInfo.setInstanceName("serviceInstanceName");
@@ -1343,10 +1326,7 @@ public class BBInputSetupTest {
Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
lookupKeyMap.put(ResourceKey.CONFIGURATION_ID, "configurationId");
String bbName = AssignFlows.FABRIC_CONFIGURATION.toString();
- ConfigurationResourceKeys configResourceKeys = new ConfigurationResourceKeys();
- configResourceKeys.setCvnfcCustomizationUUID("cvnfcCustomizationUUID");
- configResourceKeys.setVfModuleCustomizationUUID("vfModuleCustomizationUUID");
- configResourceKeys.setVnfResourceCustomizationUUID("vnfResourceCustomizationUUID");
+ ConfigurationResourceKeys configResourceKeys = prepareConfigurationResourceKeys();
configResourceKeys.setVnfcName(vnfcName);
Vnfc vnfc = new Vnfc();
vnfc.setVnfcName(vnfcName);
@@ -1420,10 +1400,7 @@ public class BBInputSetupTest {
Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
lookupKeyMap.put(ResourceKey.CONFIGURATION_ID, "configurationId");
String bbName = AssignFlows.FABRIC_CONFIGURATION.toString();
- ConfigurationResourceKeys configResourceKeys = new ConfigurationResourceKeys();
- configResourceKeys.setCvnfcCustomizationUUID("cvnfcCustomizationUUID");
- configResourceKeys.setVfModuleCustomizationUUID("vfModuleCustomizationUUID");
- configResourceKeys.setVnfResourceCustomizationUUID("vnfResourceCustomizationUUID");
+ ConfigurationResourceKeys configResourceKeys = prepareConfigurationResourceKeys();
configResourceKeys.setVnfcName(vnfcName);
Vnfc vnfc = new Vnfc();
vnfc.setVnfcName(vnfcName);
@@ -2017,122 +1994,25 @@ public class BBInputSetupTest {
}
@Test
- public void testgetGBBMacro() throws Exception {
- GeneralBuildingBlock gBB = 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_serviceMacro.json"), RequestDetails.class);
- InfraActiveRequests request = Mockito.mock(InfraActiveRequests.class);
- org.onap.aai.domain.yang.GenericVnf aaiVnf = new org.onap.aai.domain.yang.GenericVnf();
- aaiVnf.setModelCustomizationId("modelCustId");
- Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
- lookupKeyMap.put(ResourceKey.NETWORK_ID, "networkId");
- lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, "vnfId");
- lookupKeyMap.put(ResourceKey.VF_MODULE_ID, "vfModuleId");
- lookupKeyMap.put(ResourceKey.VOLUME_GROUP_ID, "volumeGroupId");
- lookupKeyMap.put(ResourceKey.SERVICE_INSTANCE_ID, "serviceInstanceId");
- lookupKeyMap.put(ResourceKey.CONFIGURATION_ID, "configurationId");
+ public void testGBBMacroNoUserParamsVrfConfiguration() throws Exception {
String resourceId = "123";
String vnfType = "vnfType";
- Service service = Mockito.mock(Service.class);
String requestAction = "createInstance";
-
- ConfigurationResourceKeys configResourceKeys = new ConfigurationResourceKeys();
- configResourceKeys.setCvnfcCustomizationUUID("cvnfcCustomizationUUID");
- configResourceKeys.setVfModuleCustomizationUUID("vfModuleCustomizationUUID");
- configResourceKeys.setVnfResourceCustomizationUUID("vnfResourceCustomizationUUID");
- executeBB.setConfigurationResourceKeys(configResourceKeys);
- executeBB.setRequestDetails(requestDetails);
- doReturn(gBB).when(SPY_bbInputSetup).getGBBALaCarteService(executeBB, requestDetails, lookupKeyMap,
- requestAction, lookupKeyMap.get(ResourceKey.SERVICE_INSTANCE_ID));
- doReturn(request).when(SPY_bbInputSetupUtils).getInfraActiveRequest(executeBB.getRequestId());
- doReturn(service).when(SPY_bbInputSetupUtils)
- .getCatalogServiceByModelUUID(gBB.getServiceInstance().getModelInfoServiceInstance().getModelUuid());
- doNothing().when(SPY_bbInputSetupUtils).updateInfraActiveRequestVnfId(request,
- lookupKeyMap.get(ResourceKey.GENERIC_VNF_ID));
- doReturn("vnfId").when(SPY_bbInputSetup).getVnfId(executeBB, lookupKeyMap);
- doReturn(aaiVnf).when(SPY_bbInputSetupUtils).getAAIGenericVnf(any(String.class));
-
-
- executeBB.getBuildingBlock().setBpmnFlowName(AssignFlows.NETWORK_MACRO.toString());
- executeBB.getBuildingBlock().setKey("ab153b6e-c364-44c0-bef6-1f2982117f04");
- SPY_bbInputSetup.getGBBMacro(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType);
- verify(SPY_bbInputSetup, times(1)).populateL3Network(any(String.class), isA(ModelInfo.class),
- isA(Service.class), any(String.class), isA(ServiceInstance.class), any(), any(String.class), any());
-
- executeBB.getBuildingBlock().setKey("ab153b6e-c364-44c0-bef6-1f2982117f04");
- executeBB.getBuildingBlock().setBpmnFlowName(AssignFlows.VNF.toString());
- SPY_bbInputSetup.getGBBMacro(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType);
- verify(SPY_bbInputSetup, times(1)).populateGenericVnf(isA(ModelInfo.class), any(String.class),
- isA(org.onap.so.serviceinstancebeans.Platform.class),
- isA(org.onap.so.serviceinstancebeans.LineOfBusiness.class), isA(Service.class), any(String.class),
- isA(ServiceInstance.class), any(), any(), any(String.class), any(String.class), any(),
- any(String.class), any(String.class), Mockito.anyBoolean());
-
- lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, null);
- executeBB.getBuildingBlock().setBpmnFlowName(AssignFlows.VF_MODULE.toString());
- executeBB.getBuildingBlock().setKey("a25e8e8c-58b8-4eec-810c-97dcc1f5cb7f");
- 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(ServiceModel.class));
-
- lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, null);
- executeBB.getBuildingBlock().setBpmnFlowName(AssignFlows.VOLUME_GROUP.toString());
- executeBB.getBuildingBlock().setKey("72d9d1cd-f46d-447a-abdb-451d6fb05fa8");
- SPY_bbInputSetup.getGBBMacro(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType);
- verify(SPY_bbInputSetup, times(1)).populateVolumeGroup(isA(ModelInfo.class), isA(Service.class),
- any(String.class), isA(ServiceInstance.class), any(), any(String.class), ArgumentMatchers.isNull(),
- ArgumentMatchers.isNull(), any(String.class), any());
-
- Configuration configuration = new Configuration();
- configuration.setConfigurationId("configurationId");
- gBB.getServiceInstance().getConfigurations().add(configuration);
- List<ConfigurationResourceCustomization> configurationCustList = new ArrayList<>();
- ConfigurationResourceCustomization configurationCust = new ConfigurationResourceCustomization();
- configurationCust.setModelCustomizationUUID("72d9d1cd-f46d-447a-abdb-451d6fb05fa9");
- doReturn(configurationCustList).when(service).getConfigurationCustomizations();
- configurationCustList.add(configurationCust);
- doNothing().when(SPY_bbInputSetup).populateConfiguration(isA(ModelInfo.class), isA(Service.class),
- any(String.class), isA(ServiceInstance.class), any(), any(String.class), ArgumentMatchers.isNull(),
- isA(ConfigurationResourceKeys.class), isA(RequestDetails.class));
-
- executeBB.getBuildingBlock().setBpmnFlowName("AssignFabricConfigurationBB");
- executeBB.getBuildingBlock().setKey("72d9d1cd-f46d-447a-abdb-451d6fb05fa9");
- SPY_bbInputSetup.getGBBMacro(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType);
- verify(SPY_bbInputSetup, times(1)).populateConfiguration(isA(ModelInfo.class), isA(Service.class),
- any(String.class), isA(ServiceInstance.class), any(), any(String.class), ArgumentMatchers.isNull(),
- isA(ConfigurationResourceKeys.class), isA(RequestDetails.class));
-
-
- }
-
- @Test
- public void testGBBMacroNoUserParamsVrfConfiguration() throws Exception {
+ Service service = Mockito.mock(Service.class);
GeneralBuildingBlock gBB = 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_serviceMacroVrf.json"), RequestDetails.class);
- InfraActiveRequests request = Mockito.mock(InfraActiveRequests.class);
- Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
- lookupKeyMap.put(ResourceKey.SERVICE_INSTANCE_ID, "serviceInstanceId");
- lookupKeyMap.put(ResourceKey.CONFIGURATION_ID, "configurationId");
- String resourceId = "123";
- String vnfType = "vnfType";
- Service service = Mockito.mock(Service.class);
- String requestAction = "createInstance";
+ Map<ResourceKey, String> lookupKeyMap = prepareLookupKeyMap();
- ConfigurationResourceKeys configResourceKeys = new ConfigurationResourceKeys();
- configResourceKeys.setCvnfcCustomizationUUID("cvnfcCustomizationUUID");
- configResourceKeys.setVfModuleCustomizationUUID("vfModuleCustomizationUUID");
- configResourceKeys.setVnfResourceCustomizationUUID("vnfResourceCustomizationUUID");
- executeBB.setConfigurationResourceKeys(configResourceKeys);
+ ConfigurationResourceKeys configResourceKeys = prepareConfigurationResourceKeys();
+ executeBB.setConfigurationResourceKeys(configResourceKeys).setRequestDetails(requestDetails);
+ BuildingBlock buildingBlock = executeBB.getBuildingBlock();
+ buildingBlock.setBpmnFlowName("AssignVrfConfigurationBB");
+ buildingBlock.setKey("72d9d1cd-f46d-447a-abdb-451d6fb05fa9");
- executeBB.setRequestDetails(requestDetails);
doReturn(gBB).when(SPY_bbInputSetup).getGBBALaCarteService(executeBB, requestDetails, lookupKeyMap,
requestAction, lookupKeyMap.get(ResourceKey.SERVICE_INSTANCE_ID));
doReturn(service).when(SPY_bbInputSetupUtils)
@@ -2174,8 +2054,6 @@ public class BBInputSetupTest {
any(String.class), isA(ServiceInstance.class), any(), any(String.class), ArgumentMatchers.isNull(),
isA(ConfigurationResourceKeys.class), isA(RequestDetails.class));
- executeBB.getBuildingBlock().setBpmnFlowName("AssignVrfConfigurationBB");
- executeBB.getBuildingBlock().setKey("72d9d1cd-f46d-447a-abdb-451d6fb05fa9");
gBB = SPY_bbInputSetup.getGBBMacro(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType);
verify(SPY_bbInputSetup, times(1)).populateConfiguration(isA(ModelInfo.class), isA(Service.class),
any(String.class), isA(ServiceInstance.class), any(), any(String.class), ArgumentMatchers.isNull(),
@@ -2253,6 +2131,10 @@ public class BBInputSetupTest {
@Test
public void testgetGBBMacroWithEmptyUserParams() throws Exception {
+ String resourceId = "123";
+ String vnfType = "vnfType";
+ String requestAction = "createInstance";
+ Service service = Mockito.mock(Service.class);
GeneralBuildingBlock gBB = mapper.readValue(new File(RESOURCE_PATH + "GeneralBuildingBlockExpected.json"),
GeneralBuildingBlock.class);
ExecuteBuildingBlock executeBB = mapper.readValue(new File(RESOURCE_PATH + "ExecuteBuildingBlockSimple.json"),
@@ -2260,28 +2142,18 @@ public class BBInputSetupTest {
RequestDetails requestDetails = mapper
.readValue(new File(RESOURCE_PATH + "RequestDetailsInput_serviceMacro.json"), RequestDetails.class);
requestDetails.getRequestParameters().getUserParams().clear();
- InfraActiveRequests request = Mockito.mock(InfraActiveRequests.class);
org.onap.aai.domain.yang.GenericVnf aaiVnf = new org.onap.aai.domain.yang.GenericVnf();
aaiVnf.setModelCustomizationId("modelCustId");
- Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
- lookupKeyMap.put(ResourceKey.NETWORK_ID, "networkId");
- lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, "vnfId");
- lookupKeyMap.put(ResourceKey.VF_MODULE_ID, "vfModuleId");
- lookupKeyMap.put(ResourceKey.VOLUME_GROUP_ID, "volumeGroupId");
- lookupKeyMap.put(ResourceKey.SERVICE_INSTANCE_ID, "serviceInstanceId");
- String resourceId = "123";
- String vnfType = "vnfType";
- Service service = Mockito.mock(Service.class);
- String requestAction = "createInstance";
+ Map<ResourceKey, String> lookupKeyMap = prepareLookupKeyMap();
+ BuildingBlock buildingBlock = executeBB.getBuildingBlock();
+ buildingBlock.setBpmnFlowName(AssignFlows.NETWORK_MACRO.toString())
+ .setKey("ab153b6e-c364-44c0-bef6-1f2982117f04").setIsVirtualLink(false);
doReturn(gBB).when(SPY_bbInputSetup).getGBBALaCarteService(executeBB, requestDetails, lookupKeyMap,
requestAction, lookupKeyMap.get(ResourceKey.SERVICE_INSTANCE_ID));
doReturn(service).when(SPY_bbInputSetupUtils)
.getCatalogServiceByModelUUID(gBB.getServiceInstance().getModelInfoServiceInstance().getModelUuid());
- executeBB.getBuildingBlock().setBpmnFlowName(AssignFlows.NETWORK_MACRO.toString());
- executeBB.getBuildingBlock().setKey("ab153b6e-c364-44c0-bef6-1f2982117f04");
- executeBB.getBuildingBlock().setIsVirtualLink(Boolean.FALSE);
SPY_bbInputSetup.getGBBMacro(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType);
verify(SPY_bbInputSetup, times(1)).getGBBMacroNoUserParamsCreate(any(ExecuteBuildingBlock.class), any(),
any(String.class), any(String.class), any(GeneralBuildingBlock.class), any(Service.class));
@@ -2289,8 +2161,6 @@ public class BBInputSetupTest {
@Test(expected = Exception.class)
public void testgetGBBMacroException() throws Exception {
- GeneralBuildingBlock gBB = 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
@@ -2298,146 +2168,52 @@ public class BBInputSetupTest {
Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
String resourceId = "123";
String vnfType = "vnfType";
- Service service = Mockito.mock(Service.class);
String requestAction = "createInstance";
- executeBB.getBuildingBlock().setBpmnFlowName("Network");
- executeBB.getBuildingBlock().setKey("ab153b6e-c364-44c0-bef6-1f2982117f04");
+ BuildingBlock buildingBlock = executeBB.getBuildingBlock();
+ buildingBlock.setBpmnFlowName("Network").setKey("ab153b6e-c364-44c0-bef6-1f2982117f04");
+
SPY_bbInputSetup.getGBBMacro(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType);
}
@Test
- public void testgetGBBMacroWithVnfTypeNull() throws Exception {
- GeneralBuildingBlock gBB = 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_serviceMacro.json"), RequestDetails.class);
- Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
- lookupKeyMap.put(ResourceKey.NETWORK_ID, "networkId");
- lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, "vnfId");
- lookupKeyMap.put(ResourceKey.VF_MODULE_ID, "vfModuleId");
- lookupKeyMap.put(ResourceKey.VOLUME_GROUP_ID, "volumeGroupId");
- lookupKeyMap.put(ResourceKey.SERVICE_INSTANCE_ID, "serviceInstanceId");
- org.onap.aai.domain.yang.GenericVnf aaiVnf = new org.onap.aai.domain.yang.GenericVnf();
- aaiVnf.setModelCustomizationId("modelCustId");
- InfraActiveRequests request = Mockito.mock(InfraActiveRequests.class);
+ public void test_getGBBMacroForVnfTypeNull_populateL3Network_shouldBeCalled() throws Exception {
+ // given
String resourceId = "123";
- String vnfType = null;
- Service service = Mockito.mock(Service.class);
+ String vnfType = "null";
String requestAction = "createInstance";
-
- executeBB.setRequestDetails(requestDetails);
- doReturn(gBB).when(SPY_bbInputSetup).getGBBALaCarteService(executeBB, requestDetails, lookupKeyMap,
- requestAction, lookupKeyMap.get(ResourceKey.SERVICE_INSTANCE_ID));
- doReturn(request).when(SPY_bbInputSetupUtils).getInfraActiveRequest(executeBB.getRequestId());
- doReturn(service).when(SPY_bbInputSetupUtils)
- .getCatalogServiceByModelUUID(gBB.getServiceInstance().getModelInfoServiceInstance().getModelUuid());
- doNothing().when(SPY_bbInputSetupUtils).updateInfraActiveRequestVnfId(request,
- lookupKeyMap.get(ResourceKey.GENERIC_VNF_ID));
- doReturn("vnfId").when(SPY_bbInputSetup).getVnfId(executeBB, lookupKeyMap);
- doReturn(aaiVnf).when(SPY_bbInputSetupUtils).getAAIGenericVnf(any(String.class));
-
- executeBB.getBuildingBlock().setBpmnFlowName(AssignFlows.NETWORK_MACRO.toString());
- executeBB.getBuildingBlock().setKey("ab153b6e-c364-44c0-bef6-1f2982117f04");
- SPY_bbInputSetup.getGBBMacro(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType);
- verify(SPY_bbInputSetup, times(1)).populateL3Network(any(String.class), isA(ModelInfo.class),
- isA(Service.class), any(String.class), isA(ServiceInstance.class), any(), any(String.class), any());
-
- executeBB.getBuildingBlock().setBpmnFlowName(AssignFlows.VNF.toString());
- executeBB.getBuildingBlock().setKey("ab153b6e-c364-44c0-bef6-1f2982117f04");
- SPY_bbInputSetup.getGBBMacro(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType);
- verify(SPY_bbInputSetup, times(1)).populateGenericVnf(isA(ModelInfo.class), any(String.class),
- isA(org.onap.so.serviceinstancebeans.Platform.class),
- isA(org.onap.so.serviceinstancebeans.LineOfBusiness.class), isA(Service.class), any(String.class),
- isA(ServiceInstance.class), any(), ArgumentMatchers.isNull(), any(String.class),
- ArgumentMatchers.isNull(), any(), any(String.class), any(), Mockito.anyBoolean());
-
- lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, null);
- executeBB.getBuildingBlock().setBpmnFlowName(AssignFlows.VF_MODULE.toString());
- executeBB.getBuildingBlock().setKey("a25e8e8c-58b8-4eec-810c-97dcc1f5cb7f");
- 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(ServiceModel.class));
-
- lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, null);
- executeBB.getBuildingBlock().setBpmnFlowName(AssignFlows.VOLUME_GROUP.toString());
- executeBB.getBuildingBlock().setKey("72d9d1cd-f46d-447a-abdb-451d6fb05fa8");
- SPY_bbInputSetup.getGBBMacro(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType);
- verify(SPY_bbInputSetup, times(1)).populateVolumeGroup(isA(ModelInfo.class), isA(Service.class),
- any(String.class), isA(ServiceInstance.class), any(), any(String.class), ArgumentMatchers.isNull(),
- ArgumentMatchers.isNull(), ArgumentMatchers.isNull(), any());
- }
-
- @Test
- public void testgetGBBMacroGetServiceWithInvariantId() throws Exception {
+ Service service = Mockito.mock(Service.class);
GeneralBuildingBlock gBB = mapper.readValue(new File(RESOURCE_PATH + "GeneralBuildingBlockExpected.json"),
GeneralBuildingBlock.class);
- ExecuteBuildingBlock executeBB = mapper.readValue(new File(RESOURCE_PATH + "ExecuteBuildingBlockSimple.json"),
- ExecuteBuildingBlock.class);
+ Map<ResourceKey, String> lookupKeyMap = prepareLookupKeyMap();
+
+ ConfigurationResourceKeys configResourceKeys = prepareConfigurationResourceKeys();
RequestDetails requestDetails = mapper
.readValue(new File(RESOURCE_PATH + "RequestDetailsInput_serviceMacro.json"), RequestDetails.class);
- Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
- lookupKeyMap.put(ResourceKey.NETWORK_ID, "networkId");
- lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, "vnfId");
- lookupKeyMap.put(ResourceKey.VF_MODULE_ID, "vfModuleId");
- lookupKeyMap.put(ResourceKey.VOLUME_GROUP_ID, "volumeGroupId");
- lookupKeyMap.put(ResourceKey.SERVICE_INSTANCE_ID, "serviceInstanceId");
- org.onap.aai.domain.yang.GenericVnf aaiVnf = new org.onap.aai.domain.yang.GenericVnf();
- aaiVnf.setModelCustomizationId("modelCustId");
- InfraActiveRequests request = Mockito.mock(InfraActiveRequests.class);
- String resourceId = "123";
- String vnfType = "vnfType";
- Service service = Mockito.mock(Service.class);
- String requestAction = "createInstance";
+ ExecuteBuildingBlock executeBB = mapper.readValue(new File(RESOURCE_PATH + "ExecuteBuildingBlockSimple.json"),
+ ExecuteBuildingBlock.class);
+ executeBB.setConfigurationResourceKeys(configResourceKeys).setRequestDetails(requestDetails);
+ BuildingBlock buildingBlock = executeBB.getBuildingBlock();
+ buildingBlock.setBpmnFlowName(AssignFlows.NETWORK_MACRO.toString())
+ .setKey("ab153b6e-c364-44c0-bef6-1f2982117f04");
- executeBB.setRequestDetails(requestDetails);
doReturn(gBB).when(SPY_bbInputSetup).getGBBALaCarteService(executeBB, requestDetails, lookupKeyMap,
requestAction, lookupKeyMap.get(ResourceKey.SERVICE_INSTANCE_ID));
- doReturn(request).when(SPY_bbInputSetupUtils).getInfraActiveRequest(executeBB.getRequestId());
doReturn(service).when(SPY_bbInputSetupUtils)
.getCatalogServiceByModelUUID(gBB.getServiceInstance().getModelInfoServiceInstance().getModelUuid());
- doNothing().when(SPY_bbInputSetupUtils).updateInfraActiveRequestVnfId(request,
- lookupKeyMap.get(ResourceKey.GENERIC_VNF_ID));
- doReturn("vnfId").when(SPY_bbInputSetup).getVnfId(executeBB, lookupKeyMap);
- doReturn(aaiVnf).when(SPY_bbInputSetupUtils).getAAIGenericVnf(any(String.class));
-
- executeBB.getBuildingBlock().setBpmnFlowName(AssignFlows.NETWORK_MACRO.toString());
- executeBB.getBuildingBlock().setKey("ab153b6e-c364-44c0-bef6-1f2982117f04");
+ // when
SPY_bbInputSetup.getGBBMacro(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType);
+ // then
verify(SPY_bbInputSetup, times(1)).populateL3Network(any(String.class), isA(ModelInfo.class),
isA(Service.class), any(String.class), isA(ServiceInstance.class), any(), any(String.class), any());
-
- executeBB.getBuildingBlock().setBpmnFlowName(AssignFlows.VNF.toString());
- executeBB.getBuildingBlock().setKey("ab153b6e-c364-44c0-bef6-1f2982117f04");
- SPY_bbInputSetup.getGBBMacro(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType);
- verify(SPY_bbInputSetup, times(1)).populateGenericVnf(isA(ModelInfo.class), any(String.class),
- isA(org.onap.so.serviceinstancebeans.Platform.class),
- isA(org.onap.so.serviceinstancebeans.LineOfBusiness.class), isA(Service.class), any(String.class),
- isA(ServiceInstance.class), any(), any(), any(String.class), any(String.class), any(),
- any(String.class), any(String.class), Mockito.anyBoolean());
-
- lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, null);
- executeBB.getBuildingBlock().setBpmnFlowName(AssignFlows.VF_MODULE.toString());
- executeBB.getBuildingBlock().setKey("a25e8e8c-58b8-4eec-810c-97dcc1f5cb7f");
- 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(ServiceModel.class));
-
- lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, null);
- executeBB.getBuildingBlock().setBpmnFlowName(AssignFlows.VOLUME_GROUP.toString());
- executeBB.getBuildingBlock().setKey("72d9d1cd-f46d-447a-abdb-451d6fb05fa8");
- SPY_bbInputSetup.getGBBMacro(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType);
- verify(SPY_bbInputSetup, times(1)).populateVolumeGroup(isA(ModelInfo.class), isA(Service.class),
- any(String.class), isA(ServiceInstance.class), any(), any(String.class), ArgumentMatchers.isNull(),
- ArgumentMatchers.isNull(), any(String.class), any());
}
@Test
public void testgetGBBMacroNoUserParamsDeactivateInstnace() throws Exception {
+ String resourceId = "123";
+ String vnfType = "vnfType";
+ String requestAction = "deactivateInstance";
+ Service service = Mockito.mock(Service.class);
GeneralBuildingBlock gBB = mapper.readValue(new File(RESOURCE_PATH + "GeneralBuildingBlockExpected.json"),
GeneralBuildingBlock.class);
ExecuteBuildingBlock executeBB = mapper.readValue(new File(RESOURCE_PATH + "ExecuteBuildingBlockSimple.json"),
@@ -2453,171 +2229,147 @@ public class BBInputSetupTest {
lookupKeyMap.put(ResourceKey.VF_MODULE_ID, "vfModuleId");
lookupKeyMap.put(ResourceKey.VOLUME_GROUP_ID, "volumeGroupId");
lookupKeyMap.put(ResourceKey.SERVICE_INSTANCE_ID, "serviceInstanceId");
- String resourceId = "123";
- String vnfType = "vnfType";
- Service service = Mockito.mock(Service.class);
- String requestAction = "deactivateInstance";
+ BuildingBlock buildingBlock = executeBB.getBuildingBlock();
+ buildingBlock.setBpmnFlowName("DeactivateServiceInstanceBB").setKey("3c40d244-808e-42ca-b09a-256d83d19d0a");
+
doReturn(gBB).when(SPY_bbInputSetup).getGBBALaCarteService(executeBB, requestDetails, lookupKeyMap,
requestAction, lookupKeyMap.get(ResourceKey.SERVICE_INSTANCE_ID));
doReturn(service).when(SPY_bbInputSetupUtils)
.getCatalogServiceByModelUUID(gBB.getServiceInstance().getModelInfoServiceInstance().getModelUuid());
- String generatedId = "12131";
- executeBB.getBuildingBlock().setBpmnFlowName("DeactivateServiceInstanceBB");
- executeBB.getBuildingBlock().setKey("3c40d244-808e-42ca-b09a-256d83d19d0a");
GeneralBuildingBlock actual = SPY_bbInputSetup.getGBBMacro(executeBB, requestDetails, lookupKeyMap,
requestAction, resourceId, vnfType);
assertThat(actual, sameBeanAs(gBB));
}
@Test
- public void testgetGBBMacroNoUserParamsCreateInstance() throws Exception {
+ public void test_getGBBMacroNoUserParamsCreate_shouldBeCalled() throws Exception {
+ // given
+ String resourceId = "123";
+ String vnfType = "vnfType";
+ String requestAction = "createInstance";
+ Service service = Mockito.mock(Service.class);
GeneralBuildingBlock gBB = mapper.readValue(new File(RESOURCE_PATH + "GeneralBuildingBlockExpected.json"),
GeneralBuildingBlock.class);
- ExecuteBuildingBlock executeBB = mapper.readValue(new File(RESOURCE_PATH + "ExecuteBuildingBlockSimple.json"),
- ExecuteBuildingBlock.class);
+ Map<ResourceKey, String> lookupKeyMap = prepareLookupKeyMap();
+ List<NetworkResourceCustomization> networkCustList = new ArrayList<>();
+ NetworkResourceCustomization networkCust = Mockito.mock(NetworkResourceCustomization.class);
+ networkCustList.add(networkCust);
+
+ ConfigurationResourceKeys configResourceKeys = prepareConfigurationResourceKeys();
RequestDetails requestDetails = mapper
.readValue(new File(RESOURCE_PATH + "RequestDetailsInput_serviceMacro.json"), RequestDetails.class);
- InfraActiveRequests request = Mockito.mock(InfraActiveRequests.class);
requestDetails.getRequestParameters().setUserParams(null);
- org.onap.aai.domain.yang.GenericVnf aaiVnf = new org.onap.aai.domain.yang.GenericVnf();
- aaiVnf.setModelCustomizationId("modelCustId");
- Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
- lookupKeyMap.put(ResourceKey.NETWORK_ID, "networkId");
- lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, "vnfId");
- lookupKeyMap.put(ResourceKey.VF_MODULE_ID, "vfModuleId");
- lookupKeyMap.put(ResourceKey.VOLUME_GROUP_ID, "volumeGroupId");
- lookupKeyMap.put(ResourceKey.SERVICE_INSTANCE_ID, "serviceInstanceId");
- lookupKeyMap.put(ResourceKey.CONFIGURATION_ID, "configurationId");
-
- ConfigurationResourceKeys configResourceKeys = new ConfigurationResourceKeys();
- configResourceKeys.setCvnfcCustomizationUUID("cvnfcCustomizationUUID");
- configResourceKeys.setVfModuleCustomizationUUID("vfModuleCustomizationUUID");
- configResourceKeys.setVnfResourceCustomizationUUID("vnfResourceCustomizationUUID");
- executeBB.setConfigurationResourceKeys(configResourceKeys);
+ ExecuteBuildingBlock executeBB = mapper.readValue(new File(RESOURCE_PATH + "ExecuteBuildingBlockSimple.json"),
+ ExecuteBuildingBlock.class);
+ executeBB.setConfigurationResourceKeys(configResourceKeys).setRequestDetails(requestDetails);
+ BuildingBlock buildingBlock = executeBB.getBuildingBlock();
+ buildingBlock.setBpmnFlowName(AssignFlows.NETWORK_MACRO.toString())
+ .setKey("ab153b6e-c364-44c0-bef6-1f2982117f04").setIsVirtualLink(false);
- String resourceId = "123";
- String vnfType = "vnfType";
- Service service = Mockito.mock(Service.class);
- String requestAction = "createInstance";
doReturn(gBB).when(SPY_bbInputSetup).getGBBALaCarteService(executeBB, requestDetails, lookupKeyMap,
requestAction, lookupKeyMap.get(ResourceKey.SERVICE_INSTANCE_ID));
-
-
doReturn(service).when(SPY_bbInputSetupUtils)
.getCatalogServiceByModelUUID(gBB.getServiceInstance().getModelInfoServiceInstance().getModelUuid());
- List<NetworkResourceCustomization> networkCustList = new ArrayList<>();
- NetworkResourceCustomization networkCust = Mockito.mock(NetworkResourceCustomization.class);
- doReturn("ab153b6e-c364-44c0-bef6-1f2982117f04").when(networkCust).getModelCustomizationUUID();
- networkCustList.add(networkCust);
doReturn(networkCustList).when(service).getNetworkCustomizations();
+ doReturn("ab153b6e-c364-44c0-bef6-1f2982117f04").when(networkCust).getModelCustomizationUUID();
doNothing().when(SPY_bbInputSetup).populateL3Network(any(), isA(ModelInfo.class), isA(Service.class),
any(String.class), isA(ServiceInstance.class), any(), any(String.class), any());
-
- executeBB.getBuildingBlock().setBpmnFlowName(AssignFlows.NETWORK_MACRO.toString());
- executeBB.getBuildingBlock().setKey("ab153b6e-c364-44c0-bef6-1f2982117f04");
- executeBB.getBuildingBlock().setIsVirtualLink(false);
+ // when
SPY_bbInputSetup.getGBBMacro(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType);
+ // then
verify(SPY_bbInputSetup, times(1)).getGBBMacroNoUserParamsCreate(executeBB, lookupKeyMap,
executeBB.getBuildingBlock().getBpmnFlowName(), "ab153b6e-c364-44c0-bef6-1f2982117f04", gBB, service);
+ }
+ @Test
+ public void test_getGBBMacroNoUserParamsCreate_shouldBeCalled_whenBBhasVirtualLink() throws Exception {
+ // given
+ String resourceId = "123";
+ String vnfType = "vnfType";
+ String requestAction = "createInstance";
+ Service service = Mockito.mock(Service.class);
+ GeneralBuildingBlock gBB = mapper.readValue(new File(RESOURCE_PATH + "GeneralBuildingBlockExpected.json"),
+ GeneralBuildingBlock.class);
+ Map<ResourceKey, String> lookupKeyMap = prepareLookupKeyMap();
+ List<NetworkResourceCustomization> networkCustList = new ArrayList<>();
+ NetworkResourceCustomization networkCust = Mockito.mock(NetworkResourceCustomization.class);
+ networkCustList.add(networkCust);
CollectionNetworkResourceCustomization collectionNetworkResourceCust =
Mockito.mock(CollectionNetworkResourceCustomization.class);
+ org.onap.aai.domain.yang.GenericVnf aaiVnf = new org.onap.aai.domain.yang.GenericVnf();
+ aaiVnf.setModelCustomizationId("modelCustId");
+ ModelInfoNetwork modelInfoNetwork = Mockito.mock(ModelInfoNetwork.class);
+ NetworkResourceCustomization networkResourceCustomization = Mockito.mock(NetworkResourceCustomization.class);
+
+ ConfigurationResourceKeys configResourceKeys = prepareConfigurationResourceKeys();
+ RequestDetails requestDetails = mapper
+ .readValue(new File(RESOURCE_PATH + "RequestDetailsInput_serviceMacro.json"), RequestDetails.class);
+ requestDetails.getRequestParameters().setUserParams(null);
+ ExecuteBuildingBlock executeBB = mapper.readValue(new File(RESOURCE_PATH + "ExecuteBuildingBlockSimple.json"),
+ ExecuteBuildingBlock.class);
+ executeBB.setConfigurationResourceKeys(configResourceKeys).setRequestDetails(requestDetails);
+ BuildingBlock buildingBlock = executeBB.getBuildingBlock();
+ buildingBlock.setBpmnFlowName(AssignFlows.NETWORK_MACRO.toString())
+ .setKey("ab153b6e-c364-44c0-bef6-1f2982117f04").setIsVirtualLink(true);
+
+ doReturn(gBB).when(SPY_bbInputSetup).getGBBALaCarteService(executeBB, requestDetails, lookupKeyMap,
+ requestAction, lookupKeyMap.get(ResourceKey.SERVICE_INSTANCE_ID));
+ doReturn(service).when(SPY_bbInputSetupUtils)
+ .getCatalogServiceByModelUUID(gBB.getServiceInstance().getModelInfoServiceInstance().getModelUuid());
doReturn(collectionNetworkResourceCust).when(SPY_bbInputSetupUtils)
.getCatalogCollectionNetworkResourceCustByID(any(String.class));
- NetworkResourceCustomization networkResourceCustomization = Mockito.mock(NetworkResourceCustomization.class);
doReturn(networkResourceCustomization).when(bbInputSetupMapperLayer)
.mapCollectionNetworkResourceCustToNetworkResourceCust(collectionNetworkResourceCust);
- ModelInfoNetwork modelInfoNetwork = Mockito.mock(ModelInfoNetwork.class);
doReturn(modelInfoNetwork).when(bbInputSetupMapperLayer)
.mapCatalogNetworkToNetwork(networkResourceCustomization);
-
- executeBB.getBuildingBlock().setBpmnFlowName(AssignFlows.NETWORK_MACRO.toString());
- executeBB.getBuildingBlock().setKey("ab153b6e-c364-44c0-bef6-1f2982117f04");
- executeBB.getBuildingBlock().setIsVirtualLink(true);
- SPY_bbInputSetup.getGBBMacro(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType);
- verify(SPY_bbInputSetup, times(2)).getGBBMacroNoUserParamsCreate(executeBB, lookupKeyMap,
- executeBB.getBuildingBlock().getBpmnFlowName(), "ab153b6e-c364-44c0-bef6-1f2982117f04", gBB, service);
-
- executeBB.getBuildingBlock().setBpmnFlowName("CreateNetworkBB");
- executeBB.getBuildingBlock().setKey("ab153b6e-c364-44c0-bef6-1f2982117f04");
- executeBB.getBuildingBlock().setIsVirtualLink(true);
+ // when
SPY_bbInputSetup.getGBBMacro(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType);
+ // then
verify(SPY_bbInputSetup, times(1)).getGBBMacroNoUserParamsCreate(executeBB, lookupKeyMap,
executeBB.getBuildingBlock().getBpmnFlowName(), "ab153b6e-c364-44c0-bef6-1f2982117f04", gBB, service);
}
@Test
- public void testgetGBBMacroNoUserParamsOther() throws Exception {
+ public void test_getGBBMacroNoUserParamsCreate_shouldBeCalled_whenBBhasVirtualLinkAndOtherFlowName()
+ throws Exception {
+ // given
+ String otherFlowName = "CreateNetworkBB";
+ String resourceId = "123";
+ String vnfType = "vnfType";
+ String requestAction = "createInstance";
+ Service service = Mockito.mock(Service.class);
GeneralBuildingBlock gBB = mapper.readValue(new File(RESOURCE_PATH + "GeneralBuildingBlockExpected.json"),
GeneralBuildingBlock.class);
- ExecuteBuildingBlock executeBB = mapper.readValue(new File(RESOURCE_PATH + "ExecuteBuildingBlockSimple.json"),
- ExecuteBuildingBlock.class);
+ Map<ResourceKey, String> lookupKeyMap = prepareLookupKeyMap();
+ List<NetworkResourceCustomization> networkCustList = new ArrayList<>();
+ NetworkResourceCustomization networkCust = Mockito.mock(NetworkResourceCustomization.class);
+ networkCustList.add(networkCust);
+ CollectionNetworkResourceCustomization collectionNetworkResourceCust =
+ Mockito.mock(CollectionNetworkResourceCustomization.class);
+
+ ConfigurationResourceKeys configResourceKeys = prepareConfigurationResourceKeys();
RequestDetails requestDetails = mapper
.readValue(new File(RESOURCE_PATH + "RequestDetailsInput_serviceMacro.json"), RequestDetails.class);
requestDetails.getRequestParameters().setUserParams(null);
- org.onap.aai.domain.yang.GenericVnf aaiVnf = new org.onap.aai.domain.yang.GenericVnf();
- aaiVnf.setModelCustomizationId("modelCustId");
- Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
- lookupKeyMap.put(ResourceKey.NETWORK_ID, "networkId");
- lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, "vnfId");
- lookupKeyMap.put(ResourceKey.VF_MODULE_ID, "vfModuleId");
- lookupKeyMap.put(ResourceKey.VOLUME_GROUP_ID, "volumeGroupId");
- lookupKeyMap.put(ResourceKey.SERVICE_INSTANCE_ID, "serviceInstanceId");
- String resourceId = "123";
- String vnfType = "vnfType";
- Service service = Mockito.mock(Service.class);
- String requestAction = "deleteInstance";
+ ExecuteBuildingBlock executeBB = mapper.readValue(new File(RESOURCE_PATH + "ExecuteBuildingBlockSimple.json"),
+ ExecuteBuildingBlock.class);
+ executeBB.setConfigurationResourceKeys(configResourceKeys).setRequestDetails(requestDetails);
+ BuildingBlock buildingBlock = executeBB.getBuildingBlock();
+ buildingBlock.setBpmnFlowName(otherFlowName).setKey("ab153b6e-c364-44c0-bef6-1f2982117f04")
+ .setIsVirtualLink(true);
- executeBB.setRequestDetails(requestDetails);
- ServiceInstance serviceInstance = gBB.getServiceInstance();
- org.onap.aai.domain.yang.ServiceInstance aaiServiceInstance = new org.onap.aai.domain.yang.ServiceInstance();
- aaiServiceInstance.setModelVersionId("modelVersionId");
+ doReturn(gBB).when(SPY_bbInputSetup).getGBBALaCarteService(executeBB, requestDetails, lookupKeyMap,
+ requestAction, lookupKeyMap.get(ResourceKey.SERVICE_INSTANCE_ID));
doReturn(service).when(SPY_bbInputSetupUtils)
- .getCatalogServiceByModelUUID(aaiServiceInstance.getModelVersionId());
- doReturn(aaiServiceInstance).when(SPY_bbInputSetupUtils)
- .getAAIServiceInstanceById(lookupKeyMap.get(ResourceKey.SERVICE_INSTANCE_ID));
- doReturn(serviceInstance).when(SPY_bbInputSetup).getExistingServiceInstance(aaiServiceInstance);
- doReturn(gBB).when(SPY_bbInputSetup).populateGBBWithSIAndAdditionalInfo(requestDetails, serviceInstance,
- executeBB, requestAction, null);
-
- CloudConfiguration cloudConfig = new CloudConfiguration();
- cloudConfig.setLcpCloudRegionId("lcpCloudRegionId");
- requestDetails.setCloudConfiguration(cloudConfig);
- org.onap.aai.domain.yang.CloudRegion aaiCloudRegion = Mockito.mock(org.onap.aai.domain.yang.CloudRegion.class);
- doReturn(aaiCloudRegion).when(SPY_bbInputSetupUtils).getCloudRegion(requestDetails.getCloudConfiguration());
- executeBB.getBuildingBlock().setBpmnFlowName("DeleteNetworkBB");
- executeBB.getBuildingBlock().setKey("ab153b6e-c364-44c0-bef6-1f2982117f04");
- SPY_bbInputSetup.getGBBMacro(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType);
- verify(SPY_bbInputSetup, times(1)).getGBBMacroExistingService(isA(ExecuteBuildingBlock.class), any(),
- any(String.class), isA(String.class), isA(CloudConfiguration.class));
-
- requestAction = "activateInstance";
- doReturn(gBB).when(SPY_bbInputSetup).populateGBBWithSIAndAdditionalInfo(requestDetails, serviceInstance,
- executeBB, requestAction, null);
- executeBB.getBuildingBlock().setBpmnFlowName("ActivateNetworkBB");
- executeBB.getBuildingBlock().setKey("ab153b6e-c364-44c0-bef6-1f2982117f04");
- SPY_bbInputSetup.getGBBMacro(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType);
- verify(SPY_bbInputSetup, times(2)).getGBBMacroExistingService(isA(ExecuteBuildingBlock.class), any(),
- any(String.class), isA(String.class), isA(CloudConfiguration.class));
-
- requestAction = "unassignInstance";
- doReturn(gBB).when(SPY_bbInputSetup).populateGBBWithSIAndAdditionalInfo(requestDetails, serviceInstance,
- executeBB, requestAction, null);
- executeBB.getBuildingBlock().setBpmnFlowName("UnassignNetworkBB");
- executeBB.getBuildingBlock().setKey("ab153b6e-c364-44c0-bef6-1f2982117f04");
- SPY_bbInputSetup.getGBBMacro(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType);
- verify(SPY_bbInputSetup, times(3)).getGBBMacroExistingService(isA(ExecuteBuildingBlock.class), any(),
- any(String.class), isA(String.class), isA(CloudConfiguration.class));
-
- requestAction = "activateFabricConfiguration";
- doReturn(gBB).when(SPY_bbInputSetup).populateGBBWithSIAndAdditionalInfo(requestDetails, serviceInstance,
- executeBB, requestAction, null);
- executeBB.getBuildingBlock().setBpmnFlowName("ActivateFabricConfigurationBB");
- executeBB.getBuildingBlock().setKey("ab153b6e-c364-44c0-bef6-134534656234");
+ .getCatalogServiceByModelUUID(gBB.getServiceInstance().getModelInfoServiceInstance().getModelUuid());
+ doReturn(collectionNetworkResourceCust).when(SPY_bbInputSetupUtils)
+ .getCatalogCollectionNetworkResourceCustByID(any(String.class));
+ // when
SPY_bbInputSetup.getGBBMacro(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType);
- verify(SPY_bbInputSetup, times(4)).getGBBMacroExistingService(isA(ExecuteBuildingBlock.class), any(),
- any(String.class), isA(String.class), isA(CloudConfiguration.class));
+ // then
+ verify(SPY_bbInputSetup, times(1)).getGBBMacroNoUserParamsCreate(executeBB, lookupKeyMap,
+ executeBB.getBuildingBlock().getBpmnFlowName(), "ab153b6e-c364-44c0-bef6-1f2982117f04", gBB, service);
}
@Test(expected = IllegalArgumentException.class)
@@ -2647,40 +2399,37 @@ public class BBInputSetupTest {
.getCatalogServiceByModelUUID(gBB.getServiceInstance().getModelInfoServiceInstance().getModelUuid());
String generatedId = "12131";
- executeBB.getBuildingBlock().setKey("3c40d244-808e-42ca-b09a-256d83d19d0a");
SPY_bbInputSetup.getGBBMacro(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType);
}
@Test
- public void testgetGBBMacroNoUserParamsExistingService() throws Exception {
+ public void test_getGBBMacroNoUserParamsExistingService_forCatalogNetwork() throws Exception {
+ // given
+ String requestAction = "unassignInstance";
GeneralBuildingBlock gBB = mapper.readValue(new File(RESOURCE_PATH + "GeneralBuildingBlockExpected.json"),
GeneralBuildingBlock.class);
+ L3Network network = new L3Network();
+ network.setNetworkId("networkId");
+ gBB.getServiceInstance().getNetworks().add(network);
+ ServiceInstance serviceInstance = gBB.getServiceInstance();
ExecuteBuildingBlock executeBB = mapper.readValue(new File(RESOURCE_PATH + "ExecuteBuildingBlockSimple.json"),
ExecuteBuildingBlock.class);
RequestDetails requestDetails = mapper
.readValue(new File(RESOURCE_PATH + "RequestDetailsInput_serviceMacro.json"), RequestDetails.class);
requestDetails.getRequestParameters().setUserParams(null);
- Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
- lookupKeyMap.put(ResourceKey.NETWORK_ID, "networkId");
- lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, "vnfId");
- lookupKeyMap.put(ResourceKey.VF_MODULE_ID, "vfModuleId");
- lookupKeyMap.put(ResourceKey.VOLUME_GROUP_ID, "volumeGroupId");
- lookupKeyMap.put(ResourceKey.SERVICE_INSTANCE_ID, "serviceInstanceId");
- lookupKeyMap.put(ResourceKey.CONFIGURATION_ID, "configurationId");
+ Map<ResourceKey, String> lookupKeyMap = prepareLookupKeyMap();
Service service = Mockito.mock(Service.class);
CloudConfiguration cloudConfiguration = new CloudConfiguration();
cloudConfiguration.setLcpCloudRegionId("cloudRegionId");
- String requestAction = "unassignInstance";
- executeBB.setRequestDetails(requestDetails);
+ org.onap.aai.domain.yang.ServiceInstance aaiServiceInstance = new org.onap.aai.domain.yang.ServiceInstance();
+ org.onap.aai.domain.yang.L3Network aaiNetwork = new org.onap.aai.domain.yang.L3Network();
+ aaiNetwork.setModelCustomizationId("modelCustId");
- ConfigurationResourceKeys configResourceKeys = new ConfigurationResourceKeys();
- configResourceKeys.setCvnfcCustomizationUUID("cvnfcCustomizationUUID");
- configResourceKeys.setVfModuleCustomizationUUID("vfModuleCustomizationUUID");
- configResourceKeys.setVnfResourceCustomizationUUID("vnfResourceCustomizationUUID");
- executeBB.setConfigurationResourceKeys(configResourceKeys);
+ ConfigurationResourceKeys configResourceKeys = prepareConfigurationResourceKeys();
+ executeBB.setConfigurationResourceKeys(configResourceKeys).setRequestDetails(requestDetails);
+ BuildingBlock buildingBlock = executeBB.getBuildingBlock();
+ buildingBlock.setBpmnFlowName("DeleteNetworkBB").setKey("ab153b6e-c364-44c0-bef6-1f2982117f04");
- ServiceInstance serviceInstance = gBB.getServiceInstance();
- org.onap.aai.domain.yang.ServiceInstance aaiServiceInstance = new org.onap.aai.domain.yang.ServiceInstance();
aaiServiceInstance.setModelVersionId("modelVersionId");
doReturn(service).when(SPY_bbInputSetupUtils)
.getCatalogServiceByModelUUID(aaiServiceInstance.getModelVersionId());
@@ -2689,89 +2438,252 @@ public class BBInputSetupTest {
doReturn(serviceInstance).when(SPY_bbInputSetup).getExistingServiceInstance(aaiServiceInstance);
doReturn(gBB).when(SPY_bbInputSetup).populateGBBWithSIAndAdditionalInfo(requestDetails, serviceInstance,
executeBB, requestAction, null);
-
- L3Network network = new L3Network();
- network.setNetworkId("networkId");
- gBB.getServiceInstance().getNetworks().add(network);
- org.onap.aai.domain.yang.L3Network aaiNetwork = new org.onap.aai.domain.yang.L3Network();
- aaiNetwork.setModelCustomizationId("modelCustId");
doReturn(aaiNetwork).when(SPY_bbInputSetupUtils).getAAIL3Network(network.getNetworkId());
doNothing().when(SPY_bbInputSetup).mapCatalogNetwork(any(L3Network.class), any(ModelInfo.class),
any(Service.class));
-
- executeBB.getBuildingBlock().setBpmnFlowName("DeleteNetworkBB");
- executeBB.getBuildingBlock().setKey("ab153b6e-c364-44c0-bef6-1f2982117f04");
+ // when
SPY_bbInputSetup.getGBBMacroExistingService(executeBB, lookupKeyMap,
executeBB.getBuildingBlock().getBpmnFlowName(), requestAction, null);
+ // then
verify(SPY_bbInputSetup, times(1)).mapCatalogNetwork(any(L3Network.class), any(ModelInfo.class),
any(Service.class));
+ }
+ @Test
+ public void test_getGBBMacroNoUserParamsExistingService_forActivateVnfBB() throws Exception {
+ // given
+ String requestAction = "unassignInstance";
+ GeneralBuildingBlock gBB = mapper.readValue(new File(RESOURCE_PATH + "GeneralBuildingBlockExpected.json"),
+ GeneralBuildingBlock.class);
+ L3Network network = new L3Network();
+ network.setNetworkId("networkId");
+ gBB.getServiceInstance().getNetworks().add(network);
+ ServiceInstance serviceInstance = gBB.getServiceInstance();
+ ExecuteBuildingBlock executeBB = mapper.readValue(new File(RESOURCE_PATH + "ExecuteBuildingBlockSimple.json"),
+ ExecuteBuildingBlock.class);
+ RequestDetails requestDetails = mapper
+ .readValue(new File(RESOURCE_PATH + "RequestDetailsInput_serviceMacro.json"), RequestDetails.class);
+ requestDetails.getRequestParameters().setUserParams(null);
+ Map<ResourceKey, String> lookupKeyMap = prepareLookupKeyMap();
+ Service service = Mockito.mock(Service.class);
+ CloudConfiguration cloudConfiguration = new CloudConfiguration();
+ cloudConfiguration.setLcpCloudRegionId("cloudRegionId");
+ org.onap.aai.domain.yang.ServiceInstance aaiServiceInstance = new org.onap.aai.domain.yang.ServiceInstance();
+ org.onap.aai.domain.yang.L3Network aaiNetwork = new org.onap.aai.domain.yang.L3Network();
+ aaiNetwork.setModelCustomizationId("modelCustId");
GenericVnf vnf = new GenericVnf();
vnf.setVnfId("vnfId");
gBB.getServiceInstance().getVnfs().add(vnf);
org.onap.aai.domain.yang.GenericVnf aaiVnf = new org.onap.aai.domain.yang.GenericVnf();
aaiVnf.setModelCustomizationId("modelCustId");
+
+ ConfigurationResourceKeys configResourceKeys = prepareConfigurationResourceKeys();
+ executeBB.setConfigurationResourceKeys(configResourceKeys).setRequestDetails(requestDetails);
+ BuildingBlock buildingBlock = executeBB.getBuildingBlock();
+ buildingBlock.setBpmnFlowName("ActivateVnfBB").setKey("ab153b6e-c364-44c0-bef6-1f2982117f04");
+
+ aaiServiceInstance.setModelVersionId("modelVersionId");
+ doReturn(service).when(SPY_bbInputSetupUtils)
+ .getCatalogServiceByModelUUID(aaiServiceInstance.getModelVersionId());
+ doReturn(aaiServiceInstance).when(SPY_bbInputSetupUtils)
+ .getAAIServiceInstanceById(lookupKeyMap.get(ResourceKey.SERVICE_INSTANCE_ID));
+ doReturn(serviceInstance).when(SPY_bbInputSetup).getExistingServiceInstance(aaiServiceInstance);
+ doReturn(gBB).when(SPY_bbInputSetup).populateGBBWithSIAndAdditionalInfo(requestDetails, serviceInstance,
+ executeBB, requestAction, null);
doReturn(aaiVnf).when(SPY_bbInputSetupUtils).getAAIGenericVnf(vnf.getVnfId());
doNothing().when(SPY_bbInputSetup).mapCatalogVnf(any(GenericVnf.class), any(ModelInfo.class),
any(Service.class));
-
- executeBB.getBuildingBlock().setBpmnFlowName("ActivateVnfBB");
- executeBB.getBuildingBlock().setKey("ab153b6e-c364-44c0-bef6-1f2982117f04");
+ // when
SPY_bbInputSetup.getGBBMacroExistingService(executeBB, lookupKeyMap,
executeBB.getBuildingBlock().getBpmnFlowName(), requestAction, cloudConfiguration);
+ // then
verify(SPY_bbInputSetup, times(1)).mapCatalogVnf(any(GenericVnf.class), any(ModelInfo.class),
any(Service.class));
+ }
+ @Test
+ public void test_getGBBMacroNoUserParamsExistingService_forUnassignVfModuleBB() throws Exception {
+ // given
+ String requestAction = "unassignInstance";
+ GeneralBuildingBlock gBB = mapper.readValue(new File(RESOURCE_PATH + "GeneralBuildingBlockExpected.json"),
+ GeneralBuildingBlock.class);
+ L3Network network = new L3Network();
+ network.setNetworkId("networkId");
+ gBB.getServiceInstance().getNetworks().add(network);
+ ServiceInstance serviceInstance = gBB.getServiceInstance();
+ ExecuteBuildingBlock executeBB = mapper.readValue(new File(RESOURCE_PATH + "ExecuteBuildingBlockSimple.json"),
+ ExecuteBuildingBlock.class);
+ RequestDetails requestDetails = mapper
+ .readValue(new File(RESOURCE_PATH + "RequestDetailsInput_serviceMacro.json"), RequestDetails.class);
+ requestDetails.getRequestParameters().setUserParams(null);
+ Map<ResourceKey, String> lookupKeyMap = prepareLookupKeyMap();
+ Service service = Mockito.mock(Service.class);
+ CloudConfiguration cloudConfiguration = new CloudConfiguration();
+ cloudConfiguration.setLcpCloudRegionId("cloudRegionId");
+ org.onap.aai.domain.yang.ServiceInstance aaiServiceInstance = new org.onap.aai.domain.yang.ServiceInstance();
+ org.onap.aai.domain.yang.L3Network aaiNetwork = new org.onap.aai.domain.yang.L3Network();
+ aaiNetwork.setModelCustomizationId("modelCustId");
+ GenericVnf vnf = new GenericVnf();
+ vnf.setVnfId("vnfId");
+ gBB.getServiceInstance().getVnfs().add(vnf);
+ org.onap.aai.domain.yang.GenericVnf aaiVnf = new org.onap.aai.domain.yang.GenericVnf();
+ aaiVnf.setModelCustomizationId("modelCustId");
VfModule vfModule = new VfModule();
vfModule.setVfModuleId("vfModuleId");
gBB.getServiceInstance().getVnfs().get(0).getVfModules().add(vfModule);
org.onap.aai.domain.yang.VfModule aaiVfModule = new org.onap.aai.domain.yang.VfModule();
aaiVfModule.setModelCustomizationId("modelCustId");
- doReturn(aaiVfModule).when(SPY_bbInputSetupUtils).getAAIVfModule(vnf.getVnfId(), vfModule.getVfModuleId());
- executeBB.getBuildingBlock().setBpmnFlowName("UnassignVfModuleBB");
- executeBB.getBuildingBlock().setKey("a25e8e8c-58b8-4eec-810c-97dcc1f5cb7f");
+ ConfigurationResourceKeys configResourceKeys = prepareConfigurationResourceKeys();
+ executeBB.setConfigurationResourceKeys(configResourceKeys).setRequestDetails(requestDetails);
+ BuildingBlock buildingBlock = executeBB.getBuildingBlock();
+ buildingBlock.setBpmnFlowName("UnassignVfModuleBB").setKey("a25e8e8c-58b8-4eec-810c-97dcc1f5cb7f");
+
+ aaiServiceInstance.setModelVersionId("modelVersionId");
+ doReturn(service).when(SPY_bbInputSetupUtils)
+ .getCatalogServiceByModelUUID(aaiServiceInstance.getModelVersionId());
+ doReturn(aaiServiceInstance).when(SPY_bbInputSetupUtils)
+ .getAAIServiceInstanceById(lookupKeyMap.get(ResourceKey.SERVICE_INSTANCE_ID));
+ doReturn(serviceInstance).when(SPY_bbInputSetup).getExistingServiceInstance(aaiServiceInstance);
+ doReturn(gBB).when(SPY_bbInputSetup).populateGBBWithSIAndAdditionalInfo(requestDetails, serviceInstance,
+ executeBB, requestAction, null);
+ doReturn(aaiVnf).when(SPY_bbInputSetupUtils).getAAIGenericVnf(vnf.getVnfId());
+ doNothing().when(SPY_bbInputSetup).mapCatalogVnf(any(GenericVnf.class), any(ModelInfo.class),
+ any(Service.class));
+ doReturn(aaiVfModule).when(SPY_bbInputSetupUtils).getAAIVfModule(vnf.getVnfId(), vfModule.getVfModuleId());
+ // when
SPY_bbInputSetup.getGBBMacroExistingService(executeBB, lookupKeyMap,
executeBB.getBuildingBlock().getBpmnFlowName(), requestAction, cloudConfiguration);
- verify(SPY_bbInputSetup, times(2)).mapCatalogVnf(any(GenericVnf.class), any(ModelInfo.class),
+ // then
+ verify(SPY_bbInputSetup, times(1)).mapCatalogVnf(any(GenericVnf.class), any(ModelInfo.class),
any(Service.class));
verify(SPY_bbInputSetup, times(1)).mapCatalogVfModule(any(VfModule.class), any(ModelInfo.class),
any(Service.class), any(String.class));
+ }
+ @Test
+ public void test_getGBBMacroNoUserParamsExistingService_forUnassignVolumeGroupBB() throws Exception {
+ // given
+ String requestAction = "unassignInstance";
+ GeneralBuildingBlock gBB = mapper.readValue(new File(RESOURCE_PATH + "GeneralBuildingBlockExpected.json"),
+ GeneralBuildingBlock.class);
+ L3Network network = new L3Network();
+ network.setNetworkId("networkId");
+ gBB.getServiceInstance().getNetworks().add(network);
+ ServiceInstance serviceInstance = gBB.getServiceInstance();
+ ExecuteBuildingBlock executeBB = mapper.readValue(new File(RESOURCE_PATH + "ExecuteBuildingBlockSimple.json"),
+ ExecuteBuildingBlock.class);
+ RequestDetails requestDetails = mapper
+ .readValue(new File(RESOURCE_PATH + "RequestDetailsInput_serviceMacro.json"), RequestDetails.class);
+ requestDetails.getRequestParameters().setUserParams(null);
+ Map<ResourceKey, String> lookupKeyMap = prepareLookupKeyMap();
+ Service service = Mockito.mock(Service.class);
+ org.onap.aai.domain.yang.ServiceInstance aaiServiceInstance = new org.onap.aai.domain.yang.ServiceInstance();
+ GenericVnf vnf = new GenericVnf();
+ vnf.setVnfId("vnfId");
+ gBB.getServiceInstance().getVnfs().add(vnf);
+ org.onap.aai.domain.yang.GenericVnf aaiVnf = new org.onap.aai.domain.yang.GenericVnf();
+ aaiVnf.setModelCustomizationId("modelCustId");
+ VfModule vfModule = new VfModule();
+ vfModule.setVfModuleId("vfModuleId");
+ gBB.getServiceInstance().getVnfs().get(0).getVfModules().add(vfModule);
CloudRegion cloudRegion = new CloudRegion();
cloudRegion.setLcpCloudRegionId("cloudRegionId");
cloudRegion.setCloudOwner("CloudOwner");
- doReturn(Optional.of(cloudRegion)).when(SPY_cloudInfoFromAAI).getCloudInfoFromAAI(gBB.getServiceInstance());
VolumeGroup volumeGroup = new VolumeGroup();
volumeGroup.setVolumeGroupId("volumeGroupId");
gBB.getServiceInstance().getVnfs().get(0).getVolumeGroups().add(volumeGroup);
org.onap.aai.domain.yang.VolumeGroup aaiVolumeGroup = new org.onap.aai.domain.yang.VolumeGroup();
aaiVolumeGroup.setModelCustomizationId("modelCustId");
+
+ ConfigurationResourceKeys configResourceKeys = prepareConfigurationResourceKeys();
+ executeBB.setConfigurationResourceKeys(configResourceKeys).setRequestDetails(requestDetails);
+ BuildingBlock buildingBlock = executeBB.getBuildingBlock();
+ buildingBlock.setBpmnFlowName("UnassignVolumeGroupBB").setKey("72d9d1cd-f46d-447a-abdb-451d6fb05fa8");
+
+ aaiServiceInstance.setModelVersionId("modelVersionId");
+ doReturn(service).when(SPY_bbInputSetupUtils)
+ .getCatalogServiceByModelUUID(aaiServiceInstance.getModelVersionId());
+ doReturn(aaiServiceInstance).when(SPY_bbInputSetupUtils)
+ .getAAIServiceInstanceById(lookupKeyMap.get(ResourceKey.SERVICE_INSTANCE_ID));
+ doReturn(serviceInstance).when(SPY_bbInputSetup).getExistingServiceInstance(aaiServiceInstance);
+ doReturn(gBB).when(SPY_bbInputSetup).populateGBBWithSIAndAdditionalInfo(requestDetails, serviceInstance,
+ executeBB, requestAction, null);
+ doReturn(aaiVnf).when(SPY_bbInputSetupUtils).getAAIGenericVnf(vnf.getVnfId());
+ doNothing().when(SPY_bbInputSetup).mapCatalogVnf(any(GenericVnf.class), any(ModelInfo.class),
+ any(Service.class));
doReturn(aaiVolumeGroup).when(SPY_bbInputSetupUtils).getAAIVolumeGroup(cloudRegion.getCloudOwner(),
cloudRegion.getLcpCloudRegionId(), volumeGroup.getVolumeGroupId());
+ doReturn(Optional.of(cloudRegion)).when(SPY_cloudInfoFromAAI).getCloudInfoFromAAI(gBB.getServiceInstance());
- executeBB.getBuildingBlock().setBpmnFlowName("UnassignVolumeGroupBB");
- executeBB.getBuildingBlock().setKey("72d9d1cd-f46d-447a-abdb-451d6fb05fa8");
+ // when
SPY_bbInputSetup.getGBBMacroExistingService(executeBB, lookupKeyMap,
executeBB.getBuildingBlock().getBpmnFlowName(), requestAction, null);
- verify(SPY_bbInputSetup, times(3)).mapCatalogVnf(any(GenericVnf.class), any(ModelInfo.class),
+ // then
+ verify(SPY_bbInputSetup, times(1)).mapCatalogVnf(any(GenericVnf.class), any(ModelInfo.class),
any(Service.class));
verify(SPY_bbInputSetup, times(1)).mapCatalogVolumeGroup(isA(VolumeGroup.class), isA(ModelInfo.class),
isA(Service.class), isA(String.class));
+ }
+ @Test
+ public void test_getGBBMacroNoUserParamsExistingService_forActivateFabricConfigurationBB() throws Exception {
+ // given
+ String requestAction = "unassignInstance";
+ GeneralBuildingBlock gBB = mapper.readValue(new File(RESOURCE_PATH + "GeneralBuildingBlockExpected.json"),
+ GeneralBuildingBlock.class);
+ L3Network network = new L3Network();
+ network.setNetworkId("networkId");
+ gBB.getServiceInstance().getNetworks().add(network);
+ ServiceInstance serviceInstance = gBB.getServiceInstance();
+ ExecuteBuildingBlock executeBB = mapper.readValue(new File(RESOURCE_PATH + "ExecuteBuildingBlockSimple.json"),
+ ExecuteBuildingBlock.class);
+ RequestDetails requestDetails = mapper
+ .readValue(new File(RESOURCE_PATH + "RequestDetailsInput_serviceMacro.json"), RequestDetails.class);
+ requestDetails.getRequestParameters().setUserParams(null);
+ Map<ResourceKey, String> lookupKeyMap = prepareLookupKeyMap();
+ Service service = Mockito.mock(Service.class);
+ org.onap.aai.domain.yang.ServiceInstance aaiServiceInstance = new org.onap.aai.domain.yang.ServiceInstance();
+ GenericVnf vnf = new GenericVnf();
+ vnf.setVnfId("vnfId");
+ gBB.getServiceInstance().getVnfs().add(vnf);
+ org.onap.aai.domain.yang.GenericVnf aaiVnf = new org.onap.aai.domain.yang.GenericVnf();
+ aaiVnf.setModelCustomizationId("modelCustId");
+ VfModule vfModule = new VfModule();
+ vfModule.setVfModuleId("vfModuleId");
+ gBB.getServiceInstance().getVnfs().get(0).getVfModules().add(vfModule);
+ VolumeGroup volumeGroup = new VolumeGroup();
+ volumeGroup.setVolumeGroupId("volumeGroupId");
+ gBB.getServiceInstance().getVnfs().get(0).getVolumeGroups().add(volumeGroup);
+ CloudConfiguration cloudConfiguration = new CloudConfiguration();
+ cloudConfiguration.setLcpCloudRegionId("cloudRegionId");
Configuration configuration = new Configuration();
configuration.setConfigurationId("configurationId");
gBB.getServiceInstance().getConfigurations().add(configuration);
org.onap.aai.domain.yang.Configuration aaiConfiguration = new org.onap.aai.domain.yang.Configuration();
aaiConfiguration.setModelCustomizationId("modelCustId");
+
+ ConfigurationResourceKeys configResourceKeys = prepareConfigurationResourceKeys();
+ executeBB.setConfigurationResourceKeys(configResourceKeys).setRequestDetails(requestDetails);
+ BuildingBlock buildingBlock = executeBB.getBuildingBlock();
+ buildingBlock.setBpmnFlowName("ActivateFabricConfigurationBB").setKey("72d9d1cd-f46d-447a-abdb-451d6fb05fa9");
+
+ aaiServiceInstance.setModelVersionId("modelVersionId");
+ doReturn(service).when(SPY_bbInputSetupUtils)
+ .getCatalogServiceByModelUUID(aaiServiceInstance.getModelVersionId());
+ doReturn(aaiServiceInstance).when(SPY_bbInputSetupUtils)
+ .getAAIServiceInstanceById(lookupKeyMap.get(ResourceKey.SERVICE_INSTANCE_ID));
+ doReturn(serviceInstance).when(SPY_bbInputSetup).getExistingServiceInstance(aaiServiceInstance);
+ doReturn(gBB).when(SPY_bbInputSetup).populateGBBWithSIAndAdditionalInfo(requestDetails, serviceInstance,
+ executeBB, requestAction, null);
doReturn(aaiConfiguration).when(SPY_bbInputSetupUtils).getAAIConfiguration(configuration.getConfigurationId());
doNothing().when(SPY_bbInputSetup).mapCatalogConfiguration(isA(Configuration.class), isA(ModelInfo.class),
isA(Service.class), isA(ConfigurationResourceKeys.class));
- executeBB.getBuildingBlock().setBpmnFlowName("ActivateFabricConfigurationBB");
- executeBB.getBuildingBlock().setKey("72d9d1cd-f46d-447a-abdb-451d6fb05fa9");
+ // when
SPY_bbInputSetup.getGBBMacroExistingService(executeBB, lookupKeyMap,
executeBB.getBuildingBlock().getBpmnFlowName(), requestAction, cloudConfiguration);
+ // then
verify(SPY_bbInputSetup, times(1)).mapCatalogConfiguration(any(Configuration.class), any(ModelInfo.class),
any(Service.class), isA(ConfigurationResourceKeys.class));
}
@@ -2821,9 +2733,8 @@ public class BBInputSetupTest {
@Test
public void testGetVnfId() {
String expected = "vnfId";
- ExecuteBuildingBlock executeBB = new ExecuteBuildingBlock();
+ ExecuteBuildingBlock executeBB = new ExecuteBuildingBlock().setRequestId("requestId");
Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
- executeBB.setRequestId("requestId");
InfraActiveRequests request = new InfraActiveRequests();
request.setVnfId(expected);
doReturn(request).when(SPY_bbInputSetupUtils).getInfraActiveRequest(executeBB.getRequestId());
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BaseBBInputSetupTestHelper.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BaseBBInputSetupTestHelper.java
new file mode 100644
index 0000000000..adeb4d0eb0
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BaseBBInputSetupTestHelper.java
@@ -0,0 +1,47 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2020 Nokia Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.so.bpmn.servicedecomposition.tasks;
+
+import org.onap.so.bpmn.servicedecomposition.entities.ConfigurationResourceKeys;
+import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
+import java.util.HashMap;
+import java.util.Map;
+
+public class BaseBBInputSetupTestHelper {
+
+ public static Map<ResourceKey, String> prepareLookupKeyMap() {
+ Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
+ lookupKeyMap.put(ResourceKey.NETWORK_ID, "networkId");
+ lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, "vnfId");
+ lookupKeyMap.put(ResourceKey.VF_MODULE_ID, "vfModuleId");
+ lookupKeyMap.put(ResourceKey.VOLUME_GROUP_ID, "volumeGroupId");
+ lookupKeyMap.put(ResourceKey.SERVICE_INSTANCE_ID, "serviceInstanceId");
+ lookupKeyMap.put(ResourceKey.CONFIGURATION_ID, "configurationId");
+ return lookupKeyMap;
+ }
+
+ public static ConfigurationResourceKeys prepareConfigurationResourceKeys() {
+ ConfigurationResourceKeys configResourceKeys = new ConfigurationResourceKeys();
+ configResourceKeys.setCvnfcCustomizationUUID("cvnfcCustomizationUUID");
+ configResourceKeys.setVfModuleCustomizationUUID("vfModuleCustomizationUUID");
+ configResourceKeys.setVnfResourceCustomizationUUID("vnfResourceCustomizationUUID");
+ return configResourceKeys;
+ }
+}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BuildingBlockTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BuildingBlockTest.java
new file mode 100644
index 0000000000..f87382aa98
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BuildingBlockTest.java
@@ -0,0 +1,68 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2020 Nokia Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.so.bpmn.servicedecomposition.tasks;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.junit.Test;
+import org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock;
+import java.io.File;
+import java.io.IOException;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
+public class BuildingBlockTest {
+ private static final String RESOURCE_PATH = "src/test/resources/__files/BuildingBlock/";
+ private ObjectMapper mapper = new ObjectMapper();
+
+ @Test
+ public void simpleJson_shouldBeProperlyDeserialized() throws IOException {
+ // given
+ BuildingBlock expectedBuildingBlock = new BuildingBlock();
+ expectedBuildingBlock.setMsoId("msoId").setBpmnFlowName("bbName");
+ // when
+ BuildingBlock result =
+ mapper.readValue(new File(RESOURCE_PATH + "BuildingBlockSimple.json"), BuildingBlock.class);
+ // then
+ assertEquals(expectedBuildingBlock.getBpmnFlowName(), result.getBpmnFlowName());
+ assertEquals(expectedBuildingBlock.getMsoId(), result.getMsoId());
+ assertNull(result.getKey());
+ assertNull(result.getVirtualLinkKey());
+ assertNull(result.isVirtualLink());
+ }
+
+ @Test
+ public void fullJson_shouldBeProperlyDeserialized() throws IOException {
+ // given
+ BuildingBlock expectedBuildingBlock = new BuildingBlock().setMsoId("msoId").setBpmnFlowName("bbName")
+ .setVirtualLinkKey("sampleVirtualLinkKey").setIsVirtualLink(true).setKey("sampleKey")
+ .setBpmnScope("sampleScope").setBpmnAction("sampleAction");
+ // when
+ BuildingBlock result =
+ mapper.readValue(new File(RESOURCE_PATH + "BuildingBlockAllParameters.json"), BuildingBlock.class);
+ // then
+ assertEquals(expectedBuildingBlock.getBpmnFlowName(), result.getBpmnFlowName());
+ assertEquals(expectedBuildingBlock.getMsoId(), result.getMsoId());
+ assertEquals(true, result.isVirtualLink());
+ assertEquals(expectedBuildingBlock.getVirtualLinkKey(), result.getVirtualLinkKey());
+ assertEquals(expectedBuildingBlock.getKey(), result.getKey());
+ assertEquals(expectedBuildingBlock.getBpmnScope(), result.getBpmnScope());
+ assertEquals(expectedBuildingBlock.getBpmnAction(), result.getBpmnAction());
+ }
+}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildlingBlockRainyDayTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildingBlockRainyDayTest.java
index 18e08917ed..ee47b514d1 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildlingBlockRainyDayTest.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildingBlockRainyDayTest.java
@@ -42,15 +42,13 @@ import org.onap.so.constants.Status;
import org.onap.so.db.catalog.beans.macro.RainyDayHandlerStatus;
import org.springframework.beans.factory.annotation.Autowired;
-public class ExecuteBuildlingBlockRainyDayTest extends BaseTest {
+public class ExecuteBuildingBlockRainyDayTest extends BaseTest {
@Autowired
private ExecuteBuildingBlockRainyDay executeBuildingBlockRainyDay;
private ServiceInstance serviceInstance;
private Customer customer; // will build service sub
private GenericVnf vnf;
- private BuildingBlock buildingBlock;
- private ExecuteBuildingBlock executeBuildingBlock;
private static final String ASTERISK = "*";
@Before
@@ -59,11 +57,8 @@ public class ExecuteBuildlingBlockRainyDayTest extends BaseTest {
customer = setCustomer();
vnf = setGenericVnf();
- buildingBlock = new BuildingBlock();
- buildingBlock.setBpmnFlowName("AssignServiceInstanceBB");
-
- executeBuildingBlock = new ExecuteBuildingBlock();
- executeBuildingBlock.setBuildingBlock(buildingBlock);
+ BuildingBlock buildingBlock = new BuildingBlock().setBpmnFlowName("AssignServiceInstanceBB");
+ ExecuteBuildingBlock executeBuildingBlock = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock);
delegateExecution.setVariable("gBBInput", gBBInput);
delegateExecution.setVariable("WorkflowException", new WorkflowException("", 7000, ""));
diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/BuildingBlock/BuildingBlockAllParameters.json b/bpmn/MSOCommonBPMN/src/test/resources/__files/BuildingBlock/BuildingBlockAllParameters.json
new file mode 100644
index 0000000000..f99fea62db
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/BuildingBlock/BuildingBlockAllParameters.json
@@ -0,0 +1,9 @@
+{
+ "mso-id": "msoId",
+ "bpmn-flow-name": "bbName",
+ "key": "sampleKey",
+ "is-virtual-link": true,
+ "virtual-link-key": "sampleVirtualLinkKey",
+ "scope": "sampleScope",
+ "action": "sampleAction"
+} \ No newline at end of file
diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/BuildingBlock/BuildingBlockSimple.json b/bpmn/MSOCommonBPMN/src/test/resources/__files/BuildingBlock/BuildingBlockSimple.json
new file mode 100644
index 0000000000..3ffc18da16
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/BuildingBlock/BuildingBlockSimple.json
@@ -0,0 +1,4 @@
+{
+ "mso-id": "msoId",
+ "bpmn-flow-name": "bbName"
+} \ No newline at end of file
diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/ExecuteBuildingBlockExtended.json b/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/ExecuteBuildingBlockExtended.json
new file mode 100644
index 0000000000..defe40b50a
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/ExecuteBuildingBlockExtended.json
@@ -0,0 +1,8 @@
+{
+ "buildingBlock":{
+ "mso-id":"msoId",
+ "bpmn-flow-name":"bbName"
+ },
+ "requestId":"requestId",
+ "aLaCarte":true
+}
diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/GeneralBuildingBlockWithVnf.json b/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/GeneralBuildingBlockWithVnf.json
new file mode 100644
index 0000000000..ca2b76e4bf
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/GeneralBuildingBlockWithVnf.json
@@ -0,0 +1,127 @@
+{
+ "requestContext": {
+ "product-family-id": "productFamilyId",
+ "source": "source",
+ "requestor-id": "requestorId",
+ "mso-request-id": "requestId",
+ "subscription-service-type": "subscriptionServiceType",
+ "user-params": {
+ "name1": "value1",
+ "name2": "value2"
+ },
+ "action": "createInstance",
+ "callback-url": "callbackURL",
+ "requestParameters": {
+ "subscriptionServiceType": "subscriptionServiceType",
+ "userParams": [
+ {
+ "name": "name1",
+ "value": "value1"
+ },
+ {
+ "name": "name2",
+ "value": "value2"
+ },
+ {
+ "ignore": "false",
+ "skip": "ignore"
+ }
+ ]
+ },
+ "configurationParameters": [
+ {
+ "availability-zone":"$.vnf-topology.vnf-resource-assignments.availability-zones.availability-zone[0]",
+ "xtz-123":"$.vnf-topology.vnf-resource-assignments.availability-zones.availability-zone[0]"
+ }
+ ]
+ },
+ "orchContext": {
+ "is-rollback-enabled": false
+ },
+ "cloudRegion": {
+ "lcp-cloud-region-id": "lcpCloudRegionId",
+ "cloud-owner": "test-owner-name",
+ "tenant-id": "tenantId",
+ "complex": "complexName"
+ },
+ "tenant": {
+ "tenant-name": "tenantName",
+ "tenant-context": "tenantContext",
+ "tenant-id": "tenantId"
+ },
+ "userInput": null,
+ "customer": {
+ "global-customer-id": "globalCustomerId",
+ "subscriber-name": "subscriberName",
+ "subscriber-type": "subscriberType",
+ "service-subscription": {
+ "service-type": "subscriptionServiceType",
+ "service-instances": [
+ {
+ "service-instance-id": "3655a595-05d1-433c-93c0-3afd6b572545",
+ "service-instance-name": "serviceInstanceName",
+ "orchestration-status": "PRECREATED",
+ "owning-entity": {
+ "owning-entity-id": "owningEntityId",
+ "owning-entity-name": "owningEntityName"
+ },
+ "project": {
+ "project-name": "projectName"
+ },
+ "vnfs": [],
+ "allotted-resources": [],
+ "networks": [],
+ "vhn-portal-url": null,
+ "service-instance-location-id": null,
+ "selflink": null,
+ "metadata": null,
+ "configurations": [],
+ "model-info-service-instance": {
+ "description": "description",
+ "created": null,
+ "model-name": "modelName",
+ "model-uuid": "modelUUID",
+ "model-invariant-uuid": "modelInvariantUUID",
+ "model-version": "modelVersion",
+ "service-type": "serviceType",
+ "service-role": "serviceRole",
+ "environment-context": "environmentContext",
+ "workload-context": "workloadContext"
+ }
+ }
+ ]
+ }
+ },
+ "serviceInstance": {
+ "service-instance-id": "3655a595-05d1-433c-93c0-3afd6b572545",
+ "service-instance-name": "serviceInstanceName",
+ "orchestration-status": "PRECREATED",
+ "owning-entity": {
+ "owning-entity-id": "owningEntityId",
+ "owning-entity-name": "owningEntityName"
+ },
+ "project": {
+ "project-name": "projectName"
+ },
+ "vnfs": [{"vnf-id": "vnfId" }],
+ "allotted-resources": [],
+ "networks": [],
+ "vhn-portal-url": null,
+ "service-instance-location-id": null,
+ "selflink": null,
+ "metadata": null,
+ "configurations": [],
+ "model-info-service-instance": {
+ "description": "description",
+ "created": null,
+ "model-name": "modelName",
+ "model-uuid": "modelUUID",
+ "model-invariant-uuid": "modelInvariantUUID",
+ "model-version": "modelVersion",
+ "service-type": "serviceType",
+ "service-role": "serviceRole",
+ "environment-context": "environmentContext",
+ "workload-context": "workloadContext"
+ }
+ }
+}
diff --git a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/ExecuteBuildingBlockTest.java b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/ExecuteBuildingBlockTest.java
index 07554cdf97..aec118b7fb 100644
--- a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/ExecuteBuildingBlockTest.java
+++ b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/ExecuteBuildingBlockTest.java
@@ -20,29 +20,21 @@
package org.onap.so.bpmn.infrastructure.bpmn.subprocess;
-import static org.camunda.bpm.engine.test.assertions.ProcessEngineTests.assertThat;
-import static org.junit.Assert.assertNotNull;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.Mockito.doAnswer;
-import static org.mockito.Mockito.doThrow;
-import java.util.List;
import org.camunda.bpm.engine.ManagementService;
import org.camunda.bpm.engine.TaskService;
import org.camunda.bpm.engine.delegate.BpmnError;
import org.camunda.bpm.engine.delegate.DelegateExecution;
-import org.camunda.bpm.engine.management.JobDefinition;
import org.camunda.bpm.engine.runtime.Job;
import org.camunda.bpm.engine.runtime.ProcessInstance;
-import org.camunda.bpm.engine.task.Task;
-import org.camunda.bpm.engine.test.ProcessEngineRule;
import org.junit.Ignore;
-import org.junit.Rule;
import org.junit.Test;
-import org.mockito.invocation.InvocationOnMock;
-import org.mockito.stubbing.Answer;
import org.onap.so.bpmn.BaseBPMNTest;
import org.onap.so.db.catalog.beans.OrchestrationStatusValidationDirective;
import org.springframework.beans.factory.annotation.Autowired;
+import static org.camunda.bpm.engine.test.assertions.ProcessEngineTests.assertThat;
+import static org.junit.Assert.assertNotNull;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.doThrow;
public class ExecuteBuildingBlockTest extends BaseBPMNTest {
@Autowired
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/activity/ExecuteActivity.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/activity/ExecuteActivity.java
index 0c31dfa16f..533dd89276 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/activity/ExecuteActivity.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/activity/ExecuteActivity.java
@@ -6,12 +6,14 @@
* ================================================================================
* Modifications Copyright (c) 2019 Samsung
* ================================================================================
+ * Modifications Copyright (c) 2020 Nokia
+ * ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -151,32 +153,24 @@ public class ExecuteActivity implements JavaDelegate {
}
protected BuildingBlock buildBuildingBlock(String activityName) {
- BuildingBlock buildingBlock = new BuildingBlock();
- buildingBlock.setBpmnFlowName(activityName);
- buildingBlock.setMsoId(UUID.randomUUID().toString());
- buildingBlock.setKey("");
- buildingBlock.setIsVirtualLink(false);
- buildingBlock.setVirtualLinkKey("");
+ BuildingBlock buildingBlock = new BuildingBlock().setBpmnFlowName(activityName)
+ .setMsoId(UUID.randomUUID().toString()).setKey("").setIsVirtualLink(false).setVirtualLinkKey("");
return buildingBlock;
}
protected ExecuteBuildingBlock buildExecuteBuildingBlock(DelegateExecution execution, String requestId,
BuildingBlock buildingBlock) throws Exception {
- ExecuteBuildingBlock executeBuildingBlock = new ExecuteBuildingBlock();
- String bpmnRequest = (String) execution.getVariable(G_BPMN_REQUEST);
- ServiceInstancesRequest sIRequest = mapper.readValue(bpmnRequest, ServiceInstancesRequest.class);
- RequestDetails requestDetails = sIRequest.getRequestDetails();
- executeBuildingBlock.setaLaCarte(true);
- executeBuildingBlock.setRequestAction((String) execution.getVariable(G_ACTION));
- executeBuildingBlock.setResourceId((String) execution.getVariable(VNF_ID));
- executeBuildingBlock.setVnfType((String) execution.getVariable(VNF_TYPE));
WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
workflowResourceIds.setServiceInstanceId((String) execution.getVariable(SERVICE_INSTANCE_ID));
workflowResourceIds.setVnfId((String) execution.getVariable(VNF_ID));
- executeBuildingBlock.setWorkflowResourceIds(workflowResourceIds);
- executeBuildingBlock.setRequestId(requestId);
- executeBuildingBlock.setBuildingBlock(buildingBlock);
- executeBuildingBlock.setRequestDetails(requestDetails);
+ String bpmnRequest = (String) execution.getVariable(G_BPMN_REQUEST);
+ ServiceInstancesRequest sIRequest = mapper.readValue(bpmnRequest, ServiceInstancesRequest.class);
+ RequestDetails requestDetails = sIRequest.getRequestDetails();
+ ExecuteBuildingBlock executeBuildingBlock = new ExecuteBuildingBlock().setaLaCarte(true)
+ .setRequestAction((String) execution.getVariable(G_ACTION))
+ .setResourceId((String) execution.getVariable(VNF_ID))
+ .setVnfType((String) execution.getVariable(VNF_TYPE)).setWorkflowResourceIds(workflowResourceIds)
+ .setRequestId(requestId).setBuildingBlock(buildingBlock).setRequestDetails(requestDetails);
return executeBuildingBlock;
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java
index 356fe8d9a2..8911ebf15d 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java
@@ -6,14 +6,14 @@
* ================================================================================
* Modifications Copyright (c) 2019 Samsung
* ================================================================================
- * Copyright (C) 2019 Nokia.
+ * Modifications Copyright (c) 2020 Nokia
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -75,7 +75,18 @@ import org.onap.so.db.catalog.beans.VfModuleCustomization;
import org.onap.so.db.catalog.beans.macro.NorthBoundRequest;
import org.onap.so.db.catalog.beans.macro.OrchestrationFlow;
import org.onap.so.db.catalog.client.CatalogDbClient;
-import org.onap.so.serviceinstancebeans.*;
+import org.onap.so.serviceinstancebeans.CloudConfiguration;
+import org.onap.so.serviceinstancebeans.ModelInfo;
+import org.onap.so.serviceinstancebeans.ModelType;
+import org.onap.so.serviceinstancebeans.Networks;
+import org.onap.so.serviceinstancebeans.Pnfs;
+import org.onap.so.serviceinstancebeans.RelatedInstance;
+import org.onap.so.serviceinstancebeans.RequestDetails;
+import org.onap.so.serviceinstancebeans.RequestInfo;
+import org.onap.so.serviceinstancebeans.Service;
+import org.onap.so.serviceinstancebeans.ServiceInstancesRequest;
+import org.onap.so.serviceinstancebeans.VfModules;
+import org.onap.so.serviceinstancebeans.Vnfs;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@@ -274,15 +285,14 @@ public class WorkflowAction {
for (OrchestrationFlow orchFlow : orchFlows) {
ExecuteBuildingBlock ebb = buildExecuteBuildingBlock(orchFlow, requestId, resourceKey,
apiVersion, resourceId, requestAction, aLaCarte, vnfType, workflowResourceIds,
- requestDetails, false, null, false);
+ requestDetails, false, null, null, false);
flowsToExecute.add(ebb);
}
} else {
boolean foundRelated = false;
boolean containsService = false;
if (resourceType == WorkflowType.SERVICE && requestAction.equalsIgnoreCase(ASSIGNINSTANCE)) {
- // SERVICE-MACRO-ASSIGN will always get user params with
- // a
+ // SERVICE-MACRO-ASSIGN will always get user params with a
// service.
if (sIRequest.getRequestDetails().getRequestParameters().getUserParams() != null) {
List<Map<String, Object>> userParams =
@@ -300,8 +310,7 @@ public class WorkflowAction {
"Service-Macro-Assign request details must contain user params with a service");
}
} else if (resourceType == WorkflowType.SERVICE && requestAction.equalsIgnoreCase(CREATEINSTANCE)) {
- // SERVICE-MACRO-CREATE will get user params with a
- // service,
+ // SERVICE-MACRO-CREATE will get user params with a service,
// a service with a network, a service with a
// networkcollection, OR an empty service.
// If user params is just a service or null and macro
@@ -330,8 +339,7 @@ public class WorkflowAction {
|| requestAction.equalsIgnoreCase("activate" + FABRIC_CONFIGURATION))) {
// SERVICE-MACRO-ACTIVATE, SERVICE-MACRO-UNASSIGN, and
// SERVICE-MACRO-DELETE
- // Will never get user params with service, macro will
- // have
+ // Will never get user params with service, macro will have
// to query the SI in AAI to find related instances.
traverseAAIService(execution, resourceCounter, resourceId, aaiResourceIds);
} else if (resourceType == WorkflowType.SERVICE
@@ -368,8 +376,7 @@ public class WorkflowAction {
logger.info("Sorting for Vlan Tagging");
flowsToExecute = sortExecutionPathByObjectForVlanTagging(flowsToExecute, requestAction);
}
- // By default, enable homing at VNF level for CREATEINSTANCE
- // and ASSIGNINSTANCE
+ // By default, enable homing at VNF level for CREATEINSTANCE and ASSIGNINSTANCE
if (resourceType == WorkflowType.SERVICE
&& (requestAction.equals(CREATEINSTANCE) || requestAction.equals(ASSIGNINSTANCE))
&& !resourceCounter.stream().filter(x -> WorkflowType.VNF.equals(x.getResourceType()))
@@ -386,8 +393,7 @@ public class WorkflowAction {
}
}
}
- // If the user set "Homing_Solution" to "none", disable homing, else
- // if "Homing_Solution" is specified,
+ // If the user set "Homing_Solution" to "none", disable homing, else if "Homing_Solution" is specified,
// enable it.
if (sIRequest.getRequestDetails().getRequestParameters() != null
&& sIRequest.getRequestDetails().getRequestParameters().getUserParams() != null) {
@@ -540,17 +546,16 @@ public class WorkflowAction {
dataObj.getResourceKey().setVfModuleCustomizationId(vfModuleCustomizationUUID);
dataObj.getResourceKey().setCvnfModuleCustomizationId(vnfc.getModelCustomizationId());
dataObj.getResourceKey().setVnfCustomizationId(vnfCustomizationUUID);
- ExecuteBuildingBlock ebb = buildExecuteBuildingBlock(orchFlow, dataObj.getRequestId(),
- dataObj.getResourceKey(), dataObj.getApiVersion(), dataObj.getResourceId(),
- dataObj.getRequestAction(), dataObj.isaLaCarte(), dataObj.getVnfType(),
- dataObj.getWorkflowResourceIds(), dataObj.getRequestDetails(), false, null, true);
String vnfcName = getVnfcNameForConfiguration(configuration);
if (vnfcName == null || vnfcName.isEmpty()) {
buildAndThrowException(dataObj.getExecution(), "Exception in create execution list "
+ ": VnfcName does not exist or is null while there is a configuration for the vfModule",
new Exception("Vnfc and Configuration do not match"));
}
- ebb.getConfigurationResourceKeys().setVnfcName(vnfcName);
+ ExecuteBuildingBlock ebb = buildExecuteBuildingBlock(orchFlow, dataObj.getRequestId(),
+ dataObj.getResourceKey(), dataObj.getApiVersion(), dataObj.getResourceId(),
+ dataObj.getRequestAction(), dataObj.isaLaCarte(), dataObj.getVnfType(),
+ dataObj.getWorkflowResourceIds(), dataObj.getRequestDetails(), false, null, vnfcName, true);
flowsToExecuteConfigs.add(ebb);
}
}
@@ -735,7 +740,7 @@ public class WorkflowAction {
}
ebb.setWorkflowResourceIds(workflowResourceIds);
}
- if (virtualLinkKey != null && ebb.getBuildingBlock().getIsVirtualLink()
+ if (virtualLinkKey != null && ebb.getBuildingBlock().isVirtualLink()
&& virtualLinkKey.equalsIgnoreCase(ebb.getBuildingBlock().getVirtualLinkKey())) {
WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
workflowResourceIds.setServiceInstanceId(serviceInstanceId);
@@ -1323,7 +1328,7 @@ public class WorkflowAction {
for (ExecuteBuildingBlock ebb : orchFlows) {
if (ebb.getBuildingBlock().getBpmnFlowName().equals("AssignNetworkBB")) {
String key = ebb.getBuildingBlock().getKey();
- boolean isVirtualLink = Boolean.TRUE.equals(ebb.getBuildingBlock().getIsVirtualLink());
+ boolean isVirtualLink = Boolean.TRUE.equals(ebb.getBuildingBlock().isVirtualLink());
String virtualLinkKey = ebb.getBuildingBlock().getVirtualLinkKey();
sortedOrchFlows.add(ebb);
for (ExecuteBuildingBlock ebb2 : orchFlows) {
@@ -1396,7 +1401,7 @@ public class WorkflowAction {
.filter(resource -> resource.getResourceType().equals(workflowType)).collect(Collectors.toList());
serviceResources.forEach(resource -> flowsToExecute.add(buildExecuteBuildingBlock(orchFlow, requestId, resource,
apiVersion, resourceId, requestAction, false, vnfType, workflowResourceIds, requestDetails,
- isVirtualLink, resource.getVirtualLinkKey(), isConfiguration)));
+ isVirtualLink, resource.getVirtualLinkKey(), null, isConfiguration)));
}
protected List<ExecuteBuildingBlock> buildExecuteBuildingBlockList(List<OrchestrationFlow> orchFlows,
@@ -1428,7 +1433,6 @@ public class WorkflowAction {
addBuildingBlockToExecuteBBList(flowsToExecute, resourceList, WorkflowType.VIRTUAL_LINK, orchFlow,
requestId, apiVersion, resourceId, requestAction, vnfType, workflowResourceIds, requestDetails,
true, false);
-
} else if (orchFlow.getFlowName().contains(VFMODULE)) {
List<Resource> vfModuleResourcesSorted = null;
if (requestAction.equals(CREATEINSTANCE) || requestAction.equals(ASSIGNINSTANCE)
@@ -1442,7 +1446,7 @@ public class WorkflowAction {
for (int i = 0; i < vfModuleResourcesSorted.size(); i++) {
flowsToExecute.add(buildExecuteBuildingBlock(orchFlow, requestId, vfModuleResourcesSorted.get(i),
apiVersion, resourceId, requestAction, false, vnfType, workflowResourceIds, requestDetails,
- false, null, false));
+ false, null, null, false));
}
} else if (orchFlow.getFlowName().contains(VOLUMEGROUP)) {
if (requestAction.equalsIgnoreCase(REPLACEINSTANCE)
@@ -1463,7 +1467,7 @@ public class WorkflowAction {
false, true);
} else {
flowsToExecute.add(buildExecuteBuildingBlock(orchFlow, requestId, null, apiVersion, resourceId,
- requestAction, false, vnfType, workflowResourceIds, requestDetails, false, null, false));
+ requestAction, false, vnfType, workflowResourceIds, requestDetails, false, null, null, false));
}
}
return flowsToExecute;
@@ -1472,46 +1476,33 @@ public class WorkflowAction {
protected ExecuteBuildingBlock buildExecuteBuildingBlock(OrchestrationFlow orchFlow, String requestId,
Resource resource, String apiVersion, String resourceId, String requestAction, boolean aLaCarte,
String vnfType, WorkflowResourceIds workflowResourceIds, RequestDetails requestDetails,
- boolean isVirtualLink, String virtualLinkKey, boolean isConfiguration) {
- ExecuteBuildingBlock executeBuildingBlock = new ExecuteBuildingBlock();
- BuildingBlock buildingBlock = new BuildingBlock();
+ boolean isVirtualLink, String virtualLinkKey, String vnfcName, boolean isConfiguration) {
+ BuildingBlock buildingBlock =
+ new BuildingBlock().setBpmnFlowName(orchFlow.getFlowName()).setMsoId(UUID.randomUUID().toString())
+ .setIsVirtualLink(isVirtualLink).setVirtualLinkKey(virtualLinkKey)
+ .setKey(Optional.ofNullable(resource).map(Resource::getResourceId).orElse(""));
Optional.ofNullable(orchFlow.getBpmnAction()).ifPresent(action -> buildingBlock.setBpmnAction(action));
Optional.ofNullable(orchFlow.getBpmnScope()).ifPresent(scope -> buildingBlock.setBpmnScope(scope));
-
- buildingBlock.setBpmnFlowName(orchFlow.getFlowName());
- buildingBlock.setMsoId(UUID.randomUUID().toString());
- if (resource == null) {
- buildingBlock.setKey("");
- } else {
- buildingBlock.setKey(resource.getResourceId());
- }
- buildingBlock.setIsVirtualLink(isVirtualLink);
- buildingBlock.setVirtualLinkKey(virtualLinkKey);
- executeBuildingBlock.setApiVersion(apiVersion);
- executeBuildingBlock.setaLaCarte(aLaCarte);
- executeBuildingBlock.setRequestAction(requestAction);
-
if (resource != null
&& (orchFlow.getFlowName().contains(VOLUMEGROUP) && (requestAction.equalsIgnoreCase(REPLACEINSTANCE)
|| requestAction.equalsIgnoreCase(REPLACEINSTANCERETAINASSIGNMENTS)))) {
logger.debug("Setting resourceId to volume group id for volume group flow on replace");
resourceId = workflowResourceIds.getVolumeGroupId();
}
- executeBuildingBlock.setResourceId(resourceId);
- executeBuildingBlock.setVnfType(vnfType);
- executeBuildingBlock.setWorkflowResourceIds(workflowResourceIds);
- executeBuildingBlock.setRequestId(requestId);
- executeBuildingBlock.setBuildingBlock(buildingBlock);
- executeBuildingBlock.setRequestDetails(requestDetails);
+
+ ExecuteBuildingBlock executeBuildingBlock = new ExecuteBuildingBlock().setApiVersion(apiVersion)
+ .setaLaCarte(aLaCarte).setRequestAction(requestAction).setResourceId(resourceId).setVnfType(vnfType)
+ .setWorkflowResourceIds(workflowResourceIds).setRequestId(requestId).setBuildingBlock(buildingBlock)
+ .setRequestDetails(requestDetails);
+
if (resource != null && (isConfiguration || resource.getResourceType().equals(WorkflowType.CONFIGURATION))) {
ConfigurationResourceKeys configurationResourceKeys = new ConfigurationResourceKeys();
- if (resource != null) {
- configurationResourceKeys.setCvnfcCustomizationUUID(resource.getCvnfModuleCustomizationId());
- configurationResourceKeys.setVfModuleCustomizationUUID(resource.getVfModuleCustomizationId());
- configurationResourceKeys.setVnfResourceCustomizationUUID(resource.getVnfCustomizationId());
- }
+ Optional.ofNullable(vnfcName).ifPresent(name -> configurationResourceKeys.setVnfcName(name));
+ configurationResourceKeys.setCvnfcCustomizationUUID(resource.getCvnfModuleCustomizationId());
+ configurationResourceKeys.setVfModuleCustomizationUUID(resource.getVfModuleCustomizationId());
+ configurationResourceKeys.setVnfResourceCustomizationUUID(resource.getVnfCustomizationId());
executeBuildingBlock.setConfigurationResourceKeys(configurationResourceKeys);
}
return executeBuildingBlock;
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java
index 9d45272a60..ba5d283c01 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java
@@ -453,21 +453,16 @@ public class WorkflowActionBBTasks {
protected ExecuteBuildingBlock getExecuteBBForConfig(String bbName, ExecuteBuildingBlock ebb,
String configurationId, ConfigurationResourceKeys configurationResourceKeys) {
- ExecuteBuildingBlock configBB = new ExecuteBuildingBlock();
- BuildingBlock buildingBlock = new BuildingBlock();
- buildingBlock.setBpmnFlowName(bbName);
- buildingBlock.setMsoId(UUID.randomUUID().toString());
- configBB.setaLaCarte(ebb.isaLaCarte());
- configBB.setApiVersion(ebb.getApiVersion());
- configBB.setRequestAction(ebb.getRequestAction());
- configBB.setVnfType(ebb.getVnfType());
- configBB.setRequestId(ebb.getRequestId());
- configBB.setRequestDetails(ebb.getRequestDetails());
- configBB.setBuildingBlock(buildingBlock);
+ BuildingBlock buildingBlock =
+ new BuildingBlock().setBpmnFlowName(bbName).setMsoId(UUID.randomUUID().toString());
+
WorkflowResourceIds workflowResourceIds = ebb.getWorkflowResourceIds();
workflowResourceIds.setConfigurationId(configurationId);
- configBB.setWorkflowResourceIds(workflowResourceIds);
- configBB.setConfigurationResourceKeys(configurationResourceKeys);
+ ExecuteBuildingBlock configBB = new ExecuteBuildingBlock().setaLaCarte(ebb.isaLaCarte())
+ .setApiVersion(ebb.getApiVersion()).setRequestAction(ebb.getRequestAction())
+ .setVnfType(ebb.getVnfType()).setRequestId(ebb.getRequestId())
+ .setRequestDetails(ebb.getRequestDetails()).setBuildingBlock(buildingBlock)
+ .setWorkflowResourceIds(workflowResourceIds).setConfigurationResourceKeys(configurationResourceKeys);
return configBB;
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBFailureTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBFailureTest.java
index 573601b20f..7f44c97f59 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBFailureTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBFailureTest.java
@@ -143,10 +143,8 @@ public class WorkflowActionBBFailureTest extends BaseTaskTest {
@Test
public void updateRequestStatusToFailedRollbackFabric() {
- ExecuteBuildingBlock ebb = new ExecuteBuildingBlock();
- BuildingBlock bb = new BuildingBlock();
- bb.setBpmnFlowName("UnassignFabricConfigurationBB");
- ebb.setBuildingBlock(bb);
+ BuildingBlock bb = new BuildingBlock().setBpmnFlowName("UnassignFabricConfigurationBB");
+ ExecuteBuildingBlock ebb = new ExecuteBuildingBlock().setBuildingBlock(bb);
execution.setVariable("buildingBlock", ebb);
execution.setVariable("mso-request-id", "123");
execution.setVariable("isRollbackComplete", false);
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksTest.java
index 4991fa59ee..ff1246bc46 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksTest.java
@@ -4,12 +4,14 @@
* ================================================================================
* Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved.
* ================================================================================
+ * Modifications Copyright (c) 2020 Nokia
+ * ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -20,19 +22,6 @@
package org.onap.so.bpmn.infrastructure.workflow.tasks;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertThat;
-import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
-import static org.mockito.ArgumentMatchers.anyObject;
-import static org.mockito.ArgumentMatchers.anyString;
-import static org.mockito.ArgumentMatchers.isA;
-import static org.mockito.Mockito.doNothing;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.when;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Optional;
import org.camunda.bpm.engine.delegate.BpmnError;
import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.camunda.bpm.extension.mockito.delegate.DelegateExecutionFake;
@@ -58,15 +47,26 @@ import org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock;
import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock;
import org.onap.so.db.catalog.beans.VnfResourceCustomization;
import org.onap.so.db.request.beans.InfraActiveRequests;
-import org.onap.so.serviceinstancebeans.CloudConfiguration;
import org.onap.so.serviceinstancebeans.ModelInfo;
-import org.onap.so.serviceinstancebeans.ModelType;
import org.onap.so.serviceinstancebeans.RequestDetails;
-import org.onap.so.serviceinstancebeans.RequestInfo;
import org.springframework.core.env.Environment;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Optional;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.ArgumentMatchers.anyObject;
+import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.ArgumentMatchers.isA;
+import static org.mockito.Mockito.doNothing;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.when;
public class WorkflowActionBBTasksTest extends BaseTaskTest {
+ private static final String SAMPLE_MSO_REQUEST_ID = "00f704ca-c5e5-4f95-a72c-6889db7b0688";
+ private static final String SAMPLE_REQUEST_ACTION = "Delete-Network-Collection";
+ private static final int SAMPLE_SEQUENCE = 0;
@Mock
protected WorkflowAction workflowAction;
@@ -94,7 +94,7 @@ public class WorkflowActionBBTasksTest extends BaseTaskTest {
@Before
public void before() throws Exception {
execution = new DelegateExecutionFake();
- org.onap.aai.domain.yang.ServiceInstance servInstance = new org.onap.aai.domain.yang.ServiceInstance();
+ ServiceInstance servInstance = new ServiceInstance();
servInstance.setServiceInstanceId("TEST");
when(bbSetupUtils.getAAIServiceInstanceByName(anyString(), anyObject())).thenReturn(servInstance);
workflowAction.setBbInputSetupUtils(bbSetupUtils);
@@ -102,30 +102,22 @@ public class WorkflowActionBBTasksTest extends BaseTaskTest {
}
@Test
- public void selectBBTest() throws Exception {
- String gAction = "Delete-Network-Collection";
- execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688");
- execution.setVariable("requestAction", gAction);
- execution.setVariable("gCurrentSequence", 0);
- execution.setVariable("homing", false);
- execution.setVariable("calledHoming", false);
- List<ExecuteBuildingBlock> flowsToExecute = new ArrayList();
- ExecuteBuildingBlock ebb = new ExecuteBuildingBlock();
-
+ public void selectBBTest() {
String vnfCustomizationUUID = "1234567";
String modelUuid = "1234567";
- BuildingBlock buildingBlock = new BuildingBlock();
- buildingBlock.setBpmnFlowName("ConfigAssignVnfBB");
- buildingBlock.setKey(vnfCustomizationUUID);
- ebb.setBuildingBlock(buildingBlock);
+ prepareDelegateExecution();
+ List<ExecuteBuildingBlock> flowsToExecute = new ArrayList<>();
+
+ BuildingBlock buildingBlock =
+ new BuildingBlock().setBpmnFlowName("ConfigAssignVnfBB").setKey(vnfCustomizationUUID);
RequestDetails rd = new RequestDetails();
ModelInfo mi = new ModelInfo();
mi.setModelUuid(modelUuid);
rd.setModelInfo(mi);
- ebb.setRequestDetails(rd);
+ ExecuteBuildingBlock ebb = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock).setRequestDetails(rd);
flowsToExecute.add(ebb);
- List<VnfResourceCustomization> vnfResourceCustomizations = new ArrayList();
+ List<VnfResourceCustomization> vnfResourceCustomizations = new ArrayList<>();
VnfResourceCustomization vrc = new VnfResourceCustomization();
vrc.setSkipPostInstConf(false);
vrc.setModelCustomizationUUID(vnfCustomizationUUID);
@@ -140,42 +132,37 @@ public class WorkflowActionBBTasksTest extends BaseTaskTest {
workflowActionBBTasks.selectBB(execution);
boolean success = (boolean) execution.getVariable("completed");
int currentSequence = (int) execution.getVariable("gCurrentSequence");
- assertEquals(true, success);
+ assertTrue(success);
assertEquals(1, currentSequence);
}
@Test
- public void select2BBTest() throws Exception {
- String gAction = "Delete-Network-Collection";
- execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688");
- execution.setVariable("requestAction", gAction);
- execution.setVariable("gCurrentSequence", 0);
- execution.setVariable("homing", false);
- execution.setVariable("calledHoming", false);
- List<ExecuteBuildingBlock> flowsToExecute = new ArrayList();
- ExecuteBuildingBlock ebb = new ExecuteBuildingBlock();
- ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock();
-
+ public void select2BBTest() {
String vnfCustomizationUUID = "1234567";
String modelUuid = "1234567";
- BuildingBlock buildingBlock = new BuildingBlock();
- buildingBlock.setBpmnFlowName("ConfigDeployVnfBB");
- buildingBlock.setKey(vnfCustomizationUUID);
- ebb.setBuildingBlock(buildingBlock);
+
+ prepareDelegateExecution();
+ List<ExecuteBuildingBlock> flowsToExecute = new ArrayList<>();
+ BuildingBlock buildingBlock =
+ new BuildingBlock().setBpmnFlowName("ConfigDeployVnfBB").setKey(vnfCustomizationUUID);
RequestDetails rd = new RequestDetails();
ModelInfo mi = new ModelInfo();
mi.setModelUuid(modelUuid);
rd.setModelInfo(mi);
- ebb.setRequestDetails(rd);
+ ExecuteBuildingBlock ebb = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock).setRequestDetails(rd);
+ ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock();
+
flowsToExecute.add(ebb);
- List<VnfResourceCustomization> vnfResourceCustomizations = new ArrayList();
+ List<VnfResourceCustomization> vnfResourceCustomizations = new ArrayList<>();
VnfResourceCustomization vrc = new VnfResourceCustomization();
+
vrc.setSkipPostInstConf(false);
vrc.setModelCustomizationUUID(vnfCustomizationUUID);
vnfResourceCustomizations.add(vrc);
GenericVnf genericVnf = new GenericVnf();
genericVnf.setModelCustomizationId(vnfCustomizationUUID);
+
doReturn(vnfResourceCustomizations).when(catalogDbClient).getVnfResourceCustomizationByModelUuid(modelUuid);
doReturn(vrc).when(catalogDbClient).findVnfResourceCustomizationInList(vnfCustomizationUUID,
vnfResourceCustomizations);
@@ -190,7 +177,7 @@ public class WorkflowActionBBTasksTest extends BaseTaskTest {
}
@Test
- public void updateRequestStatusToCompleteTest() throws Exception {
+ public void updateRequestStatusToCompleteTest() {
String reqId = "reqId123";
execution.setVariable("mso-request-id", reqId);
execution.setVariable("requestAction", "createInstance");
@@ -208,21 +195,17 @@ public class WorkflowActionBBTasksTest extends BaseTaskTest {
public void rollbackExecutionPathTest() {
execution.setVariable("handlingCode", "Rollback");
execution.setVariable("isRollback", false);
- List<ExecuteBuildingBlock> flowsToExecute = new ArrayList();
- ExecuteBuildingBlock ebb1 = new ExecuteBuildingBlock();
- BuildingBlock bb1 = new BuildingBlock();
- bb1.setBpmnFlowName("AssignVfModuleBB");
- ebb1.setBuildingBlock(bb1);
+ List<ExecuteBuildingBlock> flowsToExecute = new ArrayList<>();
+ BuildingBlock buildingBlock1 = new BuildingBlock().setBpmnFlowName("AssignVfModuleBB");
+ ExecuteBuildingBlock ebb1 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock1);
flowsToExecute.add(ebb1);
- ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock();
- BuildingBlock bb2 = new BuildingBlock();
- bb2.setBpmnFlowName("CreateVfModuleBB");
- ebb2.setBuildingBlock(bb2);
+
+ BuildingBlock buildingBlock2 = new BuildingBlock().setBpmnFlowName("CreateVfModuleBB");
+ ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock2);
flowsToExecute.add(ebb2);
- ExecuteBuildingBlock ebb3 = new ExecuteBuildingBlock();
- BuildingBlock bb3 = new BuildingBlock();
- bb3.setBpmnFlowName("ActivateVfModuleBB");
- ebb3.setBuildingBlock(bb3);
+
+ BuildingBlock buildingBlock3 = new BuildingBlock().setBpmnFlowName("ActivateVfModuleBB");
+ ExecuteBuildingBlock ebb3 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock3);
flowsToExecute.add(ebb3);
execution.setVariable("flowsToExecute", flowsToExecute);
@@ -241,21 +224,17 @@ public class WorkflowActionBBTasksTest extends BaseTaskTest {
public void rollbackExecutionPathUnfinishedFlowTest() {
execution.setVariable("handlingCode", "Rollback");
execution.setVariable("isRollback", false);
- List<ExecuteBuildingBlock> flowsToExecute = new ArrayList();
- ExecuteBuildingBlock ebb1 = new ExecuteBuildingBlock();
- BuildingBlock bb1 = new BuildingBlock();
- bb1.setBpmnFlowName("AssignVfModuleBB");
- ebb1.setBuildingBlock(bb1);
+ List<ExecuteBuildingBlock> flowsToExecute = new ArrayList<>();
+ BuildingBlock buildingBlock1 = new BuildingBlock().setBpmnFlowName("AssignVfModuleBB");
+ ExecuteBuildingBlock ebb1 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock1);
flowsToExecute.add(ebb1);
- ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock();
- BuildingBlock bb2 = new BuildingBlock();
- bb2.setBpmnFlowName("CreateVfModuleBB");
- ebb2.setBuildingBlock(bb2);
+
+ BuildingBlock buildingBlock2 = new BuildingBlock().setBpmnFlowName("CreateVfModuleBB");
+ ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock2);
flowsToExecute.add(ebb2);
- ExecuteBuildingBlock ebb3 = new ExecuteBuildingBlock();
- BuildingBlock bb3 = new BuildingBlock();
- bb3.setBpmnFlowName("ActivateVfModuleBB");
- ebb3.setBuildingBlock(bb3);
+
+ BuildingBlock buildingBlock3 = new BuildingBlock().setBpmnFlowName("ActivateVfModuleBB");
+ ExecuteBuildingBlock ebb3 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock3);
flowsToExecute.add(ebb3);
execution.setVariable("flowsToExecute", flowsToExecute);
@@ -274,26 +253,21 @@ public class WorkflowActionBBTasksTest extends BaseTaskTest {
public void rollbackExecutionTest() {
execution.setVariable("handlingCode", "Rollback");
execution.setVariable("isRollback", false);
- List<ExecuteBuildingBlock> flowsToExecute = new ArrayList();
- ExecuteBuildingBlock ebb1 = new ExecuteBuildingBlock();
- BuildingBlock bb1 = new BuildingBlock();
- bb1.setBpmnFlowName("AssignServiceInstanceBB");
- ebb1.setBuildingBlock(bb1);
+ List<ExecuteBuildingBlock> flowsToExecute = new ArrayList<>();
+ BuildingBlock buildingBlock1 = new BuildingBlock().setBpmnFlowName("AssignServiceInstanceBB");
+ ExecuteBuildingBlock ebb1 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock1);
flowsToExecute.add(ebb1);
- ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock();
- BuildingBlock bb2 = new BuildingBlock();
- bb2.setBpmnFlowName("CreateNetworkCollectionBB");
- ebb2.setBuildingBlock(bb2);
+
+ BuildingBlock buildingBlock2 = new BuildingBlock().setBpmnFlowName("CreateNetworkCollectionBB");
+ ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock2);
flowsToExecute.add(ebb2);
- ExecuteBuildingBlock ebb3 = new ExecuteBuildingBlock();
- BuildingBlock bb3 = new BuildingBlock();
- bb3.setBpmnFlowName("AssignNetworkBB");
- ebb3.setBuildingBlock(bb3);
+
+ BuildingBlock buildingBlock3 = new BuildingBlock().setBpmnFlowName("AssignNetworkBB");
+ ExecuteBuildingBlock ebb3 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock3);
flowsToExecute.add(ebb3);
- ExecuteBuildingBlock ebb4 = new ExecuteBuildingBlock();
- BuildingBlock bb4 = new BuildingBlock();
- bb4.setBpmnFlowName("CreateNetworkBB");
- ebb4.setBuildingBlock(bb4);
+
+ BuildingBlock buildingBlock4 = new BuildingBlock().setBpmnFlowName("CreateNetworkBB");
+ ExecuteBuildingBlock ebb4 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock4);
flowsToExecute.add(ebb4);
execution.setVariable("flowsToExecute", flowsToExecute);
@@ -312,21 +286,18 @@ public class WorkflowActionBBTasksTest extends BaseTaskTest {
public void rollbackExecutionRollbackToAssignedTest() {
execution.setVariable("isRollback", false);
execution.setVariable("handlingCode", "RollbackToAssigned");
- List<ExecuteBuildingBlock> flowsToExecute = new ArrayList();
- ExecuteBuildingBlock ebb1 = new ExecuteBuildingBlock();
- BuildingBlock bb1 = new BuildingBlock();
- bb1.setBpmnFlowName("AssignVfModuleBB");
- ebb1.setBuildingBlock(bb1);
+ List<ExecuteBuildingBlock> flowsToExecute = new ArrayList<>();
+
+ BuildingBlock buildingBlock1 = new BuildingBlock().setBpmnFlowName("AssignVfModuleBB");
+ ExecuteBuildingBlock ebb1 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock1);
flowsToExecute.add(ebb1);
- ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock();
- BuildingBlock bb2 = new BuildingBlock();
- bb2.setBpmnFlowName("CreateVfModuleBB");
- ebb2.setBuildingBlock(bb2);
+
+ BuildingBlock buildingBlock2 = new BuildingBlock().setBpmnFlowName("CreateVfModuleBB");
+ ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock2);
flowsToExecute.add(ebb2);
- ExecuteBuildingBlock ebb3 = new ExecuteBuildingBlock();
- BuildingBlock bb3 = new BuildingBlock();
- bb3.setBpmnFlowName("ActivateVfModuleBB");
- ebb3.setBuildingBlock(bb3);
+
+ BuildingBlock buildingBlock3 = new BuildingBlock().setBpmnFlowName("ActivateVfModuleBB");
+ ExecuteBuildingBlock ebb3 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock3);
flowsToExecute.add(ebb3);
execution.setVariable("flowsToExecute", flowsToExecute);
@@ -343,31 +314,26 @@ public class WorkflowActionBBTasksTest extends BaseTaskTest {
public void rollbackExecutionRollbackToAssignedWithFabricTest() {
execution.setVariable("isRollback", false);
execution.setVariable("handlingCode", "RollbackToAssigned");
- List<ExecuteBuildingBlock> flowsToExecute = new ArrayList();
- ExecuteBuildingBlock ebb1 = new ExecuteBuildingBlock();
- BuildingBlock bb1 = new BuildingBlock();
- bb1.setBpmnFlowName("AssignVfModuleBB");
- ebb1.setBuildingBlock(bb1);
+ List<ExecuteBuildingBlock> flowsToExecute = new ArrayList<>();
+
+ BuildingBlock buildingBlock1 = new BuildingBlock().setBpmnFlowName("AssignVfModuleBB");
+ ExecuteBuildingBlock ebb1 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock1);
flowsToExecute.add(ebb1);
- ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock();
- BuildingBlock bb2 = new BuildingBlock();
- bb2.setBpmnFlowName("CreateVfModuleBB");
- ebb2.setBuildingBlock(bb2);
+
+ BuildingBlock buildingBlock2 = new BuildingBlock().setBpmnFlowName("CreateVfModuleBB");
+ ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock2);
flowsToExecute.add(ebb2);
- ExecuteBuildingBlock ebb3 = new ExecuteBuildingBlock();
- BuildingBlock bb3 = new BuildingBlock();
- bb3.setBpmnFlowName("ActivateVfModuleBB");
- ebb3.setBuildingBlock(bb3);
+
+ BuildingBlock buildingBlock3 = new BuildingBlock().setBpmnFlowName("ActivateVfModuleBB");
+ ExecuteBuildingBlock ebb3 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock3);
flowsToExecute.add(ebb3);
- ExecuteBuildingBlock ebb4 = new ExecuteBuildingBlock();
- BuildingBlock bb4 = new BuildingBlock();
- bb4.setBpmnFlowName("AssignFabricConfigurationBB");
- ebb4.setBuildingBlock(bb4);
+
+ BuildingBlock buildingBlock4 = new BuildingBlock().setBpmnFlowName("AssignFabricConfigurationBB");
+ ExecuteBuildingBlock ebb4 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock4);
flowsToExecute.add(ebb4);
- ExecuteBuildingBlock ebb5 = new ExecuteBuildingBlock();
- BuildingBlock bb5 = new BuildingBlock();
- bb5.setBpmnFlowName("ActivateFabricConfigurationBB");
- ebb5.setBuildingBlock(bb5);
+
+ BuildingBlock buildingBlock5 = new BuildingBlock().setBpmnFlowName("ActivateFabricConfigurationBB");
+ ExecuteBuildingBlock ebb5 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock5);
flowsToExecute.add(ebb5);
execution.setVariable("flowsToExecute", flowsToExecute);
@@ -388,21 +354,17 @@ public class WorkflowActionBBTasksTest extends BaseTaskTest {
public void rollbackExecutionRollbackToCreatedTest() {
execution.setVariable("isRollback", false);
execution.setVariable("handlingCode", "RollbackToCreated");
- List<ExecuteBuildingBlock> flowsToExecute = new ArrayList();
- ExecuteBuildingBlock ebb1 = new ExecuteBuildingBlock();
- BuildingBlock bb1 = new BuildingBlock();
- bb1.setBpmnFlowName("AssignVfModuleBB");
- ebb1.setBuildingBlock(bb1);
+ List<ExecuteBuildingBlock> flowsToExecute = new ArrayList<>();
+ BuildingBlock buildingBlock1 = new BuildingBlock().setBpmnFlowName("AssignVfModuleBB");
+ ExecuteBuildingBlock ebb1 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock1);
flowsToExecute.add(ebb1);
- ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock();
- BuildingBlock bb2 = new BuildingBlock();
- bb2.setBpmnFlowName("CreateVfModuleBB");
- ebb2.setBuildingBlock(bb2);
+
+ BuildingBlock buildingBlock2 = new BuildingBlock().setBpmnFlowName("CreateVfModuleBB");
+ ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock2);
flowsToExecute.add(ebb2);
- ExecuteBuildingBlock ebb3 = new ExecuteBuildingBlock();
- BuildingBlock bb3 = new BuildingBlock();
- bb3.setBpmnFlowName("ActivateVfModuleBB");
- ebb3.setBuildingBlock(bb3);
+
+ BuildingBlock buildingBlock3 = new BuildingBlock().setBpmnFlowName("ActivateVfModuleBB");
+ ExecuteBuildingBlock ebb3 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock3);
flowsToExecute.add(ebb3);
execution.setVariable("flowsToExecute", flowsToExecute);
@@ -480,8 +442,7 @@ public class WorkflowActionBBTasksTest extends BaseTaskTest {
org.onap.aai.domain.yang.Vnfc vnfc = new org.onap.aai.domain.yang.Vnfc();
vnfc.setModelInvariantId("modelInvariantId");
vnfc.setVnfcName("testVnfcName");
- List<org.onap.aai.domain.yang.Configuration> configurations =
- new ArrayList<org.onap.aai.domain.yang.Configuration>();
+ List<Configuration> configurations = new ArrayList<>();
org.onap.aai.domain.yang.Configuration configuration = new org.onap.aai.domain.yang.Configuration();
configuration.setConfigurationId("configurationId");
configuration.setModelCustomizationId("modelCustimizationId");
@@ -585,4 +546,12 @@ public class WorkflowActionBBTasksTest extends BaseTaskTest {
assertEquals("volumeGroupName", request.getVolumeGroupName());
}
+
+ private void prepareDelegateExecution() {
+ execution.setVariable("mso-request-id", SAMPLE_MSO_REQUEST_ID);
+ execution.setVariable("requestAction", SAMPLE_REQUEST_ACTION);
+ execution.setVariable("gCurrentSequence", SAMPLE_SEQUENCE);
+ execution.setVariable("homing", false);
+ execution.setVariable("calledHoming", false);
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksUpdateReqDbTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksUpdateReqDbTest.java
index 9c3f0c6f0b..73aace7592 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksUpdateReqDbTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksUpdateReqDbTest.java
@@ -67,16 +67,12 @@ public class WorkflowActionBBTasksUpdateReqDbTest extends BaseTaskTest {
@Test
public void getUpdatedRequestTest() throws Exception {
List<ExecuteBuildingBlock> flowsToExecute = new ArrayList();
- ExecuteBuildingBlock ebb1 = new ExecuteBuildingBlock();
- BuildingBlock bb1 = new BuildingBlock();
- bb1.setBpmnFlowName("CreateNetworkBB");
+ BuildingBlock bb1 = new BuildingBlock().setBpmnFlowName("CreateNetworkBB");
+ ExecuteBuildingBlock ebb1 = new ExecuteBuildingBlock().setBuildingBlock(bb1);
flowsToExecute.add(ebb1);
- ebb1.setBuildingBlock(bb1);
- ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock();
- BuildingBlock bb2 = new BuildingBlock();
- bb2.setBpmnFlowName("ActivateNetworkBB");
+ BuildingBlock bb2 = new BuildingBlock().setBpmnFlowName("ActivateNetworkBB");
+ ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock().setBuildingBlock(bb2);
flowsToExecute.add(ebb2);
- ebb2.setBuildingBlock(bb2);
String requestId = "requestId";
execution.setVariable("mso-request-id", requestId);
execution.setVariable("flowsToExecute", flowsToExecute);
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java
index ed3ee0a3a1..cc4a5ce04e 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java
@@ -6,6 +6,8 @@
* ================================================================================
* Modifications Copyright (c) 2019 Samsung
* ================================================================================
+ * Modifications Copyright (c) 2020 Nokia
+ * ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@@ -109,7 +111,6 @@ import org.springframework.core.env.Environment;
public class WorkflowActionTest extends BaseTaskTest {
-
@Mock
protected Environment environment;
@InjectMocks
@@ -1706,41 +1707,29 @@ public class WorkflowActionTest extends BaseTaskTest {
@Test
public void sortExecutionPathByObjectForVlanTaggingCreateTest() throws Exception {
List<ExecuteBuildingBlock> executeFlows = new ArrayList<>();
- ExecuteBuildingBlock ebb = new ExecuteBuildingBlock();
- BuildingBlock bb = new BuildingBlock();
- bb.setBpmnFlowName("AssignNetworkBB");
- bb.setKey("0");
- ebb.setBuildingBlock(bb);
+
+ BuildingBlock bb = new BuildingBlock().setBpmnFlowName("AssignNetworkBB").setKey("0");
+ ExecuteBuildingBlock ebb = new ExecuteBuildingBlock().setBuildingBlock(bb);
executeFlows.add(ebb);
- ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock();
- BuildingBlock bb2 = new BuildingBlock();
- bb2.setBpmnFlowName("AssignNetworkBB");
- bb2.setKey("1");
- ebb2.setBuildingBlock(bb2);
+
+ BuildingBlock bb2 = new BuildingBlock().setBpmnFlowName("AssignNetworkBB").setKey("1");
+ ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock().setBuildingBlock(bb2);
executeFlows.add(ebb2);
- ExecuteBuildingBlock ebb3 = new ExecuteBuildingBlock();
- BuildingBlock bb3 = new BuildingBlock();
- bb3.setBpmnFlowName("CreateNetworkBB");
- bb3.setKey("0");
- ebb3.setBuildingBlock(bb3);
+
+ BuildingBlock bb3 = new BuildingBlock().setBpmnFlowName("CreateNetworkBB").setKey("0");
+ ExecuteBuildingBlock ebb3 = new ExecuteBuildingBlock().setBuildingBlock(bb3);
executeFlows.add(ebb3);
- ExecuteBuildingBlock ebb4 = new ExecuteBuildingBlock();
- BuildingBlock bb4 = new BuildingBlock();
- bb4.setBpmnFlowName("CreateNetworkBB");
- bb4.setKey("1");
- ebb4.setBuildingBlock(bb4);
+
+ BuildingBlock bb4 = new BuildingBlock().setBpmnFlowName("CreateNetworkBB").setKey("1");
+ ExecuteBuildingBlock ebb4 = new ExecuteBuildingBlock().setBuildingBlock(bb4);
executeFlows.add(ebb4);
- ExecuteBuildingBlock ebb5 = new ExecuteBuildingBlock();
- BuildingBlock bb5 = new BuildingBlock();
- bb5.setBpmnFlowName("ActivateNetworkBB");
- bb5.setKey("0");
- ebb5.setBuildingBlock(bb5);
+
+ BuildingBlock bb5 = new BuildingBlock().setBpmnFlowName("ActivateNetworkBB").setKey("0");
+ ExecuteBuildingBlock ebb5 = new ExecuteBuildingBlock().setBuildingBlock(bb5);
executeFlows.add(ebb5);
- ExecuteBuildingBlock ebb6 = new ExecuteBuildingBlock();
- BuildingBlock bb6 = new BuildingBlock();
- bb6.setBpmnFlowName("ActivateNetworkBB");
- bb6.setKey("1");
- ebb6.setBuildingBlock(bb6);
+
+ BuildingBlock bb6 = new BuildingBlock().setBpmnFlowName("ActivateNetworkBB").setKey("1");
+ ExecuteBuildingBlock ebb6 = new ExecuteBuildingBlock().setBuildingBlock(bb6);
executeFlows.add(ebb6);
List<ExecuteBuildingBlock> sorted =
@@ -1752,41 +1741,29 @@ public class WorkflowActionTest extends BaseTaskTest {
@Test
public void sortExecutionPathByObjectForVlanTaggingDeleteTest() throws Exception {
List<ExecuteBuildingBlock> executeFlows = new ArrayList<>();
- ExecuteBuildingBlock ebb = new ExecuteBuildingBlock();
- BuildingBlock bb = new BuildingBlock();
- bb.setBpmnFlowName("DeactivateNetworkBB");
- bb.setKey("0");
- ebb.setBuildingBlock(bb);
+
+ BuildingBlock bb = new BuildingBlock().setBpmnFlowName("DeactivateNetworkBB").setKey("0");
+ ExecuteBuildingBlock ebb = new ExecuteBuildingBlock().setBuildingBlock(bb);
executeFlows.add(ebb);
- ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock();
- BuildingBlock bb2 = new BuildingBlock();
- bb2.setBpmnFlowName("DeactivateNetworkBB");
- bb2.setKey("1");
- ebb2.setBuildingBlock(bb2);
+
+ BuildingBlock bb2 = new BuildingBlock().setBpmnFlowName("DeactivateNetworkBB").setKey("1");
+ ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock().setBuildingBlock(bb2);
executeFlows.add(ebb2);
- ExecuteBuildingBlock ebb3 = new ExecuteBuildingBlock();
- BuildingBlock bb3 = new BuildingBlock();
- bb3.setBpmnFlowName("DeleteNetworkBB");
- bb3.setKey("0");
- ebb3.setBuildingBlock(bb3);
+
+ BuildingBlock bb3 = new BuildingBlock().setBpmnFlowName("DeleteNetworkBB").setKey("0");
+ ExecuteBuildingBlock ebb3 = new ExecuteBuildingBlock().setBuildingBlock(bb3);
executeFlows.add(ebb3);
- ExecuteBuildingBlock ebb4 = new ExecuteBuildingBlock();
- BuildingBlock bb4 = new BuildingBlock();
- bb4.setBpmnFlowName("DeleteNetworkBB");
- bb4.setKey("1");
- ebb4.setBuildingBlock(bb4);
+
+ BuildingBlock bb4 = new BuildingBlock().setBpmnFlowName("DeleteNetworkBB").setKey("1");
+ ExecuteBuildingBlock ebb4 = new ExecuteBuildingBlock().setBuildingBlock(bb4);
executeFlows.add(ebb4);
- ExecuteBuildingBlock ebb5 = new ExecuteBuildingBlock();
- BuildingBlock bb5 = new BuildingBlock();
- bb5.setBpmnFlowName("UnassignNetworkBB");
- bb5.setKey("0");
- ebb5.setBuildingBlock(bb5);
+
+ BuildingBlock bb5 = new BuildingBlock().setBpmnFlowName("UnassignNetworkBB").setKey("0");
+ ExecuteBuildingBlock ebb5 = new ExecuteBuildingBlock().setBuildingBlock(bb5);
executeFlows.add(ebb5);
- ExecuteBuildingBlock ebb6 = new ExecuteBuildingBlock();
- BuildingBlock bb6 = new BuildingBlock();
- bb6.setBpmnFlowName("UnassignNetworkBB");
- bb6.setKey("1");
- ebb6.setBuildingBlock(bb6);
+
+ BuildingBlock bb6 = new BuildingBlock().setBpmnFlowName("UnassignNetworkBB").setKey("1");
+ ExecuteBuildingBlock ebb6 = new ExecuteBuildingBlock().setBuildingBlock(bb6);
executeFlows.add(ebb6);
List<ExecuteBuildingBlock> sorted =
@@ -2974,7 +2951,7 @@ public class WorkflowActionTest extends BaseTaskTest {
ExecuteBuildingBlock result = null;
try {
result = workflowAction.buildExecuteBuildingBlock(new OrchestrationFlow(), null, null, null, null, null,
- false, null, null, null, false, null, true);
+ false, null, null, null, false, null, null, true);
} catch (NullPointerException e) {
fail("NullPointerException should not be thrown when 'resource' is null");
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/MultiStageSkipListenerTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/MultiStageSkipListenerTest.java
index 82d610fa97..9d208f41e8 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/MultiStageSkipListenerTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/MultiStageSkipListenerTest.java
@@ -90,13 +90,13 @@ public class MultiStageSkipListenerTest {
WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
workflowResourceIds.setServiceInstanceId("serviceInstanceId");
workflowResourceIds.setVnfId(vnfId);
+ BuildingBlock bb = new BuildingBlock().setBpmnFlowName("AssignVfModuleBB");
+ ExecuteBuildingBlock ebb = new ExecuteBuildingBlock().setResourceId(vfModuleId).setBuildingBlock(bb)
+ .setWorkflowResourceIds(workflowResourceIds);
+ flowsToExecute.add(ebb);
flowsToExecute.add(new ExecuteBuildingBlock());
flowsToExecute.add(new ExecuteBuildingBlock());
- flowsToExecute.add(new ExecuteBuildingBlock());
- flowsToExecute.get(0).setResourceId(vfModuleId);
- flowsToExecute.get(0).setBuildingBlock(new BuildingBlock());
- flowsToExecute.get(0).getBuildingBlock().setBpmnFlowName("AssignVfModuleBB");
- flowsToExecute.get(0).setWorkflowResourceIds(workflowResourceIds);
+
BuildingBlockExecution execution = new DelegateExecutionImpl(new DelegateExecutionFake());
org.onap.aai.domain.yang.VfModule vfModule = new org.onap.aai.domain.yang.VfModule();