summaryrefslogtreecommitdiffstats
path: root/bpmn/so-bpmn-tasks/src/test/java/org
diff options
context:
space:
mode:
authorRob Daugherty <rd472p@att.com>2018-09-21 15:24:50 +0000
committerGerrit Code Review <gerrit@onap.org>2018-09-21 15:24:50 +0000
commit47b07012807ef3b3c6d39f8bb2afbe21e51dfffd (patch)
tree83f86b157f0811bb497550ae670dbf1a8791adbc /bpmn/so-bpmn-tasks/src/test/java/org
parentbe96dc7c39eed6142430d8c0486b1140a5c3a921 (diff)
parenta9696cdf3dd5da824eb23456b39e2897a15f03a8 (diff)
Merge "various bugfixes for casablanca"
Diffstat (limited to 'bpmn/so-bpmn-tasks/src/test/java/org')
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/common/data/TestDataSetup.java319
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCAssignTasksTest.java35
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksTest.java67
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdn/common/SdnCommonTasksTest.java22
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/SDNCClientTest.java30
5 files changed, 259 insertions, 214 deletions
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/common/data/TestDataSetup.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/common/data/TestDataSetup.java
index fb9533091b..b5bb0bed94 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/common/data/TestDataSetup.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/common/data/TestDataSetup.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.
@@ -58,6 +58,7 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.VpnBinding;
import org.onap.so.bpmn.servicedecomposition.bbobjects.VpnBondingLink;
import org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock;
import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
+import org.onap.so.bpmn.servicedecomposition.generalobjects.License;
import org.onap.so.bpmn.servicedecomposition.generalobjects.OrchestrationContext;
import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext;
import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestParameters;
@@ -88,20 +89,20 @@ public class TestDataSetup{
private int volumeGroupCounter;
private int vpnBindingCounter;
private int vpnBondingLinkCounter;
-
+
protected BuildingBlockExecution execution;
-
+
protected GeneralBuildingBlock gBBInput;
-
+
protected HashMap<ResourceKey, String> lookupKeyMap;
-
+
protected ExtractPojosForBB extractPojosForBB = new ExtractPojosForBB();
-
+
@Rule
public ExpectedException expectedException = ExpectedException.none();
-
+
protected DelegateExecution delegateExecution;
-
+
@Before
public void buildingBlockTestDataSetupBefore() {
collectionCounter = 0;
@@ -120,183 +121,183 @@ public class TestDataSetup{
volumeGroupCounter = 0;
vpnBindingCounter = 0;
vpnBondingLinkCounter = 0;
-
+
execution = new DelegateExecutionImpl(new ExecutionImpl());
execution.setVariable("testProcessKey", "testProcessKeyValue");
-
+
gBBInput = new GeneralBuildingBlock();
execution.setVariable("gBBInput", gBBInput);
-
+
lookupKeyMap = new HashMap<ResourceKey, String>();
execution.setVariable("lookupKeyMap", lookupKeyMap);
-
+
ExecutionImpl mockExecutionImpl = mock(ExecutionImpl.class);
doReturn("test").when(mockExecutionImpl).getProcessInstanceId();
-
+
ExecutionImpl executionImpl = new ExecutionImpl();
executionImpl.setProcessInstance(mockExecutionImpl);
-
+
delegateExecution = (DelegateExecution) executionImpl;
delegateExecution.setVariable("testProcessKey", "testProcessKeyValue");
}
-
+
public Map<String, String> buildUserInput() {
Map<String, String> userInput = new HashMap<>();
userInput.put("testUserInputKey", "testUserInputValue");
-
+
return userInput;
}
-
+
public Map<String, String> setUserInput() {
Map<String, String> userInput = buildUserInput();
-
+
gBBInput.setUserInput(userInput);
-
+
return userInput;
}
-
+
public RequestContext buildRequestContext() {
RequestContext requestContext = new RequestContext();
requestContext.setMsoRequestId(UUID.randomUUID().toString());
requestContext.setProductFamilyId("testProductFamilyId");
requestContext.setRequestorId("testRequestorId");
-
+
requestContext.setUserParams(new HashMap<>());
-
+
Map<String,Object> dataMap = new HashMap<>();
dataMap.put("vpnId","testVpnId");
dataMap.put("vpnRegion","testVpnRegion");
dataMap.put("vpnRt","testVpnRt");
dataMap.put("vpnName","vpnName");
dataMap.put("vpnRegion", Arrays.asList(new String[] {"USA", "EMEA", "APAC"}));
-
+
HashMap<String,Object> userParams = new HashMap<>();
userParams.put("vpnData",dataMap);
-
+
List<Map<String,Object>> userParamsList = new ArrayList<>();
userParamsList.add(userParams);
-
+
RequestParameters requestParameters = new RequestParameters();
requestParameters.setUserParams(userParamsList);
requestContext.setRequestParameters(requestParameters);
-
+
return requestContext;
}
-
+
public RequestContext setRequestContext() {
RequestContext requestContext = buildRequestContext();
-
+
gBBInput.setRequestContext(requestContext);
-
+
return requestContext;
}
-
+
public CloudRegion buildCloudRegion() {
CloudRegion cloudRegion = new CloudRegion();
cloudRegion.setLcpCloudRegionId("testLcpCloudRegionId");
cloudRegion.setTenantId("testTenantId");
cloudRegion.setCloudOwner("testCloudOwner");
-
+
return cloudRegion;
}
-
+
public CloudRegion setCloudRegion() {
CloudRegion cloudRegion = buildCloudRegion();
-
+
gBBInput.setCloudRegion(cloudRegion);
-
+
return cloudRegion;
}
-
+
public OrchestrationContext buildOrchestrationContext() {
OrchestrationContext orchestrationContext = new OrchestrationContext();
-
+
return orchestrationContext;
}
-
+
public OrchestrationContext setOrchestrationContext() {
OrchestrationContext orchestrationContext = buildOrchestrationContext();
-
+
gBBInput.setOrchContext(orchestrationContext);
-
+
return orchestrationContext;
}
-
+
public Collection buildCollection() {
collectionCounter++;
-
+
Collection collection = new Collection();
collection.setId("testId" + collectionCounter);
collection.setInstanceGroup(buildInstanceGroup());
-
+
return collection;
}
-
+
public Configuration buildConfiguration() {
configurationCounter++;
-
+
Configuration configuration = new Configuration();
configuration.setConfigurationId("testConfigurationId" + configurationCounter);
configuration.setConfigurationName("testConfigurationName" + configurationCounter);
-
+
ModelInfoConfiguration modelInfoConfiguration = new ModelInfoConfiguration();
modelInfoConfiguration.setModelVersionId("testModelVersionId" + configurationCounter);
modelInfoConfiguration.setModelInvariantId("testModelInvariantId" + configurationCounter);
modelInfoConfiguration.setModelCustomizationId("testModelCustomizationId" + configurationCounter);
-
+
configuration.setModelInfoConfiguration(modelInfoConfiguration);
-
+
return configuration;
}
-
+
public OwningEntity buildOwningEntity() {
owningEntityCounter++;
-
+
OwningEntity owningEntity = new OwningEntity();
owningEntity.setOwningEntityId("testOwningEntityId" + owningEntityCounter);
owningEntity.setOwningEntityName("testOwningEntityName" + owningEntityCounter);
-
+
return owningEntity;
}
-
+
public Project buildProject() {
projectCounter++;
-
+
Project project = new Project();
project.setProjectName("testProjectName" + projectCounter);
-
+
return project;
}
-
+
public ServiceSubscription buildServiceSubscription() {
serviceSubscriptionCounter++;
-
+
ServiceSubscription serviceSubscription = new ServiceSubscription();
serviceSubscription.setTempUbSubAccountId("testTempUbSubAccountId" + serviceSubscriptionCounter);
serviceSubscription.setServiceType("testServiceType" + serviceSubscriptionCounter);
-
+
return serviceSubscription;
}
-
+
public Customer buildCustomer() {
customerCounter++;
-
+
Customer customer = new Customer();
customer.setGlobalCustomerId("testGlobalCustomerId" + customerCounter);
customer.setSubscriberType("testSubscriberType" + customerCounter);
customer.setServiceSubscription(buildServiceSubscription());
-
+
return customer;
}
-
+
public ServiceInstance buildServiceInstance() {
serviceInstanceCounter++;
-
+
ServiceInstance serviceInstance = new ServiceInstance();
serviceInstance.setServiceInstanceId("testServiceInstanceId" + serviceInstanceCounter);
serviceInstance.setServiceInstanceName("testServiceInstanceName" + serviceInstanceCounter);
-
+
ModelInfoServiceInstance modelInfoServiceInstance = new ModelInfoServiceInstance();
modelInfoServiceInstance.setModelInvariantUuid("testModelInvariantUUID" + serviceInstanceCounter);
modelInfoServiceInstance.setModelUuid("testModelUUID" + serviceInstanceCounter);
@@ -304,30 +305,30 @@ public class TestDataSetup{
modelInfoServiceInstance.setModelName("testModelName" + serviceInstanceCounter);
modelInfoServiceInstance.setServiceType("testServiceType" + serviceInstanceCounter);
serviceInstance.setModelInfoServiceInstance(modelInfoServiceInstance);
-
+
serviceInstance.setProject(buildProject());
-
+
serviceInstance.setOwningEntity(buildOwningEntity());
-
+
serviceInstance.setCollection(buildCollection());
-
+
serviceInstance.getConfigurations().add(buildConfiguration());
-
+
return serviceInstance;
}
-
+
public ServiceInstance setServiceInstance() {
ServiceInstance serviceInstance = buildServiceInstance();
-
+
if(gBBInput.getCustomer() == null) {
gBBInput.setCustomer(buildCustomer());
}
gBBInput.getCustomer().getServiceSubscription().getServiceInstances().add(serviceInstance);
lookupKeyMap.put(ResourceKey.SERVICE_INSTANCE_ID, serviceInstance.getServiceInstanceId());
-
+
return serviceInstance;
}
-
+
public Customer setCustomer() {
if(gBBInput.getCustomer() != null) return gBBInput.getCustomer();
Customer customer = new Customer();
@@ -337,64 +338,64 @@ public class TestDataSetup{
customer.setServiceSubscription(buildServiceSubscription());
gBBInput.setCustomer(customer);
-
+
return customer;
}
-
+
public Collection setCollection() {
Collection collection = new Collection();
collection.setId("testId");
-
+
ServiceInstance serviceInstance = null;
-
+
try {
serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID, execution.getLookupMap().get(ResourceKey.SERVICE_INSTANCE_ID));
} catch(BBObjectNotFoundException e) {
serviceInstance = setServiceInstance();
}
-
+
serviceInstance.setCollection(collection);
-
+
return collection;
}
-
+
public InstanceGroup setInstanceGroup() {
InstanceGroup instanceGroup = new InstanceGroup();
instanceGroup.setId("testId");
instanceGroup.setInstanceGroupFunction("testInstanceGroupFunction");
-
+
Collection collection = null;
-
+
try {
ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID, execution.getLookupMap().get(ResourceKey.SERVICE_INSTANCE_ID));
collection = serviceInstance.getCollection();
-
+
if (collection == null) {
collection = setCollection();
}
} catch(BBObjectNotFoundException e) {
collection = setCollection();
}
-
+
collection.setInstanceGroup(instanceGroup);
-
+
return instanceGroup;
}
-
+
public VpnBinding buildVpnBinding() {
vpnBindingCounter++;
-
+
VpnBinding vpnBinding = new VpnBinding();
vpnBinding.setVpnId("testVpnId" + vpnBindingCounter);
vpnBinding.setVpnName("testVpnName" + vpnBindingCounter);
vpnBinding.setCustomerVpnId("testCustomerVpnId" + vpnBindingCounter);
-
+
return vpnBinding;
}
-
+
public VpnBinding setVpnBinding() {
VpnBinding vpnBinding = buildVpnBinding();
-
+
Customer customer = gBBInput.getCustomer();
if(customer == null){
@@ -403,72 +404,72 @@ public class TestDataSetup{
customer.getVpnBindings().add(vpnBinding);
lookupKeyMap.put(ResourceKey.VPN_ID, vpnBinding.getVpnId());
-
+
return vpnBinding;
}
-
+
public InstanceGroup buildInstanceGroup() {
instanceGroupCounter++;
-
+
InstanceGroup instanceGroup = new InstanceGroup();
instanceGroup.setId("testId" + instanceGroupCounter);
instanceGroup.setInstanceGroupFunction("testInstanceGroupFunction" + instanceGroupCounter);
-
+
return instanceGroup;
}
-
+
public L3Network buildL3Network() {
l3NetworkCounter++;
-
+
L3Network network = new L3Network();
network.setNetworkId("testNetworkId" + l3NetworkCounter);
network.setNetworkName("testNetworkName" + l3NetworkCounter);
network.setNetworkType("testNetworkType" + l3NetworkCounter);
-
+
ModelInfoNetwork modelInfoNetwork = new ModelInfoNetwork();
modelInfoNetwork.setModelInvariantUUID("testModelInvariantUUID" + l3NetworkCounter);
modelInfoNetwork.setModelName("testModelName" + l3NetworkCounter);
modelInfoNetwork.setModelVersion("testModelVersion" + l3NetworkCounter);
modelInfoNetwork.setModelUUID("testModelUUID" + l3NetworkCounter);
network.setModelInfoNetwork(modelInfoNetwork);
-
+
return network;
}
-
+
public L3Network setL3Network() {
L3Network network = buildL3Network();
-
+
ServiceInstance serviceInstance = null;
-
+
try {
serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID, execution.getLookupMap().get(ResourceKey.SERVICE_INSTANCE_ID));
} catch(BBObjectNotFoundException e) {
serviceInstance = setServiceInstance();
}
-
+
serviceInstance.getNetworks().add(network);
lookupKeyMap.put(ResourceKey.NETWORK_ID, network.getNetworkId());
-
+
return network;
}
-
+
public GenericVnf buildGenericVnf() {
genericVnfCounter++;
-
+
GenericVnf genericVnf = new GenericVnf();
genericVnf.setVnfId("testVnfId" + genericVnfCounter);
genericVnf.setVnfName("testVnfName" + genericVnfCounter);
genericVnf.setVnfType("testVnfType" + genericVnfCounter);
genericVnf.setIpv4OamAddress("10.222.22.2");
-
+
Platform platform = new Platform();
platform.setPlatformName("testPlatformName");
genericVnf.setPlatform(platform);
-
+
LineOfBusiness lob = new LineOfBusiness();
lob.setLineOfBusinessName("testLineOfBusinessName");
genericVnf.setLineOfBusiness(lob);
-
+
ModelInfoGenericVnf modelInfoGenericVnf = new ModelInfoGenericVnf();
modelInfoGenericVnf.setModelName("testModelName" + genericVnfCounter);
modelInfoGenericVnf.setModelCustomizationUuid("testModelCustomizationUUID" + genericVnfCounter);
@@ -476,34 +477,40 @@ public class TestDataSetup{
modelInfoGenericVnf.setModelVersion("testModelVersion" + genericVnfCounter);
modelInfoGenericVnf.setModelUuid("testModelUUID" + genericVnfCounter);
genericVnf.setModelInfoGenericVnf(modelInfoGenericVnf);
-
+
+ License license = new License();
+ List<String> array = new ArrayList<String>();
+ array.add("testPoolUuid");
+ license.setEntitlementPoolUuids(array);
+ genericVnf.setLicense(license);
+
return genericVnf;
}
-
+
public GenericVnf setGenericVnf() {
GenericVnf genericVnf = buildGenericVnf();
-
+
ServiceInstance serviceInstance = null;
-
+
try {
serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID, execution.getLookupMap().get(ResourceKey.SERVICE_INSTANCE_ID));
} catch(BBObjectNotFoundException e) {
serviceInstance = setServiceInstance();
}
-
+
serviceInstance.getVnfs().add(genericVnf);
lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, genericVnf.getVnfId());
-
+
return genericVnf;
}
-
+
public VfModule buildVfModule() {
vfModuleCounter++;
-
+
VfModule vfModule = new VfModule();
vfModule.setVfModuleId("testVfModuleId" + vfModuleCounter);
vfModule.setVfModuleName("testVfModuleName" + vfModuleCounter);
-
+
ModelInfoVfModule modelInfoVfModule = new ModelInfoVfModule();
modelInfoVfModule.setModelInvariantUUID("testModelInvariantUUID" + vfModuleCounter);
modelInfoVfModule.setModelVersion("testModelVersion" + vfModuleCounter);
@@ -511,128 +518,128 @@ public class TestDataSetup{
modelInfoVfModule.setModelName("testModelName" + vfModuleCounter);
modelInfoVfModule.setModelCustomizationUUID("testModelCustomizationUUID" + vfModuleCounter);
vfModule.setModelInfoVfModule(modelInfoVfModule);
-
+
return vfModule;
}
-
+
public VfModule setVfModule() {
VfModule vfModule = buildVfModule();
-
+
GenericVnf genericVnf = null;
-
+
try {
genericVnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID, execution.getLookupMap().get(ResourceKey.GENERIC_VNF_ID));
} catch(BBObjectNotFoundException e) {
genericVnf = setGenericVnf();
}
-
+
genericVnf.getVfModules().add(vfModule);
lookupKeyMap.put(ResourceKey.VF_MODULE_ID, vfModule.getVfModuleId());
-
+
return vfModule;
}
-
+
public VolumeGroup buildVolumeGroup() {
volumeGroupCounter++;
-
+
VolumeGroup volumeGroup = new VolumeGroup();
volumeGroup.setVolumeGroupId("testVolumeGroupId" + volumeGroupCounter);
volumeGroup.setVolumeGroupName("testVolumeGroupName" + volumeGroupCounter);
volumeGroup.setHeatStackId("testHeatStackId" + volumeGroupCounter);
-
+
return volumeGroup;
}
-
+
public VolumeGroup setVolumeGroup() {
VolumeGroup volumeGroup = buildVolumeGroup();
-
+
GenericVnf genericVnf = null;
-
+
try {
genericVnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID, execution.getLookupMap().get(ResourceKey.GENERIC_VNF_ID));
} catch(BBObjectNotFoundException e) {
genericVnf = setGenericVnf();
}
-
+
genericVnf.getVolumeGroups().add(volumeGroup);
lookupKeyMap.put(ResourceKey.VOLUME_GROUP_ID, volumeGroup.getVolumeGroupId());
-
+
return volumeGroup;
}
-
+
public Pnf buildPnf() {
pnfCounter++;
-
+
Pnf pnf = new Pnf();
pnf.setPnfId("testPnfId" + pnfCounter);
pnf.setPnfName("testPnfName" + pnfCounter);
-
+
return pnf;
}
-
+
public ServiceProxy buildServiceProxy() {
serviceProxyCounter++;
-
+
ServiceProxy serviceProxy = new ServiceProxy();
serviceProxy.setServiceInstance(buildServiceInstance());
serviceProxy.getServiceInstance().getVnfs().add(buildGenericVnf());
-
+
Pnf primaryPnf = buildPnf();
primaryPnf.setRole("Primary");
serviceProxy.getServiceInstance().getPnfs().add(primaryPnf);
-
+
Pnf secondaryPnf = buildPnf();
secondaryPnf.setRole("Secondary");
serviceProxy.getServiceInstance().getPnfs().add(secondaryPnf);
-
+
return serviceProxy;
}
-
+
public VpnBondingLink buildVpnBondingLink() {
vpnBondingLinkCounter++;
-
+
VpnBondingLink vpnBondingLink = new VpnBondingLink();
vpnBondingLink.setVpnBondingLinkId("testVpnBondingLinkId" + vpnBondingLinkCounter);
-
+
Configuration vnrConfiguration = buildConfiguration();
- vnrConfiguration.setNetwork(buildL3Network());
+ vnrConfiguration.setNetwork(buildL3Network());
vpnBondingLink.setVnrConfiguration(vnrConfiguration);
vpnBondingLink.setVrfConfiguration(buildConfiguration());
-
+
vpnBondingLink.setInfrastructureServiceProxy(buildServiceProxy());
-
+
vpnBondingLink.setTransportServiceProxy(buildServiceProxy());
-
+
return vpnBondingLink;
}
-
+
public VpnBondingLink setVpnBondingLink() {
VpnBondingLink vpnBondingLink = buildVpnBondingLink();
-
+
ServiceInstance serviceInstance = null;
-
+
try {
serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID, execution.getLookupMap().get(ResourceKey.SERVICE_INSTANCE_ID));
} catch(BBObjectNotFoundException e) {
serviceInstance = setServiceInstance();
}
-
+
serviceInstance.getVpnBondingLinks().add(vpnBondingLink);
lookupKeyMap.put(ResourceKey.VPN_BONDING_LINK_ID, vpnBondingLink.getVpnBondingLinkId());
return vpnBondingLink;
}
-
+
public Customer setAvpnCustomer() {
Customer customer = buildCustomer();
-
+
gBBInput.setCustomer(customer);
-
+
return customer;
}
-
+
public ServiceProxy setServiceProxy(String uniqueIdentifier, String type) {
ServiceProxy serviceProxy = new ServiceProxy();
serviceProxy.setId("testProxyId" + uniqueIdentifier);
@@ -658,12 +665,12 @@ public class TestDataSetup{
modelInfo.setModelName("testProxyModelName" + uniqueIdentifier);
modelInfo.setModelUuid("testProxyModelUuid" + uniqueIdentifier);
modelInfo.setModelVersion("testProxyModelVersion" + uniqueIdentifier);
-
+
ar.setModelInfoAllottedResource(modelInfo);
-
+
return ar;
}
-
+
public Configuration setConfiguration () {
Configuration config = new Configuration();
config.setConfigurationId("testConfigurationId");
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCAssignTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCAssignTasksTest.java
index 6a40db3eaa..cc96326563 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCAssignTasksTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCAssignTasksTest.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.
@@ -44,7 +44,7 @@ import org.springframework.beans.factory.annotation.Autowired;
public class SDNCAssignTasksTest extends BaseTaskTest{
@Autowired
private SDNCAssignTasks sdncAssignTasks;
-
+
private L3Network network;
private ServiceInstance serviceInstance;
private RequestContext requestContext;
@@ -53,7 +53,7 @@ public class SDNCAssignTasksTest extends BaseTaskTest{
private VfModule vfModule;
private VolumeGroup volumeGroup;
private Customer customer;
-
+
@Before
public void before() {
customer = setCustomer();
@@ -66,7 +66,7 @@ public class SDNCAssignTasksTest extends BaseTaskTest{
volumeGroup = setVolumeGroup();
}
-
+
@Test
public void assignServiceInstanceTest() throws Exception {
doReturn("response").when(sdncServiceInstanceResources).assignServiceInstance(serviceInstance, customer, requestContext);
@@ -76,35 +76,36 @@ public class SDNCAssignTasksTest extends BaseTaskTest{
verify(sdncServiceInstanceResources, times(1)).assignServiceInstance(serviceInstance, customer, requestContext);
assertTrue(execution.getVariable("SDNCResponse").equals("response"));
}
-
+
@Test
public void assignServiceInstanceExceptionTest() throws Exception {
expectedException.expect(BpmnError.class);
-
+
doThrow(Exception.class).when(sdncServiceInstanceResources).assignServiceInstance(serviceInstance, customer, requestContext);
sdncAssignTasks.assignServiceInstance(execution);
}
-
+
@Test
public void assignVnfTest() throws Exception {
doReturn("response").when(sdncVnfResources).assignVnf(genericVnf, serviceInstance, customer, cloudRegion, requestContext, false);
+ execution.setVariable("generalBuildingBlock", gBBInput);
sdncAssignTasks.assignVnf(execution);
verify(sdncVnfResources, times(1)).assignVnf(genericVnf, serviceInstance,customer, cloudRegion, requestContext, false);
assertTrue(execution.getVariable("SDNCResponse").equals("response"));
}
-
+
@Test
public void assignVnfExceptionTest() throws Exception {
expectedException.expect(BpmnError.class);
-
+
doThrow(Exception.class).when(sdncVnfResources).assignVnf(genericVnf, serviceInstance, customer, cloudRegion, requestContext, false);
-
+
sdncAssignTasks.assignVnf(execution);
}
-
+
@Test
public void assignVfModuleTest() throws Exception {
doReturn("response").when(sdncVfModuleResources).assignVfModule(vfModule, volumeGroup, genericVnf, serviceInstance, customer, cloudRegion, requestContext);
@@ -114,16 +115,16 @@ public class SDNCAssignTasksTest extends BaseTaskTest{
verify(sdncVfModuleResources, times(1)).assignVfModule(vfModule, volumeGroup, genericVnf, serviceInstance, customer, cloudRegion, requestContext);
assertTrue(execution.getVariable("SDNCAssignResponse_" + vfModule.getVfModuleId()).equals("response"));
}
-
+
@Test
public void assignVfModuleExceptionTest() throws Exception {
expectedException.expect(BpmnError.class);
-
+
doThrow(Exception.class).when(sdncVfModuleResources).assignVfModule(vfModule, volumeGroup, genericVnf, serviceInstance, customer, cloudRegion, requestContext);
sdncAssignTasks.assignVfModule(execution);
}
-
+
@Test
public void assignNetworkTest() throws Exception {
doReturn("response").when(sdncNetworkResources).assignNetwork(network, serviceInstance, customer, requestContext, cloudRegion);
@@ -132,11 +133,11 @@ public class SDNCAssignTasksTest extends BaseTaskTest{
verify(sdncNetworkResources, times(1)).assignNetwork(network, serviceInstance, customer, requestContext, cloudRegion);
}
-
+
@Test
public void assignNetworkExceptionTest() throws Exception {
expectedException.expect(BpmnError.class);
-
+
doThrow(Exception.class).when(sdncNetworkResources).assignNetwork(network, serviceInstance, customer, requestContext, cloudRegion);
sdncAssignTasks.assignNetwork(execution);
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 27173b7502..6cac238482 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
@@ -153,55 +153,56 @@ public class WorkflowActionBBTasksTest extends BaseTaskTest {
List<ExecuteBuildingBlock> flowsToExecute = new ArrayList();
ExecuteBuildingBlock ebb1 = new ExecuteBuildingBlock();
BuildingBlock bb1 = new BuildingBlock();
- bb1.setBpmnFlowName("CreateNetworkBB");
+ bb1.setBpmnFlowName("AssignVfModuleBB");
flowsToExecute.add(ebb1);
ebb1.setBuildingBlock(bb1);
ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock();
BuildingBlock bb2 = new BuildingBlock();
- bb2.setBpmnFlowName("ActivateNetworkBB");
+ bb2.setBpmnFlowName("CreateVfModuleBB");
+ flowsToExecute.add(ebb2);
+ ebb2.setBuildingBlock(bb2);
+ ExecuteBuildingBlock ebb3 = new ExecuteBuildingBlock();
+ BuildingBlock bb3 = new BuildingBlock();
+ bb3.setBpmnFlowName("ActivateVfModuleBB");
+ flowsToExecute.add(ebb3);
+ ebb3.setBuildingBlock(bb3);
+
+ execution.setVariable("flowsToExecute", flowsToExecute);
+ execution.setVariable("gCurrentSequence", 2);
+
+ workflowActionBBTasks.rollbackExecutionPath(execution);
+ List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
+ assertEquals(ebbs.get(0).getBuildingBlock().getBpmnFlowName(),"DeactivateVfModuleBB");
+ assertEquals(ebbs.get(1).getBuildingBlock().getBpmnFlowName(),"DeleteVfModuleBB");
+ assertEquals(ebbs.get(2).getBuildingBlock().getBpmnFlowName(),"UnassignVfModuleBB");
+ }
+
+ @Test
+ public void rollbackExecutionPathUnfinishedFlowTest(){
+ List<ExecuteBuildingBlock> flowsToExecute = new ArrayList();
+ ExecuteBuildingBlock ebb1 = new ExecuteBuildingBlock();
+ BuildingBlock bb1 = new BuildingBlock();
+ bb1.setBpmnFlowName("AssignVfModuleBB");
+ flowsToExecute.add(ebb1);
+ ebb1.setBuildingBlock(bb1);
+ ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock();
+ BuildingBlock bb2 = new BuildingBlock();
+ bb2.setBpmnFlowName("CreateVfModuleBB");
flowsToExecute.add(ebb2);
ebb2.setBuildingBlock(bb2);
ExecuteBuildingBlock ebb3 = new ExecuteBuildingBlock();
BuildingBlock bb3 = new BuildingBlock();
- bb3.setBpmnFlowName("CreateVolumeGroupBB");
+ bb3.setBpmnFlowName("ActivateVfModuleBB");
flowsToExecute.add(ebb3);
ebb3.setBuildingBlock(bb3);
- ExecuteBuildingBlock ebb4 = new ExecuteBuildingBlock();
- BuildingBlock bb4 = new BuildingBlock();
- bb4.setBpmnFlowName("ActivateVolumeGroupBB");
- flowsToExecute.add(ebb4);
- ebb4.setBuildingBlock(bb4);
- ExecuteBuildingBlock ebb5 = new ExecuteBuildingBlock();
- BuildingBlock bb5 = new BuildingBlock();
- bb5.setBpmnFlowName("CreateVfModuleBB");
- flowsToExecute.add(ebb5);
- ebb5.setBuildingBlock(bb5);
- ExecuteBuildingBlock ebb6 = new ExecuteBuildingBlock();
- BuildingBlock bb6 = new BuildingBlock();
- bb6.setBpmnFlowName("ActivateVfModuleBB");
- flowsToExecute.add(ebb6);
- ebb6.setBuildingBlock(bb6);
- ExecuteBuildingBlock ebb7 = new ExecuteBuildingBlock();
- BuildingBlock bb7 = new BuildingBlock();
- bb7.setBpmnFlowName("ActivateVnfBB");
- ebb7.setBuildingBlock(bb7);
- flowsToExecute.add(ebb7);
- ExecuteBuildingBlock ebb8 = new ExecuteBuildingBlock();
- BuildingBlock bb8 = new BuildingBlock();
- bb8.setBpmnFlowName("ActivateServiceInstance");
- ebb8.setBuildingBlock(bb8);
- flowsToExecute.add(ebb8);
execution.setVariable("flowsToExecute", flowsToExecute);
- execution.setVariable("gCurrentSequence", 6);
+ execution.setVariable("gCurrentSequence", 1);
workflowActionBBTasks.rollbackExecutionPath(execution);
List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
assertEquals(ebbs.get(0).getBuildingBlock().getBpmnFlowName(),"DeleteVfModuleBB");
- assertEquals(ebbs.get(1).getBuildingBlock().getBpmnFlowName(),"DeactivateVolumeGroupBB");
- assertEquals(ebbs.get(2).getBuildingBlock().getBpmnFlowName(),"DeleteVolumeGroupBB");
- assertEquals(ebbs.get(3).getBuildingBlock().getBpmnFlowName(),"DeactivateNetworkBB");
- assertEquals(ebbs.get(4).getBuildingBlock().getBpmnFlowName(),"DeleteNetworkBB");
+ assertEquals(ebbs.get(1).getBuildingBlock().getBpmnFlowName(),"UnassignVfModuleBB");
}
@Test
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdn/common/SdnCommonTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdn/common/SdnCommonTasksTest.java
index eb17ad0ff9..e30fe660c3 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdn/common/SdnCommonTasksTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdn/common/SdnCommonTasksTest.java
@@ -20,6 +20,8 @@
package org.onap.so.client.sdn.common;
+import static org.junit.Assert.assertEquals;
+
import java.util.LinkedHashMap;
import org.junit.Assert;
@@ -58,10 +60,12 @@ public class SdnCommonTasksTest{
@Test
public void validateSDNResponseTest() throws BadResponseException {
- LinkedHashMap responseMap = new LinkedHashMap();
- responseMap.put("response-code", "0");
- responseMap.put("response-message", "success");
- Assert.assertNotNull(sdnCommonTasks.validateSDNResponse(responseMap));
+ LinkedHashMap<String, Object> responseMap = new LinkedHashMap<>();
+ LinkedHashMap<String, Object> output = new LinkedHashMap<>();
+ output.put("response-code", "0");
+ output.put("response-message", "success");
+ responseMap.put("output", output);
+ assertEquals("success", sdnCommonTasks.validateSDNResponse(responseMap));
}
@Test
@@ -74,10 +78,12 @@ public class SdnCommonTasksTest{
@Test
public void validateSDNResponseTestRespCodeNot200() throws BadResponseException {
expectedException.expect(BadResponseException.class);
- LinkedHashMap responseMap = new LinkedHashMap();
- responseMap.put("response-code", "300");
- responseMap.put("response-message", "Failed");
- Assert.assertNotNull(sdnCommonTasks.validateSDNResponse(responseMap));
+ LinkedHashMap<String, Object> responseMap = new LinkedHashMap<>();
+ LinkedHashMap<String, Object> output = new LinkedHashMap<>();
+ output.put("response-code", "300");
+ output.put("response-message", "Failed");
+ responseMap.put("output", output);
+ sdnCommonTasks.validateSDNResponse(responseMap);
}
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/SDNCClientTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/SDNCClientTest.java
index 2492638520..e24ca339a3 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/SDNCClientTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/SDNCClientTest.java
@@ -22,7 +22,9 @@ package org.onap.so.client.sdnc;
import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
import static com.github.tomakehurst.wiremock.client.WireMock.get;
+import static com.github.tomakehurst.wiremock.client.WireMock.post;
import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
+import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching;
import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig;
import java.io.IOException;
@@ -34,6 +36,7 @@ import org.junit.Test;
import org.onap.so.bpmn.BaseTaskTest;
import org.onap.so.client.exception.BadResponseException;
import org.onap.so.client.exception.MapperException;
+import org.onap.so.client.sdnc.endpoint.SDNCTopology;
import org.skyscreamer.jsonassert.JSONAssert;
import com.github.tomakehurst.wiremock.junit.WireMockRule;
@@ -55,4 +58,31 @@ public class SDNCClientTest extends BaseTaskTest {
String response = SPY_sdncClient.get(queryLink);
JSONAssert.assertEquals(responseJson, response, false);
}
+
+ @Test(expected = BadResponseException.class)
+ public void post404Test() throws BadResponseException, MapperException, IOException {
+ String responseJson = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "SDNCClientPut404Response.json")));
+
+ String queryLink = "/restconf/operations/GENERIC-RESOURCE-API:network-topology-operation/";
+
+ wireMockRule.stubFor(post(urlMatching(queryLink))
+ .willReturn(aResponse().withStatus(200)
+ .withHeader("Content-Type", "application/json").withBody(responseJson)));
+
+ SPY_sdncClient.post("", SDNCTopology.NETWORK);
+ }
+
+ @Test
+ public void post200Test() throws BadResponseException, MapperException, IOException {
+ String responseJson = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "SDNCClientPut200Response.json")));
+
+ String queryLink = "/restconf/operations/GENERIC-RESOURCE-API:network-topology-operation/";
+
+ wireMockRule.stubFor(post(urlMatching(queryLink))
+ .willReturn(aResponse().withStatus(200)
+ .withHeader("Content-Type", "application/json").withBody(responseJson)));
+
+ String response = SPY_sdncClient.post("", SDNCTopology.NETWORK);
+ JSONAssert.assertEquals("", response, false);
+ }
}