aboutsummaryrefslogtreecommitdiffstats
path: root/bpmn/so-bpmn-tasks/src
diff options
context:
space:
mode:
Diffstat (limited to 'bpmn/so-bpmn-tasks/src')
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCAssignTasks.java22
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java12
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/SdnCommonTasks.java49
-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
-rw-r--r--bpmn/so-bpmn-tasks/src/test/resources/__files/SDNCClientPut200Response.json15
-rw-r--r--bpmn/so-bpmn-tasks/src/test/resources/__files/SDNCClientPut404Response.json8
10 files changed, 325 insertions, 254 deletions
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCAssignTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCAssignTasks.java
index 39f4c7822a..5f263e8b4b 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCAssignTasks.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCAssignTasks.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.
@@ -73,7 +73,7 @@ public class SDNCAssignTasks {
public void assignVnf(BuildingBlockExecution execution) {
try {
- GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
+ GeneralBuildingBlock gBBInput = execution.getVariable("generalBuildingBlock");
RequestContext requestContext = gBBInput.getRequestContext();
ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID, execution.getLookupMap().get(ResourceKey.SERVICE_INSTANCE_ID));
GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID, execution.getLookupMap().get(ResourceKey.GENERIC_VNF_ID));
@@ -85,7 +85,7 @@ public class SDNCAssignTasks {
exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
}
}
-
+
public void assignVfModule(BuildingBlockExecution execution) {
try {
GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
@@ -101,14 +101,14 @@ public class SDNCAssignTasks {
}
Customer customer = gBBInput.getCustomer();
CloudRegion cloudRegion = gBBInput.getCloudRegion();
-
- String response = sdncVfModuleResources.assignVfModule(vfModule, volumeGroup, vnf, serviceInstance, customer, cloudRegion, requestContext);
+
+ String response = sdncVfModuleResources.assignVfModule(vfModule, volumeGroup, vnf, serviceInstance, customer, cloudRegion, requestContext);
execution.setVariable("SDNCAssignResponse_"+ vfModule.getVfModuleId(), response);
- } catch (Exception ex) {
+ } catch (Exception ex) {
exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
}
}
-
+
/**
* BPMN access method to perform Assign action on SDNC for L3Network
* @param execution
@@ -117,14 +117,14 @@ public class SDNCAssignTasks {
public void assignNetwork(BuildingBlockExecution execution) {
try {
GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
-
+
L3Network l3network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID, execution.getLookupMap().get(ResourceKey.NETWORK_ID));
ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID, execution.getLookupMap().get(ResourceKey.SERVICE_INSTANCE_ID));
-
+
Customer customer = gBBInput.getCustomer();
RequestContext requestContext = gBBInput.getRequestContext();
CloudRegion cloudRegion = gBBInput.getCloudRegion();
-
+
sdncNetworkResources.assignNetwork(l3network, serviceInstance, customer, requestContext, cloudRegion);
} catch (Exception ex) {
exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
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 9e4b01eea5..d3f817c2a5 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
@@ -221,7 +221,7 @@ public class WorkflowActionBBTasks {
}
public void checkRetryStatus(DelegateExecution execution) {
- if (execution.getVariable("handlingCode") == "Retry") {
+ if (execution.getVariable("handlingCode").equals("Retry")) {
int currSequence = (int) execution.getVariable("gCurrentSequence");
currSequence--;
execution.setVariable("gCurrentSequence", currSequence);
@@ -239,8 +239,9 @@ public class WorkflowActionBBTasks {
List<ExecuteBuildingBlock> flowsToExecute = (List<ExecuteBuildingBlock>) execution
.getVariable("flowsToExecute");
List<ExecuteBuildingBlock> rollbackFlows = new ArrayList();
- int currentSequence = (int) execution.getVariable(G_CURRENT_SEQUENCE) - 1;
- for (int i = flowsToExecute.size() - 1; i >= 0; i--) {
+ int currentSequence = (int) execution.getVariable(G_CURRENT_SEQUENCE) + 1;
+ int listSize = flowsToExecute.size();
+ for (int i = listSize - 1; i >= 0; i--) {
if (i >= currentSequence) {
flowsToExecute.remove(i);
} else {
@@ -248,11 +249,13 @@ public class WorkflowActionBBTasks {
BuildingBlock bb = flowsToExecute.get(i).getBuildingBlock();
String flowName = flowsToExecute.get(i).getBuildingBlock().getBpmnFlowName();
if (flowName.contains("Assign")) {
- flowName = "Unassign" + flowName.substring(7, flowName.length());
+ flowName = "Unassign" + flowName.substring(6, flowName.length());
} else if (flowName.contains("Create")) {
flowName = "Delete" + flowName.substring(6, flowName.length());
} else if (flowName.contains("Activate")) {
flowName = "Deactivate" + flowName.substring(8, flowName.length());
+ }else{
+ continue;
}
flowsToExecute.get(i).getBuildingBlock().setBpmnFlowName(flowName);
rollbackFlows.add(flowsToExecute.get(i));
@@ -262,7 +265,6 @@ public class WorkflowActionBBTasks {
execution.setVariable("isRollbackNeeded", false);
else
execution.setVariable("isRollbackNeeded", true);
-
execution.setVariable("flowsToExecute", rollbackFlows);
execution.setVariable("handlingCode", "PreformingRollback");
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/SdnCommonTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/SdnCommonTasks.java
index aefb84c606..ee1d432b6f 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/SdnCommonTasks.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/SdnCommonTasks.java
@@ -26,21 +26,14 @@ import java.util.List;
import org.apache.commons.lang.StringUtils;
import org.apache.http.HttpStatus;
-import org.json.JSONObject;
import org.onap.so.client.exception.BadResponseException;
import org.onap.so.client.exception.MapperException;
import org.onap.so.logger.MessageEnum;
import org.onap.so.logger.MsoLogger;
-import org.onap.so.logging.jaxrs.filter.SpringClientFilter;
-import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
-import org.springframework.http.ResponseEntity;
-import org.springframework.http.client.BufferingClientHttpRequestFactory;
-import org.springframework.http.client.SimpleClientHttpRequestFactory;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
-import org.springframework.web.client.RestTemplate;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.core.JsonProcessingException;
@@ -99,24 +92,32 @@ public class SdnCommonTasks {
* @return
* @throws BadResponseException
*/
- public String validateSDNResponse(LinkedHashMap<?, ?> output) throws BadResponseException {
- if (CollectionUtils.isEmpty(output)) {
- msoLogger.error(MessageEnum.RA_RESPONSE_FROM_SDNC, NO_RESPONSE_FROM_SDNC, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, NO_RESPONSE_FROM_SDNC);
- throw new BadResponseException(NO_RESPONSE_FROM_SDNC);
+ public String validateSDNResponse(LinkedHashMap<?, ?> output) throws BadResponseException {
+ if (CollectionUtils.isEmpty(output)) {
+ msoLogger.error(MessageEnum.RA_RESPONSE_FROM_SDNC, NO_RESPONSE_FROM_SDNC, "BPMN",
+ MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, NO_RESPONSE_FROM_SDNC);
+ throw new BadResponseException(NO_RESPONSE_FROM_SDNC);
+ }
+ LinkedHashMap<?, ?> embeddedResponse =(LinkedHashMap<?, ?>) output.get("output");
+ String responseCode = "";
+ String responseMessage = "";
+ if (embeddedResponse != null) {
+ responseCode = (String) embeddedResponse.get(RESPONSE_CODE);
+ responseMessage = (String) embeddedResponse.get(RESPONSE_MESSAGE);
}
- String responseCode = (String) output.get(RESPONSE_CODE);
- String responseMessage = (String) output.get(RESPONSE_MESSAGE);
- msoLogger.info("ResponseCode: " + responseCode + " ResponseMessage: " + responseMessage);
- int code = StringUtils.isNotEmpty(responseCode) ? Integer.parseInt(responseCode) : 0;
- if (isHttpCodeSuccess(code)) {
- msoLogger.info("Successful Response from SDNC");
- return responseMessage;
- } else {
- String errorMessage = String.format(SDNC_CODE_NOT_0_OR_IN_200_299, responseMessage);
- msoLogger.error(MessageEnum.RA_RESPONSE_FROM_SDNC, errorMessage, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.DataError, errorMessage);
- throw new BadResponseException(errorMessage);
- }
- }
+
+ msoLogger.info("ResponseCode: " + responseCode + " ResponseMessage: " + responseMessage);
+ int code = StringUtils.isNotEmpty(responseCode) ? Integer.parseInt(responseCode) : 0;
+ if (isHttpCodeSuccess(code)) {
+ msoLogger.info("Successful Response from SDNC");
+ return responseMessage;
+ } else {
+ String errorMessage = String.format(SDNC_CODE_NOT_0_OR_IN_200_299, responseMessage);
+ msoLogger.error(MessageEnum.RA_RESPONSE_FROM_SDNC, errorMessage, "BPMN", MsoLogger.getServiceName(),
+ MsoLogger.ErrorCode.DataError, errorMessage);
+ throw new BadResponseException(errorMessage);
+ }
+ }
/***
*
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);
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/resources/__files/SDNCClientPut200Response.json b/bpmn/so-bpmn-tasks/src/test/resources/__files/SDNCClientPut200Response.json
new file mode 100644
index 0000000000..286ce4c844
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/test/resources/__files/SDNCClientPut200Response.json
@@ -0,0 +1,15 @@
+{
+ "output": {
+ "svc-request-id": "5d24d40e-4c77-4c06-94a3-6d168c47a57c",
+ "network-response-information": {
+ "instance-id": "4063e0aa-af13-4872-8473-b40c94f9316b",
+ "object-path": "restconf/config/GENERIC-RESOURCE-API:services/service/2c9c7996-75a7-4f92-becc-9e13e8bd288a/service-data/networks/network/4063e0aa-af13-4872-8473-b40c94f9316b/network-data/network-topology/"
+ },
+ "response-code": "200",
+ "service-response-information": {
+ "instance-id": "2c9c7996-75a7-4f92-becc-9e13e8bd288a"
+ },
+ "response-message": "",
+ "ack-final-indicator": "Y"
+ }
+}
diff --git a/bpmn/so-bpmn-tasks/src/test/resources/__files/SDNCClientPut404Response.json b/bpmn/so-bpmn-tasks/src/test/resources/__files/SDNCClientPut404Response.json
new file mode 100644
index 0000000000..cf0254886d
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/test/resources/__files/SDNCClientPut404Response.json
@@ -0,0 +1,8 @@
+{
+ "output": {
+ "svc-request-id": "086a7a09-1470-4977-8b3e-307488b8811a",
+ "response-code": "404",
+ "response-message": "invalid input: the service-instance does not have any service data in SDNC",
+ "ack-final-indicator": "Y"
+ }
+}