summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfPluginAdapterImpl.java47
-rw-r--r--adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/sdncrest/SDNCServiceRequestTask.java4
-rw-r--r--adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/rest/HealthCheckHandler.java4
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java115
-rw-r--r--asdc-controller/src/test/java/org/onap/so/asdc/installer/heat/ToscaResourceInstallerTest.java3
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/AbstractSDNCTask.java22
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCActivateTasks.java13
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCAssignTasks.java18
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCChangeAssignTasks.java14
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCDeactivateTasks.java13
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCUnassignTasks.java15
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCVnfResources.java26
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/VnfTopologyOperationRequestMapper.java6
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCActivateTaskTest.java12
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCAssignTasksTest.java12
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCChangeAssignTasksTest.java12
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCDeactivateTaskTest.java12
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCUnassignTasksTest.java12
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCVnfResourcesTest.java57
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/VnfTopologyOperationRequestMapperTest.java11
-rw-r--r--mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/exceptions/ContactCamundaException.java8
-rw-r--r--mso-api-handlers/mso-api-handler-infra/pom.xml4
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/CamundaRequestHandler.java180
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/E2EServiceInstances.java33
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/OrchestrationRequests.java15
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/RequestHandlerUtils.java49
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/Network.java6
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/ServiceInstance.java6
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/VfModules.java6
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/Vnf.java6
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/Volumes.java6
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/resources/application.yaml4
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/CamundaRequestHandlerTest.java327
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/OrchestrationRequestsTest.java17
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/OrchestrationRequestsUnitTest.java105
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/RequestHandlerUtilsTest.java5
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java13
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/resources/OrchestrationRequest/ActivityInstanceHistoryResponse.json48
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/resources/OrchestrationRequest/OrchestrationFilterResponse.json2
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/resources/OrchestrationRequest/OrchestrationList.json4
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/resources/OrchestrationRequest/ProcessInstanceHistoryResponse.json44
41 files changed, 1008 insertions, 308 deletions
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfPluginAdapterImpl.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfPluginAdapterImpl.java
index c22bb327d4..2d77bf625a 100644
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfPluginAdapterImpl.java
+++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfPluginAdapterImpl.java
@@ -187,11 +187,7 @@ public class MsoVnfPluginAdapterImpl implements MsoVnfAdapter {
Holder<Map<String, String>> outputs) throws VnfException {
logger.debug("Querying VNF " + vnfNameOrId + " in " + cloudOwner + "/" + cloudSiteId + "/" + tenantId);
- // Will capture execution time for metrics
- long startTime = System.currentTimeMillis();
- long subStartTime = System.currentTimeMillis();
-
- VduInstance vduInstance = null;
+ VduInstance vduInstance;
CloudInfo cloudInfo = new CloudInfo(cloudSiteId, cloudOwner, tenantId, null);
VduPlugin vduPlugin = getVduPlugin(cloudSiteId, cloudOwner);
@@ -252,7 +248,6 @@ public class MsoVnfPluginAdapterImpl implements MsoVnfAdapter {
*/
@Override
public void rollbackVnf(VnfRollback rollback) throws VnfException {
- long startTime = System.currentTimeMillis();
// rollback may be null (e.g. if stack already existed when Create was called)
if (rollback == null) {
logger.info(LoggingAnchor.THREE, MessageEnum.RA_ROLLBACK_NULL.toString(), "OpenStack", "rollbackVnf");
@@ -279,7 +274,6 @@ public class MsoVnfPluginAdapterImpl implements MsoVnfAdapter {
// Use the VduPlugin to delete the VF Module.
VduPlugin vduPlugin = getVduPlugin(cloudSiteId, cloudOwner);
- long subStartTime = System.currentTimeMillis();
try {
// TODO: Get a reasonable timeout. Use a global property, or store the creation timeout in rollback object
// and use that.
@@ -336,7 +330,7 @@ public class MsoVnfPluginAdapterImpl implements MsoVnfAdapter {
logger.debug("Unable to convert " + inputValue + " to an integer!", e);
return null;
}
- } else if (type.equalsIgnoreCase("json")) {
+ } else if ("json".equalsIgnoreCase(type)) {
try {
JsonNode jsonNode = JSON_MAPPER.readTree(JSON_MAPPER.writeValueAsString(inputValue));
return jsonNode;
@@ -344,7 +338,7 @@ public class MsoVnfPluginAdapterImpl implements MsoVnfAdapter {
logger.debug("Unable to convert " + inputValue + " to a JsonNode!", e);
return null;
}
- } else if (type.equalsIgnoreCase("boolean")) {
+ } else if ("boolean".equalsIgnoreCase(type)) {
return new Boolean(inputValue.toString());
}
@@ -353,7 +347,7 @@ public class MsoVnfPluginAdapterImpl implements MsoVnfAdapter {
}
private Map<String, String> copyStringOutputs(Map<String, Object> stackOutputs) {
- Map<String, String> stringOutputs = new HashMap<String, String>();
+ Map<String, String> stringOutputs = new HashMap<>();
for (String key : stackOutputs.keySet()) {
if (stackOutputs.get(key) instanceof String) {
stringOutputs.put(key, (String) stackOutputs.get(key));
@@ -447,7 +441,7 @@ public class MsoVnfPluginAdapterImpl implements MsoVnfAdapter {
if (objectMap == null) {
return null;
}
- Map<String, String> stringMap = new HashMap<String, String>();
+ Map<String, String> stringMap = new HashMap<>();
for (String key : objectMap.keySet()) {
if (!stringMap.containsKey(key)) {
Object obj = objectMap.get(key);
@@ -540,8 +534,6 @@ public class MsoVnfPluginAdapterImpl implements MsoVnfAdapter {
String volumeGroupId, String baseVfModuleId, String modelCustomizationUuid, Map<String, Object> inputs,
Boolean failIfExists, Boolean backout, Boolean enableBridge, MsoRequest msoRequest, Holder<String> vnfId,
Holder<Map<String, String>> outputs, Holder<VnfRollback> rollback) throws VnfException {
- // Will capture execution time for metrics
- long startTime = System.currentTimeMillis();
// Require a model customization ID. Every VF Module definition must have one.
if (modelCustomizationUuid == null || modelCustomizationUuid.isEmpty()) {
@@ -665,7 +657,6 @@ public class MsoVnfPluginAdapterImpl implements MsoVnfAdapter {
// Use the VduPlugin.
VduPlugin vduPlugin = getVduPlugin(cloudSiteId, cloudOwner);
- long subStartTime1 = System.currentTimeMillis();
try {
vduInstance = vduPlugin.queryVdu(cloudInfo, vfModuleName);
} catch (VduException me) {
@@ -761,8 +752,7 @@ public class MsoVnfPluginAdapterImpl implements MsoVnfAdapter {
// If a Volume Group was provided, query its outputs for inclusion in Module input parameters
if (volumeGroupId != null) {
- long subStartTime2 = System.currentTimeMillis();
- VduInstance volumeVdu = null;
+ VduInstance volumeVdu;
try {
volumeVdu = vduPlugin.queryVdu(cloudInfo, volumeGroupId);
} catch (VduException me) {
@@ -811,8 +801,7 @@ public class MsoVnfPluginAdapterImpl implements MsoVnfAdapter {
}
if (baseVfModuleId != null) {
- long subStartTime2 = System.currentTimeMillis();
- VduInstance baseVdu = null;
+ VduInstance baseVdu;
try {
baseVdu = vduPlugin.queryVdu(cloudInfo, baseVfModuleId);
} catch (MsoException me) {
@@ -887,19 +876,19 @@ public class MsoVnfPluginAdapterImpl implements MsoVnfAdapter {
// Create the combined set of parameters from the incoming request, base-module outputs,
// volume-module outputs. Also, convert all variables to their native object types.
- HashMap<String, Object> goldenInputs = new HashMap<String, Object>();
- List<String> extraInputs = new ArrayList<String>();
+ HashMap<String, Object> goldenInputs = new HashMap<>();
+ List<String> extraInputs = new ArrayList<>();
Boolean skipInputChecks = false;
if (skipInputChecks) {
- goldenInputs = new HashMap<String, Object>();
+ goldenInputs = new HashMap<>();
for (String key : inputs.keySet()) {
goldenInputs.put(key, inputs.get(key));
}
} else {
// Build maps for the parameters (including aliases) to simplify checks
- HashMap<String, HeatTemplateParam> params = new HashMap<String, HeatTemplateParam>();
+ HashMap<String, HeatTemplateParam> params = new HashMap<>();
Set<HeatTemplateParam> paramSet = heatTemplate.getParameters();
logger.debug("paramSet has " + paramSet.size() + " entries");
@@ -909,7 +898,7 @@ public class MsoVnfPluginAdapterImpl implements MsoVnfAdapter {
// Include aliases.
String alias = htp.getParamAlias();
- if (alias != null && !alias.equals("") && !params.containsKey(alias)) {
+ if (alias != null && !"".equals(alias) && !params.containsKey(alias)) {
params.put(alias, htp);
}
}
@@ -1026,7 +1015,6 @@ public class MsoVnfPluginAdapterImpl implements MsoVnfAdapter {
// Here we go... ready to deploy the VF Module.
- long instantiateVduStartTime = System.currentTimeMillis();
if (backout == null)
backout = true;
@@ -1088,11 +1076,9 @@ public class MsoVnfPluginAdapterImpl implements MsoVnfAdapter {
MsoRequest msoRequest, Holder<Map<String, String>> outputs) throws VnfException {
logger.debug("Deleting VF Module " + vfModuleId + " in " + cloudOwner + "/" + cloudSiteId + "/" + tenantId);
- // Will capture execution time for metrics
- long startTime = System.currentTimeMillis();
// Capture the output parameters on a delete, so need to query first
- VduInstance vduInstance = null;
+ VduInstance vduInstance;
CloudInfo cloudInfo = new CloudInfo(cloudSiteId, cloudOwner, tenantId, null);
// Use the VduPlugin.
@@ -1123,7 +1109,6 @@ public class MsoVnfPluginAdapterImpl implements MsoVnfAdapter {
// - a vnfInstance object with status of NOTFOUND (VDU did not exist, treat as success)
// - a vnfInstance object with status of FAILED (error)
// Also, VduException could be thrown.
- long subStartTime = System.currentTimeMillis();
try {
// TODO: Get an appropriate timeout value - require access to the model
vduPlugin.deleteVdu(cloudInfo, vfModuleId, 5);
@@ -1166,11 +1151,11 @@ public class MsoVnfPluginAdapterImpl implements MsoVnfAdapter {
CloudSite cloudSite = cloudSiteOp.get();
String orchestrator = cloudSite.getOrchestrator();
- if (orchestrator.equalsIgnoreCase("CLOUDIFY")) {
+ if ("CLOUDIFY".equalsIgnoreCase(orchestrator)) {
return cloudifyUtils;
- } else if (orchestrator.equalsIgnoreCase("HEAT")) {
+ } else if ("HEAT".equalsIgnoreCase(orchestrator)) {
return heatUtils;
- } else if (orchestrator.equalsIgnoreCase("MULTICLOUD")) {
+ } else if ("MULTICLOUD".equalsIgnoreCase(orchestrator)) {
return multicloudUtils;
} else {
// Default if cloudSite record exists - return HEAT plugin - will fail later
diff --git a/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/sdncrest/SDNCServiceRequestTask.java b/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/sdncrest/SDNCServiceRequestTask.java
index a68bd3e0be..5697ed56a5 100644
--- a/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/sdncrest/SDNCServiceRequestTask.java
+++ b/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/sdncrest/SDNCServiceRequestTask.java
@@ -88,11 +88,9 @@ public class SDNCServiceRequestTask {
String xml = genSdncReq(request, mappedTunables);
- long sdncStartTime = System.currentTimeMillis();
SDNCResponseCommon response = connector.send(xml, mappedTunables);
- long bpStartTime = System.currentTimeMillis();
- boolean callbackSuccess = bpRestCallback.send(request.getBPNotificationUrl(), response.toJson());
+ bpRestCallback.send(request.getBPNotificationUrl(), response.toJson());
}
private Element addChild(Element parent, String tag) {
diff --git a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/rest/HealthCheckHandler.java b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/rest/HealthCheckHandler.java
index cff36061b1..2dcdf11316 100644
--- a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/rest/HealthCheckHandler.java
+++ b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/rest/HealthCheckHandler.java
@@ -28,8 +28,6 @@ import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.Response;
import org.apache.http.HttpStatus;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
/**
@@ -44,8 +42,6 @@ import org.springframework.stereotype.Component;
@Component
public class HealthCheckHandler {
- private static Logger logger = LoggerFactory.getLogger(HealthCheckHandler.class);
-
private static final String CHECK_HTML =
"<!DOCTYPE html><html><head><meta charset=\"ISO-8859-1\"><title>Health Check</title></head><body>Application ready</body></html>";
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java b/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java
index 94517ccc45..a08206b477 100644
--- a/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java
+++ b/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java
@@ -628,11 +628,12 @@ public class ToscaResourceInstaller {
protected void processNetworks(ToscaResourceStructure toscaResourceStruct, Service service)
throws ArtifactInstallerException {
- List<NodeTemplate> nodeTemplatesVLList = toscaResourceStruct.getSdcCsarHelper().getServiceVlList();
- if (nodeTemplatesVLList != null) {
- for (NodeTemplate vlNode : nodeTemplatesVLList) {
- String networkResourceModelName = vlNode.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME);
+ List<IEntityDetails> vlEntityList = getEntityDetails(toscaResourceStruct, SdcTypes.VL, SdcTypes.SERVICE);
+
+ if (vlEntityList != null) {
+ for (IEntityDetails vlEntity : vlEntityList) {
+ String networkResourceModelName = vlEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_NAME);
TempNetworkHeatTemplateLookup tempNetworkLookUp =
tempNetworkLookupRepo.findFirstBynetworkResourceModelName(networkResourceModelName);
@@ -641,7 +642,7 @@ public class ToscaResourceInstaller {
HeatTemplate heatTemplate =
heatRepo.findByArtifactUuid(tempNetworkLookUp.getHeatTemplateArtifactUuid());
if (heatTemplate != null) {
- NetworkResourceCustomization networkCustomization = createNetwork(vlNode, toscaResourceStruct,
+ NetworkResourceCustomization networkCustomization = createNetwork(vlEntity, toscaResourceStruct,
heatTemplate, tempNetworkLookUp.getAicVersionMax(),
tempNetworkLookUp.getAicVersionMin(), service);
service.getNetworkCustomizations().add(networkCustomization);
@@ -651,7 +652,7 @@ public class ToscaResourceInstaller {
}
} else {
NetworkResourceCustomization networkCustomization =
- createNetwork(vlNode, toscaResourceStruct, null, null, null, service);
+ createNetwork(vlEntity, toscaResourceStruct, null, null, null, service);
service.getNetworkCustomizations().add(networkCustomization);
logger.debug("No NetworkResourceName found in TempNetworkHeatTemplateLookup for "
+ networkResourceModelName);
@@ -1493,13 +1494,13 @@ public class ToscaResourceInstaller {
return cvnfcCustomization;
}
- protected NetworkResourceCustomization createNetwork(NodeTemplate networkNodeTemplate,
+ protected NetworkResourceCustomization createNetwork(IEntityDetails networkEntity,
ToscaResourceStructure toscaResourceStructure, HeatTemplate heatTemplate, String aicMax, String aicMin,
Service service) {
NetworkResourceCustomization networkResourceCustomization =
networkCustomizationRepo.findOneByModelCustomizationUUID(
- networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
+ networkEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
boolean networkUUIDsMatch = true;
// Check to make sure the NetworkResourceUUID on the Customization record matches the NetworkResourceUUID from
@@ -1507,8 +1508,7 @@ public class ToscaResourceInstaller {
// If not we'll update the Customization record with latest from the distribution
if (networkResourceCustomization != null) {
String existingNetworkModelUUID = networkResourceCustomization.getNetworkResource().getModelUUID();
- String latestNetworkModelUUID =
- networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID);
+ String latestNetworkModelUUID = networkEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_UUID);
if (!existingNetworkModelUUID.equals(latestNetworkModelUUID)) {
networkUUIDsMatch = false;
@@ -1519,7 +1519,7 @@ public class ToscaResourceInstaller {
if (networkResourceCustomization != null && !networkUUIDsMatch) {
NetworkResource networkResource =
- createNetworkResource(networkNodeTemplate, toscaResourceStructure, heatTemplate, aicMax, aicMin);
+ createNetworkResource(networkEntity, toscaResourceStructure, heatTemplate, aicMax, aicMin);
networkResourceCustomization.setNetworkResource(networkResource);
@@ -1527,14 +1527,13 @@ public class ToscaResourceInstaller {
} else if (networkResourceCustomization == null) {
- networkResourceCustomization =
- createNetworkResourceCustomization(networkNodeTemplate, toscaResourceStructure);
+ networkResourceCustomization = createNetworkResourceCustomization(networkEntity, toscaResourceStructure);
NetworkResource networkResource = findExistingNetworkResource(service,
- networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
+ networkEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
if (networkResource == null)
- networkResource = createNetworkResource(networkNodeTemplate, toscaResourceStructure, heatTemplate,
- aicMax, aicMin);
+ networkResource =
+ createNetworkResource(networkEntity, toscaResourceStructure, heatTemplate, aicMax, aicMin);
networkResource.addNetworkResourceCustomization(networkResourceCustomization);
networkResourceCustomization.setNetworkResource(networkResource);
@@ -1557,31 +1556,34 @@ public class ToscaResourceInstaller {
return networkResource;
}
- protected NetworkResourceCustomization createNetworkResourceCustomization(NodeTemplate networkNodeTemplate,
+ protected NetworkResourceCustomization createNetworkResourceCustomization(IEntityDetails networkEntity,
ToscaResourceStructure toscaResourceStructure) {
NetworkResourceCustomization networkResourceCustomization = new NetworkResourceCustomization();
networkResourceCustomization.setModelInstanceName(
- testNull(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME)));
+ testNull(networkEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_NAME)));
networkResourceCustomization.setModelCustomizationUUID(
- testNull(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)));
+ testNull(networkEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)));
networkResourceCustomization.setNetworkTechnology(
- testNull(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(networkNodeTemplate,
- SdcPropertyNames.PROPERTY_NAME_NETWORKTECHNOLOGY)));
- networkResourceCustomization.setNetworkType(testNull(toscaResourceStructure.getSdcCsarHelper()
- .getNodeTemplatePropertyLeafValue(networkNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NETWORKTYPE)));
- networkResourceCustomization.setNetworkRole(testNull(toscaResourceStructure.getSdcCsarHelper()
- .getNodeTemplatePropertyLeafValue(networkNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NETWORKROLE)));
- networkResourceCustomization.setNetworkScope(testNull(toscaResourceStructure.getSdcCsarHelper()
- .getNodeTemplatePropertyLeafValue(networkNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NETWORKSCOPE)));
+ getLeafPropertyValue(networkEntity, SdcPropertyNames.PROPERTY_NAME_NETWORKTECHNOLOGY));
+
+ networkResourceCustomization
+ .setNetworkType(getLeafPropertyValue(networkEntity, SdcPropertyNames.PROPERTY_NAME_NETWORKTYPE));
+
+ networkResourceCustomization
+ .setNetworkRole(getLeafPropertyValue(networkEntity, SdcPropertyNames.PROPERTY_NAME_NETWORKROLE));
+
+ networkResourceCustomization
+ .setNetworkScope(getLeafPropertyValue(networkEntity, SdcPropertyNames.PROPERTY_NAME_NETWORKSCOPE));
+
return networkResourceCustomization;
}
- protected NetworkResource createNetworkResource(NodeTemplate networkNodeTemplate,
+ protected NetworkResource createNetworkResource(IEntityDetails vlEntity,
ToscaResourceStructure toscaResourceStructure, HeatTemplate heatTemplate, String aicMax, String aicMin) {
NetworkResource networkResource = new NetworkResource();
- String providerNetwork = toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(
- networkNodeTemplate, SdcPropertyNames.PROPERTY_NAME_PROVIDERNETWORK_ISPROVIDERNETWORK);
+ String providerNetwork =
+ getLeafPropertyValue(vlEntity, SdcPropertyNames.PROPERTY_NAME_PROVIDERNETWORK_ISPROVIDERNETWORK);
if ("true".equalsIgnoreCase(providerNetwork)) {
networkResource.setNeutronNetworkType(PROVIDER);
@@ -1589,21 +1591,19 @@ public class ToscaResourceInstaller {
networkResource.setNeutronNetworkType(BASIC);
}
- networkResource.setModelName(
- testNull(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME)));
+ networkResource.setModelName(testNull(vlEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_NAME)));
networkResource.setModelInvariantUUID(
- testNull(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID)));
- networkResource.setModelUUID(
- testNull(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID)));
- networkResource.setModelVersion(
- testNull(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)));
+ testNull(vlEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID)));
+ networkResource.setModelUUID(testNull(vlEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_UUID)));
+ networkResource
+ .setModelVersion(testNull(vlEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)));
networkResource.setAicVersionMax(aicMax);
networkResource.setAicVersionMin(aicMin);
- networkResource.setToscaNodeType(networkNodeTemplate.getType());
- networkResource.setDescription(
- testNull(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)));
+ networkResource.setToscaNodeType(vlEntity.getToscaType());
+ networkResource
+ .setDescription(testNull(vlEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)));
networkResource.setOrchestrationMode(HEAT);
networkResource.setHeatTemplate(heatTemplate);
return networkResource;
@@ -2672,6 +2672,41 @@ public class ToscaResourceInstaller {
+ vfModuleStructure.getVfModuleMetadata().getVfModuleModelName();
}
+ protected List<IEntityDetails> getEntityDetails(ToscaResourceStructure toscaResourceStruct, SdcTypes entityType,
+ SdcTypes topologyTemplate) {
+
+ EntityQuery entityQuery = EntityQuery.newBuilder(entityType).build();
+ TopologyTemplateQuery topologyTemplateQuery = TopologyTemplateQuery.newBuilder(topologyTemplate).build();
+ List<IEntityDetails> entityDetails =
+ toscaResourceStruct.getSdcCsarHelper().getEntity(entityQuery, topologyTemplateQuery, false);
+
+ return entityDetails;
+
+ }
+
+ protected List<IEntityDetails> getEntityDetails(ToscaResourceStructure toscaResourceStruct, String entityType,
+ SdcTypes topologyTemplate) {
+
+ EntityQuery entityQuery = EntityQuery.newBuilder(entityType).build();
+ TopologyTemplateQuery topologyTemplateQuery = TopologyTemplateQuery.newBuilder(topologyTemplate).build();
+ List<IEntityDetails> entityDetails =
+ toscaResourceStruct.getSdcCsarHelper().getEntity(entityQuery, topologyTemplateQuery, true);
+
+ return entityDetails;
+
+ }
+
+ protected String getLeafPropertyValue(IEntityDetails entityDetails, String propName) {
+
+ Property leafProperty = entityDetails.getProperties().get(propName);
+
+ if (leafProperty != null && leafProperty.getValue() != null) {
+ return leafProperty.getValue().toString();
+ }
+
+ return null;
+ }
+
protected String getPropertyInput(String propertyName) {
String inputName = new String();
diff --git a/asdc-controller/src/test/java/org/onap/so/asdc/installer/heat/ToscaResourceInstallerTest.java b/asdc-controller/src/test/java/org/onap/so/asdc/installer/heat/ToscaResourceInstallerTest.java
index bd8e877369..115af3adaf 100644
--- a/asdc-controller/src/test/java/org/onap/so/asdc/installer/heat/ToscaResourceInstallerTest.java
+++ b/asdc-controller/src/test/java/org/onap/so/asdc/installer/heat/ToscaResourceInstallerTest.java
@@ -45,6 +45,7 @@ import org.mockito.MockitoAnnotations;
import org.onap.sdc.api.notification.IArtifactInfo;
import org.onap.sdc.api.notification.INotificationData;
import org.onap.sdc.api.notification.IResourceInstance;
+import org.onap.sdc.tosca.parser.api.IEntityDetails;
import org.onap.sdc.tosca.parser.api.ISdcCsarHelper;
import org.onap.sdc.tosca.parser.impl.SdcCsarHelperImpl;
import org.onap.sdc.tosca.parser.impl.SdcPropertyNames;
@@ -102,6 +103,8 @@ public class ToscaResourceInstallerTest extends BaseTest {
@Mock
private NodeTemplate nodeTemplate;
@Mock
+ private IEntityDetails entityDetails;
+ @Mock
private ToscaResourceStructure toscaResourceStructure;
@Mock
private ServiceProxyResourceCustomization spResourceCustomization;
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/AbstractSDNCTask.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/AbstractSDNCTask.java
new file mode 100644
index 0000000000..c134f31b42
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/AbstractSDNCTask.java
@@ -0,0 +1,22 @@
+package org.onap.so.bpmn.infrastructure.sdnc.tasks;
+
+import java.net.URI;
+import javax.ws.rs.core.UriBuilder;
+import org.onap.so.client.sdnc.beans.SDNCRequest;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.core.env.Environment;
+import org.springframework.stereotype.Component;
+
+@Component
+public class AbstractSDNCTask {
+
+ @Autowired
+ Environment env;
+
+
+ public URI buildCallbackURI(SDNCRequest sdncRequest) {
+ UriBuilder builder = UriBuilder.fromPath(env.getRequiredProperty("mso.workflow.message.endpoint"))
+ .path(sdncRequest.getCorrelationName()).path(sdncRequest.getCorrelationValue());
+ return builder.build();
+ }
+}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCActivateTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCActivateTasks.java
index e4dd35503e..b85e33144f 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCActivateTasks.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCActivateTasks.java
@@ -22,8 +22,6 @@
package org.onap.so.bpmn.infrastructure.sdnc.tasks;
-import java.net.URI;
-import javax.ws.rs.core.UriBuilder;
import org.onap.sdnc.northbound.client.model.GenericResourceApiNetworkOperationInformation;
import org.onap.sdnc.northbound.client.model.GenericResourceApiVfModuleOperationInformation;
import org.onap.sdnc.northbound.client.model.GenericResourceApiVnfOperationInformation;
@@ -52,7 +50,7 @@ import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;
@Component
-public class SDNCActivateTasks {
+public class SDNCActivateTasks extends AbstractSDNCTask {
public static final String SDNC_REQUEST = "SDNCRequest";
@Autowired
@@ -77,9 +75,9 @@ public class SDNCActivateTasks {
GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
CloudRegion cloudRegion = gBBInput.getCloudRegion();
Customer customer = gBBInput.getCustomer();
- GenericResourceApiVnfOperationInformation req =
- sdncVnfResources.activateVnf(vnf, serviceInstance, customer, cloudRegion, requestContext);
SDNCRequest sdncRequest = new SDNCRequest();
+ GenericResourceApiVnfOperationInformation req = sdncVnfResources.activateVnf(vnf, serviceInstance, customer,
+ cloudRegion, requestContext, buildCallbackURI(sdncRequest));
sdncRequest.setSDNCPayload(req);
sdncRequest.setTopology(SDNCTopology.VNF);
execution.setVariable(SDNC_REQUEST, sdncRequest);
@@ -127,11 +125,8 @@ public class SDNCActivateTasks {
Customer customer = gBBInput.getCustomer();
CloudRegion cloudRegion = gBBInput.getCloudRegion();
SDNCRequest sdncRequest = new SDNCRequest();
- UriBuilder builder = UriBuilder.fromPath(env.getRequiredProperty("mso.workflow.message.endpoint"))
- .path(sdncRequest.getCorrelationName()).path(sdncRequest.getCorrelationValue());
- URI uri = builder.build();
GenericResourceApiVfModuleOperationInformation req = sdncVfModuleResources.activateVfModule(vfModule, vnf,
- serviceInstance, customer, cloudRegion, requestContext, uri);
+ serviceInstance, customer, cloudRegion, requestContext, buildCallbackURI(sdncRequest));
sdncRequest.setSDNCPayload(req);
sdncRequest.setTopology(SDNCTopology.VFMODULE);
execution.setVariable(SDNC_REQUEST, sdncRequest);
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 c100cd6cee..ab2647a68d 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
@@ -22,8 +22,6 @@
package org.onap.so.bpmn.infrastructure.sdnc.tasks;
-import java.net.URI;
-import javax.ws.rs.core.UriBuilder;
import org.onap.sdnc.northbound.client.model.GenericResourceApiNetworkOperationInformation;
import org.onap.sdnc.northbound.client.model.GenericResourceApiServiceOperationInformation;
import org.onap.sdnc.northbound.client.model.GenericResourceApiVfModuleOperationInformation;
@@ -55,7 +53,7 @@ import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;
@Component
-public class SDNCAssignTasks {
+public class SDNCAssignTasks extends AbstractSDNCTask {
private static final Logger logger = LoggerFactory.getLogger(SDNCAssignTasks.class);
public static final String SDNC_REQUEST = "SDNCRequest";
@Autowired
@@ -100,9 +98,11 @@ public class SDNCAssignTasks {
GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
Customer customer = gBBInput.getCustomer();
CloudRegion cloudRegion = gBBInput.getCloudRegion();
- GenericResourceApiVnfOperationInformation req = sdncVnfResources.assignVnf(vnf, serviceInstance, customer,
- cloudRegion, requestContext, Boolean.TRUE.equals(vnf.isCallHoming()));
SDNCRequest sdncRequest = new SDNCRequest();
+
+ GenericResourceApiVnfOperationInformation req =
+ sdncVnfResources.assignVnf(vnf, serviceInstance, customer, cloudRegion, requestContext,
+ Boolean.TRUE.equals(vnf.isCallHoming()), buildCallbackURI(sdncRequest));
sdncRequest.setSDNCPayload(req);
sdncRequest.setTopology(SDNCTopology.VNF);
execution.setVariable(SDNC_REQUEST, sdncRequest);
@@ -128,11 +128,9 @@ public class SDNCAssignTasks {
Customer customer = gBBInput.getCustomer();
CloudRegion cloudRegion = gBBInput.getCloudRegion();
SDNCRequest sdncRequest = new SDNCRequest();
- UriBuilder builder = UriBuilder.fromPath(env.getRequiredProperty("mso.workflow.message.endpoint"))
- .path(sdncRequest.getCorrelationName()).path(sdncRequest.getCorrelationValue());
- URI uri = builder.build();
- GenericResourceApiVfModuleOperationInformation req = sdncVfModuleResources.assignVfModule(vfModule,
- volumeGroup, vnf, serviceInstance, customer, cloudRegion, requestContext, uri);
+ GenericResourceApiVfModuleOperationInformation req =
+ sdncVfModuleResources.assignVfModule(vfModule, volumeGroup, vnf, serviceInstance, customer,
+ cloudRegion, requestContext, buildCallbackURI(sdncRequest));
sdncRequest.setSDNCPayload(req);
sdncRequest.setTopology(SDNCTopology.VFMODULE);
execution.setVariable(SDNC_REQUEST, sdncRequest);
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCChangeAssignTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCChangeAssignTasks.java
index acf48acdda..c5ebc5e447 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCChangeAssignTasks.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCChangeAssignTasks.java
@@ -20,8 +20,6 @@
package org.onap.so.bpmn.infrastructure.sdnc.tasks;
-import java.net.URI;
-import javax.ws.rs.core.UriBuilder;
import org.onap.sdnc.northbound.client.model.GenericResourceApiNetworkOperationInformation;
import org.onap.sdnc.northbound.client.model.GenericResourceApiServiceOperationInformation;
import org.onap.sdnc.northbound.client.model.GenericResourceApiVfModuleOperationInformation;
@@ -49,7 +47,7 @@ import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;
@Component
-public class SDNCChangeAssignTasks {
+public class SDNCChangeAssignTasks extends AbstractSDNCTask {
public static final String SDNC_REQUEST = "SDNCRequest";
@Autowired
private SDNCNetworkResources sdncNetworkResources;
@@ -88,9 +86,10 @@ public class SDNCChangeAssignTasks {
GenericVnf genericVnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
ServiceInstance serviceInstance =
extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
- GenericResourceApiVnfOperationInformation req = sdncVnfResources.changeModelVnf(genericVnf, serviceInstance,
- gBBInput.getCustomer(), gBBInput.getCloudRegion(), gBBInput.getRequestContext());
SDNCRequest sdncRequest = new SDNCRequest();
+ GenericResourceApiVnfOperationInformation req =
+ sdncVnfResources.changeModelVnf(genericVnf, serviceInstance, gBBInput.getCustomer(),
+ gBBInput.getCloudRegion(), gBBInput.getRequestContext(), buildCallbackURI(sdncRequest));
sdncRequest.setSDNCPayload(req);
sdncRequest.setTopology(SDNCTopology.VNF);
execution.setVariable(SDNC_REQUEST, sdncRequest);
@@ -127,11 +126,8 @@ public class SDNCChangeAssignTasks {
VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID);
Customer customer = gBBInput.getCustomer();
SDNCRequest sdncRequest = new SDNCRequest();
- UriBuilder builder = UriBuilder.fromPath(env.getRequiredProperty("mso.workflow.message.endpoint"))
- .path(sdncRequest.getCorrelationName()).path(sdncRequest.getCorrelationValue());
- URI uri = builder.build();
GenericResourceApiVfModuleOperationInformation req = sdncVfModuleResources.changeAssignVfModule(vfModule,
- vnf, serviceInstance, customer, cloudRegion, requestContext, uri);
+ vnf, serviceInstance, customer, cloudRegion, requestContext, buildCallbackURI(sdncRequest));
sdncRequest.setSDNCPayload(req);
sdncRequest.setTopology(SDNCTopology.VFMODULE);
execution.setVariable(SDNC_REQUEST, sdncRequest);
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCDeactivateTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCDeactivateTasks.java
index 3fc25196e1..3c42f76d73 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCDeactivateTasks.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCDeactivateTasks.java
@@ -22,8 +22,6 @@
package org.onap.so.bpmn.infrastructure.sdnc.tasks;
-import java.net.URI;
-import javax.ws.rs.core.UriBuilder;
import org.onap.sdnc.northbound.client.model.GenericResourceApiNetworkOperationInformation;
import org.onap.sdnc.northbound.client.model.GenericResourceApiServiceOperationInformation;
import org.onap.sdnc.northbound.client.model.GenericResourceApiVfModuleOperationInformation;
@@ -53,7 +51,7 @@ import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;
@Component
-public class SDNCDeactivateTasks {
+public class SDNCDeactivateTasks extends AbstractSDNCTask {
public static final String SDNC_REQUEST = "SDNCRequest";
@Autowired
@@ -82,11 +80,8 @@ public class SDNCDeactivateTasks {
Customer customer = gBBInput.getCustomer();
CloudRegion cloudRegion = gBBInput.getCloudRegion();
SDNCRequest sdncRequest = new SDNCRequest();
- UriBuilder builder = UriBuilder.fromPath(env.getRequiredProperty("mso.workflow.message.endpoint"))
- .path(sdncRequest.getCorrelationName()).path(sdncRequest.getCorrelationValue());
- URI uri = builder.build();
GenericResourceApiVfModuleOperationInformation req = sdncVfModuleResources.deactivateVfModule(vfModule, vnf,
- serviceInstance, customer, cloudRegion, requestContext, uri);
+ serviceInstance, customer, cloudRegion, requestContext, buildCallbackURI(sdncRequest));
sdncRequest.setSDNCPayload(req);
sdncRequest.setTopology(SDNCTopology.VFMODULE);
execution.setVariable(SDNC_REQUEST, sdncRequest);
@@ -111,9 +106,9 @@ public class SDNCDeactivateTasks {
vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
CloudRegion cloudRegion = gBBInput.getCloudRegion();
Customer customer = gBBInput.getCustomer();
- GenericResourceApiVnfOperationInformation req =
- sdncVnfResources.deactivateVnf(vnf, serviceInstance, customer, cloudRegion, requestContext);
SDNCRequest sdncRequest = new SDNCRequest();
+ GenericResourceApiVnfOperationInformation req = sdncVnfResources.deactivateVnf(vnf, serviceInstance,
+ customer, cloudRegion, requestContext, buildCallbackURI(sdncRequest));
sdncRequest.setSDNCPayload(req);
sdncRequest.setTopology(SDNCTopology.VNF);
execution.setVariable(SDNC_REQUEST, sdncRequest);
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCUnassignTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCUnassignTasks.java
index 4721bf56f1..e3c9785ab2 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCUnassignTasks.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCUnassignTasks.java
@@ -22,8 +22,6 @@
package org.onap.so.bpmn.infrastructure.sdnc.tasks;
-import java.net.URI;
-import javax.ws.rs.core.UriBuilder;
import org.onap.sdnc.northbound.client.model.GenericResourceApiNetworkOperationInformation;
import org.onap.sdnc.northbound.client.model.GenericResourceApiServiceOperationInformation;
import org.onap.sdnc.northbound.client.model.GenericResourceApiVfModuleOperationInformation;
@@ -53,7 +51,7 @@ import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;
@Component
-public class SDNCUnassignTasks {
+public class SDNCUnassignTasks extends AbstractSDNCTask {
public static final String SDNC_REQUEST = "SDNCRequest";
@Autowired
@@ -98,11 +96,8 @@ public class SDNCUnassignTasks {
RequestContext requestContext = gBBInput.getRequestContext();
VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID);
SDNCRequest sdncRequest = new SDNCRequest();
- UriBuilder builder = UriBuilder.fromPath(env.getRequiredProperty("mso.workflow.message.endpoint"))
- .path(sdncRequest.getCorrelationName()).path(sdncRequest.getCorrelationValue());
- URI uri = builder.build();
- GenericResourceApiVfModuleOperationInformation req =
- sdncVfModuleResources.unassignVfModule(vfModule, vnf, serviceInstance, requestContext, uri);
+ GenericResourceApiVfModuleOperationInformation req = sdncVfModuleResources.unassignVfModule(vfModule, vnf,
+ serviceInstance, requestContext, buildCallbackURI(sdncRequest));
sdncRequest.setSDNCPayload(req);
sdncRequest.setTopology(SDNCTopology.VFMODULE);
execution.setVariable(SDNC_REQUEST, sdncRequest);
@@ -120,9 +115,9 @@ public class SDNCUnassignTasks {
RequestContext requestContext = gBBInput.getRequestContext();
Customer customer = gBBInput.getCustomer();
CloudRegion cloudRegion = gBBInput.getCloudRegion();
- GenericResourceApiVnfOperationInformation req =
- sdncVnfResources.unassignVnf(vnf, serviceInstance, customer, cloudRegion, requestContext);
SDNCRequest sdncRequest = new SDNCRequest();
+ GenericResourceApiVnfOperationInformation req = sdncVnfResources.unassignVnf(vnf, serviceInstance, customer,
+ cloudRegion, requestContext, buildCallbackURI(sdncRequest));
sdncRequest.setSDNCPayload(req);
sdncRequest.setTopology(SDNCTopology.VNF);
execution.setVariable(SDNC_REQUEST, sdncRequest);
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCVnfResources.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCVnfResources.java
index 0e32955eed..12aae1e6a6 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCVnfResources.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCVnfResources.java
@@ -22,6 +22,7 @@
package org.onap.so.client.orchestration;
+import java.net.URI;
import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestActionEnumeration;
import org.onap.sdnc.northbound.client.model.GenericResourceApiVnfOperationInformation;
import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion;
@@ -50,47 +51,48 @@ public class SDNCVnfResources {
private SDNCClient sdncClient;
public GenericResourceApiVnfOperationInformation assignVnf(GenericVnf vnf, ServiceInstance serviceInstance,
- Customer customer, CloudRegion cloudRegion, RequestContext requestContext, boolean homing) {
+ Customer customer, CloudRegion cloudRegion, RequestContext requestContext, boolean homing,
+ URI callbackURI) {
return sdncRM.reqMapper(SDNCSvcOperation.VNF_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN,
GenericResourceApiRequestActionEnumeration.CREATEVNFINSTANCE, vnf, serviceInstance, customer,
- cloudRegion, requestContext, homing);
+ cloudRegion, requestContext, homing, callbackURI);
}
public GenericResourceApiVnfOperationInformation activateVnf(GenericVnf vnf, ServiceInstance serviceInstance,
- Customer customer, CloudRegion cloudRegion, RequestContext requestContext) {
+ Customer customer, CloudRegion cloudRegion, RequestContext requestContext, URI callbackURI) {
return sdncRM.reqMapper(SDNCSvcOperation.VNF_TOPOLOGY_OPERATION, SDNCSvcAction.ACTIVATE,
GenericResourceApiRequestActionEnumeration.CREATEVNFINSTANCE, vnf, serviceInstance, customer,
- cloudRegion, requestContext, false);
+ cloudRegion, requestContext, false, callbackURI);
}
public GenericResourceApiVnfOperationInformation deactivateVnf(GenericVnf vnf, ServiceInstance serviceInstance,
- Customer customer, CloudRegion cloudRegion, RequestContext requestContext) {
+ Customer customer, CloudRegion cloudRegion, RequestContext requestContext, URI callbackURI) {
return sdncRM.reqMapper(SDNCSvcOperation.VNF_TOPOLOGY_OPERATION, SDNCSvcAction.DEACTIVATE,
GenericResourceApiRequestActionEnumeration.DELETEVNFINSTANCE, vnf, serviceInstance, customer,
- cloudRegion, requestContext, false);
+ cloudRegion, requestContext, false, callbackURI);
}
public GenericResourceApiVnfOperationInformation unassignVnf(GenericVnf vnf, ServiceInstance serviceInstance,
- Customer customer, CloudRegion cloudRegion, RequestContext requestContext) {
+ Customer customer, CloudRegion cloudRegion, RequestContext requestContext, URI callbackURI) {
return sdncRM.reqMapper(SDNCSvcOperation.VNF_TOPOLOGY_OPERATION, SDNCSvcAction.UNASSIGN,
GenericResourceApiRequestActionEnumeration.DELETEVNFINSTANCE, vnf, serviceInstance, customer,
- cloudRegion, requestContext, false);
+ cloudRegion, requestContext, false, callbackURI);
}
public GenericResourceApiVnfOperationInformation deleteVnf(GenericVnf vnf, ServiceInstance serviceInstance,
- Customer customer, CloudRegion cloudRegion, RequestContext requestContext) {
+ Customer customer, CloudRegion cloudRegion, RequestContext requestContext, URI callbackURI) {
return sdncRM.reqMapper(SDNCSvcOperation.VNF_TOPOLOGY_OPERATION, SDNCSvcAction.DEACTIVATE,
GenericResourceApiRequestActionEnumeration.DELETEVNFINSTANCE, vnf, serviceInstance, customer,
- cloudRegion, requestContext, false);
+ cloudRegion, requestContext, false, callbackURI);
}
public GenericResourceApiVnfOperationInformation changeModelVnf(GenericVnf vnf, ServiceInstance serviceInstance,
- Customer customer, CloudRegion cloudRegion, RequestContext requestContext) {
+ Customer customer, CloudRegion cloudRegion, RequestContext requestContext, URI callbackURI) {
return sdncRM.reqMapper(SDNCSvcOperation.VNF_TOPOLOGY_OPERATION, SDNCSvcAction.CHANGE_ASSIGN,
GenericResourceApiRequestActionEnumeration.CREATEVNFINSTANCE, vnf, serviceInstance, customer,
- cloudRegion, requestContext, false);
+ cloudRegion, requestContext, false, callbackURI);
}
public String queryVnf(GenericVnf vnf) throws MapperException, BadResponseException {
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/VnfTopologyOperationRequestMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/VnfTopologyOperationRequestMapper.java
index e39e202aa3..bef4ec3465 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/VnfTopologyOperationRequestMapper.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/VnfTopologyOperationRequestMapper.java
@@ -20,6 +20,7 @@
package org.onap.so.client.sdnc.mapper;
+import java.net.URI;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@@ -56,7 +57,8 @@ public class VnfTopologyOperationRequestMapper {
public GenericResourceApiVnfOperationInformation reqMapper(SDNCSvcOperation svcOperation, SDNCSvcAction svcAction,
GenericResourceApiRequestActionEnumeration requestAction, GenericVnf vnf, ServiceInstance serviceInstance,
- Customer customer, CloudRegion cloudRegion, RequestContext requestContext, boolean homing) {
+ Customer customer, CloudRegion cloudRegion, RequestContext requestContext, boolean homing,
+ URI callbackUrl) {
String sdncReqId = UUID.randomUUID().toString();
String msoRequestId = UUID.randomUUID().toString();
if (requestContext != null && requestContext.getMsoRequestId() != null) {
@@ -64,7 +66,7 @@ public class VnfTopologyOperationRequestMapper {
}
GenericResourceApiVnfOperationInformation req = new GenericResourceApiVnfOperationInformation();
GenericResourceApiSdncrequestheaderSdncRequestHeader sdncRequestHeader =
- generalTopologyObjectMapper.buildSdncRequestHeader(svcAction, sdncReqId);
+ generalTopologyObjectMapper.buildSdncRequestHeader(svcAction, sdncReqId, callbackUrl.toString());
GenericResourceApiRequestinformationRequestInformation requestInformation = generalTopologyObjectMapper
.buildGenericResourceApiRequestinformationRequestInformation(msoRequestId, requestAction);
GenericResourceApiServiceinformationServiceInformation serviceInformation =
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCActivateTaskTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCActivateTaskTest.java
index ffd4f74b63..510dc47649 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCActivateTaskTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCActivateTaskTest.java
@@ -94,11 +94,11 @@ public class SDNCActivateTaskTest extends BaseTaskTest {
@Test
public void activateVnfTest() throws Exception {
- doReturn(new GenericResourceApiVnfOperationInformation()).when(sdncVnfResources).activateVnf(genericVnf,
- serviceInstance, customer, cloudRegion, requestContext);
+ doReturn(new GenericResourceApiVnfOperationInformation()).when(sdncVnfResources).activateVnf(eq(genericVnf),
+ eq(serviceInstance), eq(customer), eq(cloudRegion), eq(requestContext), any(URI.class));
sdncActivateTasks.activateVnf(execution);
- verify(sdncVnfResources, times(1)).activateVnf(genericVnf, serviceInstance, customer, cloudRegion,
- requestContext);
+ verify(sdncVnfResources, times(1)).activateVnf(eq(genericVnf), eq(serviceInstance), eq(customer),
+ eq(cloudRegion), eq(requestContext), any(URI.class));
SDNCRequest sdncRequest = execution.getVariable("SDNCRequest");
assertEquals(SDNCTopology.VNF, sdncRequest.getTopology());
}
@@ -106,8 +106,8 @@ public class SDNCActivateTaskTest extends BaseTaskTest {
@Test
public void activateVnfTestException() throws Exception {
expectedException.expect(BpmnError.class);
- doThrow(RuntimeException.class).when(sdncVnfResources).activateVnf(genericVnf, serviceInstance, customer,
- cloudRegion, requestContext);
+ doThrow(RuntimeException.class).when(sdncVnfResources).activateVnf(eq(genericVnf), eq(serviceInstance),
+ eq(customer), eq(cloudRegion), eq(requestContext), any(URI.class));
sdncActivateTasks.activateVnf(execution);
}
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 982868dcbc..b72766c386 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
@@ -113,12 +113,12 @@ public class SDNCAssignTasksTest extends BaseTaskTest {
@Test
public void assignVnfTest() throws Exception {
- doReturn(new GenericResourceApiVnfOperationInformation()).when(sdncVnfResources).assignVnf(genericVnf,
- serviceInstance, customer, cloudRegion, requestContext, false);
+ doReturn(new GenericResourceApiVnfOperationInformation()).when(sdncVnfResources).assignVnf(eq(genericVnf),
+ eq(serviceInstance), eq(customer), eq(cloudRegion), eq(requestContext), eq(false), any(URI.class));
execution.setVariable("generalBuildingBlock", gBBInput);
sdncAssignTasks.assignVnf(execution);
- verify(sdncVnfResources, times(1)).assignVnf(genericVnf, serviceInstance, customer, cloudRegion, requestContext,
- false);
+ verify(sdncVnfResources, times(1)).assignVnf(eq(genericVnf), eq(serviceInstance), eq(customer), eq(cloudRegion),
+ eq(requestContext), eq(false), any(URI.class));
SDNCRequest sdncRequest = execution.getVariable("SDNCRequest");
assertEquals(SDNCTopology.VNF, sdncRequest.getTopology());
}
@@ -126,8 +126,8 @@ public class SDNCAssignTasksTest extends BaseTaskTest {
@Test
public void assignVnfExceptionTest() throws Exception {
expectedException.expect(BpmnError.class);
- doThrow(RuntimeException.class).when(sdncVnfResources).assignVnf(genericVnf, serviceInstance, customer,
- cloudRegion, requestContext, false);
+ doThrow(RuntimeException.class).when(sdncVnfResources).assignVnf(eq(genericVnf), eq(serviceInstance),
+ eq(customer), eq(cloudRegion), eq(requestContext), eq(false), any(URI.class));
sdncAssignTasks.assignVnf(execution);
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCChangeAssignTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCChangeAssignTasksTest.java
index 8c25bea801..96ff01f78b 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCChangeAssignTasksTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCChangeAssignTasksTest.java
@@ -80,11 +80,11 @@ public class SDNCChangeAssignTasksTest extends BaseTaskTest {
@Test
public void changeModelVnfTest() throws Exception {
- doReturn(new GenericResourceApiVnfOperationInformation()).when(sdncVnfResources).changeModelVnf(genericVnf,
- serviceInstance, customer, cloudRegion, requestContext);
+ doReturn(new GenericResourceApiVnfOperationInformation()).when(sdncVnfResources).changeModelVnf(eq(genericVnf),
+ eq(serviceInstance), eq(customer), eq(cloudRegion), eq(requestContext), any(URI.class));
sdncChangeAssignTasks.changeModelVnf(execution);
- verify(sdncVnfResources, times(1)).changeModelVnf(genericVnf, serviceInstance, customer, cloudRegion,
- requestContext);
+ verify(sdncVnfResources, times(1)).changeModelVnf(eq(genericVnf), eq(serviceInstance), eq(customer),
+ eq(cloudRegion), eq(requestContext), any(URI.class));
SDNCRequest sdncRequest = execution.getVariable("SDNCRequest");
assertEquals(SDNCTopology.VNF, sdncRequest.getTopology());
}
@@ -92,8 +92,8 @@ public class SDNCChangeAssignTasksTest extends BaseTaskTest {
@Test
public void changeModelVnfExceptionTest() throws Exception {
expectedException.expect(BpmnError.class);
- doThrow(RuntimeException.class).when(sdncVnfResources).changeModelVnf(genericVnf, serviceInstance, customer,
- cloudRegion, requestContext);
+ doThrow(RuntimeException.class).when(sdncVnfResources).changeModelVnf(eq(genericVnf), eq(serviceInstance),
+ eq(customer), eq(cloudRegion), eq(requestContext), any(URI.class));
sdncChangeAssignTasks.changeModelVnf(execution);
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCDeactivateTaskTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCDeactivateTaskTest.java
index d8a1b0182e..3714f9d9a9 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCDeactivateTaskTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCDeactivateTaskTest.java
@@ -107,19 +107,19 @@ public class SDNCDeactivateTaskTest extends BaseTaskTest {
@Test
public void deactivateVnfTest() throws Exception {
- doReturn(new GenericResourceApiVnfOperationInformation()).when(sdncVnfResources).deactivateVnf(genericVnf,
- serviceInstance, customer, cloudRegion, requestContext);
+ doReturn(new GenericResourceApiVnfOperationInformation()).when(sdncVnfResources).deactivateVnf(eq(genericVnf),
+ eq(serviceInstance), eq(customer), eq(cloudRegion), eq(requestContext), any(URI.class));
sdncDeactivateTasks.deactivateVnf(execution);
- verify(sdncVnfResources, times(1)).deactivateVnf(genericVnf, serviceInstance, customer, cloudRegion,
- requestContext);
+ verify(sdncVnfResources, times(1)).deactivateVnf(eq(genericVnf), eq(serviceInstance), eq(customer),
+ eq(cloudRegion), eq(requestContext), any(URI.class));
SDNCRequest sdncRequest = execution.getVariable("SDNCRequest");
assertEquals(SDNCTopology.VNF, sdncRequest.getTopology());
}
@Test
public void deactivateVnfExceptionTest() throws Exception {
- doThrow(RuntimeException.class).when(sdncVnfResources).deactivateVnf(genericVnf, serviceInstance, customer,
- cloudRegion, requestContext);
+ doThrow(RuntimeException.class).when(sdncVnfResources).deactivateVnf(eq(genericVnf), eq(serviceInstance),
+ eq(customer), eq(cloudRegion), eq(requestContext), any(URI.class));
expectedException.expect(BpmnError.class);
sdncDeactivateTasks.deactivateVnf(execution);
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCUnassignTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCUnassignTasksTest.java
index b29d15c830..98f6bfab9c 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCUnassignTasksTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCUnassignTasksTest.java
@@ -125,11 +125,11 @@ public class SDNCUnassignTasksTest extends BaseTaskTest {
@Test
public void unassignVnfTest() throws Exception {
- doReturn(new GenericResourceApiVnfOperationInformation()).when(sdncVnfResources).unassignVnf(genericVnf,
- serviceInstance, customer, cloudRegion, requestContext);
+ doReturn(new GenericResourceApiVnfOperationInformation()).when(sdncVnfResources).unassignVnf(eq(genericVnf),
+ eq(serviceInstance), eq(customer), eq(cloudRegion), eq(requestContext), any(URI.class));
sdncUnassignTasks.unassignVnf(execution);
- verify(sdncVnfResources, times(1)).unassignVnf(genericVnf, serviceInstance, customer, cloudRegion,
- requestContext);
+ verify(sdncVnfResources, times(1)).unassignVnf(eq(genericVnf), eq(serviceInstance), eq(customer),
+ eq(cloudRegion), eq(requestContext), any(URI.class));
SDNCRequest sdncRequest = execution.getVariable("SDNCRequest");
assertEquals(SDNCTopology.VNF, sdncRequest.getTopology());
}
@@ -137,8 +137,8 @@ public class SDNCUnassignTasksTest extends BaseTaskTest {
@Test
public void unassignVnfExceptionTest() throws Exception {
expectedException.expect(BpmnError.class);
- doThrow(RuntimeException.class).when(sdncVnfResources).unassignVnf(genericVnf, serviceInstance, customer,
- cloudRegion, requestContext);
+ doThrow(RuntimeException.class).when(sdncVnfResources).unassignVnf(eq(genericVnf), eq(serviceInstance),
+ eq(customer), eq(cloudRegion), eq(requestContext), any(URI.class));
sdncUnassignTasks.unassignVnf(execution);
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCVnfResourcesTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCVnfResourcesTest.java
index 4c0e2b873f..0ccf056ddc 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCVnfResourcesTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCVnfResourcesTest.java
@@ -28,6 +28,8 @@ import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
+import java.net.URI;
+import java.net.URISyntaxException;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -66,6 +68,7 @@ public class SDNCVnfResourcesTest extends TestDataSetup {
private CloudRegion cloudRegion;
private RequestContext requestContext;
private GenericResourceApiVnfOperationInformation sdncReq;
+ private URI testURI;
@Before
public void before() {
@@ -75,6 +78,11 @@ public class SDNCVnfResourcesTest extends TestDataSetup {
cloudRegion = buildCloudRegion();
requestContext = buildRequestContext();
sdncReq = new GenericResourceApiVnfOperationInformation();
+ try {
+ testURI = new URI("http://localhost:9800");
+ } catch (URISyntaxException e) {
+
+ }
}
@Test
@@ -82,12 +90,12 @@ public class SDNCVnfResourcesTest extends TestDataSetup {
doReturn(sdncReq).when(MOCK_vnfTopologyOperationRequestMapper).reqMapper(isA(SDNCSvcOperation.class),
isA(SDNCSvcAction.class), isA(GenericResourceApiRequestActionEnumeration.class), isA(GenericVnf.class),
isA(ServiceInstance.class), isA(Customer.class), isA(CloudRegion.class), isA(RequestContext.class),
- anyBoolean());
- sdncVnfResources.assignVnf(genericVnf, serviceInstance, customer, cloudRegion, requestContext, false);
+ anyBoolean(), any(URI.class));
+ sdncVnfResources.assignVnf(genericVnf, serviceInstance, customer, cloudRegion, requestContext, false, testURI);
verify(MOCK_vnfTopologyOperationRequestMapper, times(1)).reqMapper(isA(SDNCSvcOperation.class),
isA(SDNCSvcAction.class), isA(GenericResourceApiRequestActionEnumeration.class), isA(GenericVnf.class),
isA(ServiceInstance.class), isA(Customer.class), isA(CloudRegion.class), isA(RequestContext.class),
- anyBoolean());
+ anyBoolean(), any(URI.class));
}
@Test
@@ -95,12 +103,12 @@ public class SDNCVnfResourcesTest extends TestDataSetup {
doReturn(sdncReq).when(MOCK_vnfTopologyOperationRequestMapper).reqMapper(isA(SDNCSvcOperation.class),
isA(SDNCSvcAction.class), isA(GenericResourceApiRequestActionEnumeration.class), isA(GenericVnf.class),
isA(ServiceInstance.class), isA(Customer.class), isA(CloudRegion.class), isA(RequestContext.class),
- anyBoolean());
- sdncVnfResources.activateVnf(genericVnf, serviceInstance, customer, cloudRegion, requestContext);
+ anyBoolean(), any(URI.class));
+ sdncVnfResources.activateVnf(genericVnf, serviceInstance, customer, cloudRegion, requestContext, testURI);
verify(MOCK_vnfTopologyOperationRequestMapper, times(1)).reqMapper(isA(SDNCSvcOperation.class),
isA(SDNCSvcAction.class), isA(GenericResourceApiRequestActionEnumeration.class), isA(GenericVnf.class),
isA(ServiceInstance.class), isA(Customer.class), isA(CloudRegion.class), isA(RequestContext.class),
- anyBoolean());
+ anyBoolean(), any(URI.class));
}
@Test
@@ -108,12 +116,12 @@ public class SDNCVnfResourcesTest extends TestDataSetup {
doReturn(sdncReq).when(MOCK_vnfTopologyOperationRequestMapper).reqMapper(isA(SDNCSvcOperation.class),
isA(SDNCSvcAction.class), isA(GenericResourceApiRequestActionEnumeration.class), isA(GenericVnf.class),
isA(ServiceInstance.class), isA(Customer.class), isA(CloudRegion.class), isA(RequestContext.class),
- anyBoolean());
- sdncVnfResources.deleteVnf(genericVnf, serviceInstance, customer, cloudRegion, requestContext);
+ anyBoolean(), any(URI.class));
+ sdncVnfResources.deleteVnf(genericVnf, serviceInstance, customer, cloudRegion, requestContext, testURI);
verify(MOCK_vnfTopologyOperationRequestMapper, times(1)).reqMapper(isA(SDNCSvcOperation.class),
isA(SDNCSvcAction.class), isA(GenericResourceApiRequestActionEnumeration.class), isA(GenericVnf.class),
isA(ServiceInstance.class), isA(Customer.class), isA(CloudRegion.class), isA(RequestContext.class),
- anyBoolean());
+ anyBoolean(), any(URI.class));
}
@Test
@@ -137,11 +145,12 @@ public class SDNCVnfResourcesTest extends TestDataSetup {
doReturn(sdncReq).when(MOCK_vnfTopologyOperationRequestMapper).reqMapper(isA(SDNCSvcOperation.class),
isA(SDNCSvcAction.class), isA(GenericResourceApiRequestActionEnumeration.class), isA(GenericVnf.class),
isA(ServiceInstance.class), isA(Customer.class), isA(CloudRegion.class), isA(RequestContext.class),
- anyBoolean());
- sdncVnfResources.changeModelVnf(genericVnf, serviceInstance, customer, cloudRegion, requestContext);
- verify(MOCK_vnfTopologyOperationRequestMapper, times(1)).reqMapper(SDNCSvcOperation.VNF_TOPOLOGY_OPERATION,
- SDNCSvcAction.CHANGE_ASSIGN, GenericResourceApiRequestActionEnumeration.CREATEVNFINSTANCE, genericVnf,
- serviceInstance, customer, cloudRegion, requestContext, false);
+ anyBoolean(), any(URI.class));
+ sdncVnfResources.changeModelVnf(genericVnf, serviceInstance, customer, cloudRegion, requestContext, testURI);
+ verify(MOCK_vnfTopologyOperationRequestMapper, times(1)).reqMapper(eq(SDNCSvcOperation.VNF_TOPOLOGY_OPERATION),
+ eq(SDNCSvcAction.CHANGE_ASSIGN), eq(GenericResourceApiRequestActionEnumeration.CREATEVNFINSTANCE),
+ eq(genericVnf), eq(serviceInstance), eq(customer), eq(cloudRegion), eq(requestContext), eq(false),
+ any(URI.class));
}
@Test
@@ -150,12 +159,12 @@ public class SDNCVnfResourcesTest extends TestDataSetup {
eq(SDNCSvcOperation.VNF_TOPOLOGY_OPERATION), eq(SDNCSvcAction.DEACTIVATE),
isA(GenericResourceApiRequestActionEnumeration.class), any(GenericVnf.class),
any(ServiceInstance.class), any(Customer.class), any(CloudRegion.class), any(RequestContext.class),
- anyBoolean());
- sdncVnfResources.deactivateVnf(genericVnf, serviceInstance, customer, cloudRegion, requestContext);
+ anyBoolean(), any(URI.class));
+ sdncVnfResources.deactivateVnf(genericVnf, serviceInstance, customer, cloudRegion, requestContext, testURI);
verify(MOCK_vnfTopologyOperationRequestMapper, times(1)).reqMapper(eq(SDNCSvcOperation.VNF_TOPOLOGY_OPERATION),
eq(SDNCSvcAction.DEACTIVATE), isA(GenericResourceApiRequestActionEnumeration.class),
any(GenericVnf.class), any(ServiceInstance.class), any(Customer.class), any(CloudRegion.class),
- any(RequestContext.class), anyBoolean());
+ any(RequestContext.class), anyBoolean(), any(URI.class));
}
@@ -166,8 +175,8 @@ public class SDNCVnfResourcesTest extends TestDataSetup {
eq(SDNCSvcOperation.VNF_TOPOLOGY_OPERATION), eq(SDNCSvcAction.DEACTIVATE),
isA(GenericResourceApiRequestActionEnumeration.class), any(GenericVnf.class),
any(ServiceInstance.class), any(Customer.class), any(CloudRegion.class), any(RequestContext.class),
- anyBoolean());
- sdncVnfResources.deactivateVnf(genericVnf, serviceInstance, customer, cloudRegion, requestContext);
+ anyBoolean(), any(URI.class));
+ sdncVnfResources.deactivateVnf(genericVnf, serviceInstance, customer, cloudRegion, requestContext, testURI);
}
@Test
@@ -176,12 +185,12 @@ public class SDNCVnfResourcesTest extends TestDataSetup {
eq(SDNCSvcOperation.VNF_TOPOLOGY_OPERATION), eq(SDNCSvcAction.UNASSIGN),
isA(GenericResourceApiRequestActionEnumeration.class), any(GenericVnf.class),
any(ServiceInstance.class), any(Customer.class), any(CloudRegion.class), any(RequestContext.class),
- anyBoolean());
- sdncVnfResources.unassignVnf(genericVnf, serviceInstance, customer, cloudRegion, requestContext);
+ anyBoolean(), any(URI.class));
+ sdncVnfResources.unassignVnf(genericVnf, serviceInstance, customer, cloudRegion, requestContext, testURI);
verify(MOCK_vnfTopologyOperationRequestMapper, times(1)).reqMapper(eq(SDNCSvcOperation.VNF_TOPOLOGY_OPERATION),
eq(SDNCSvcAction.UNASSIGN), isA(GenericResourceApiRequestActionEnumeration.class),
any(GenericVnf.class), any(ServiceInstance.class), any(Customer.class), any(CloudRegion.class),
- any(RequestContext.class), anyBoolean());
+ any(RequestContext.class), anyBoolean(), any(URI.class));
}
@Test
@@ -191,7 +200,7 @@ public class SDNCVnfResourcesTest extends TestDataSetup {
eq(SDNCSvcOperation.VNF_TOPOLOGY_OPERATION), eq(SDNCSvcAction.UNASSIGN),
isA(GenericResourceApiRequestActionEnumeration.class), any(GenericVnf.class),
any(ServiceInstance.class), any(Customer.class), any(CloudRegion.class), any(RequestContext.class),
- anyBoolean());
- sdncVnfResources.unassignVnf(genericVnf, serviceInstance, customer, cloudRegion, requestContext);
+ anyBoolean(), any(URI.class));
+ sdncVnfResources.unassignVnf(genericVnf, serviceInstance, customer, cloudRegion, requestContext, testURI);
}
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/VnfTopologyOperationRequestMapperTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/VnfTopologyOperationRequestMapperTest.java
index cecf34ea10..00836176f0 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/VnfTopologyOperationRequestMapperTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/VnfTopologyOperationRequestMapperTest.java
@@ -23,15 +23,18 @@ package org.onap.so.client.sdnc.mapper;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
+import java.net.URI;
import java.util.ArrayList;
import java.util.HashMap;
-import java.util.Map;
import java.util.List;
+import java.util.Map;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Spy;
import org.mockito.junit.MockitoJUnitRunner;
+import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestActionEnumeration;
+import org.onap.sdnc.northbound.client.model.GenericResourceApiVnfOperationInformation;
import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion;
import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer;
import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf;
@@ -45,8 +48,6 @@ import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoInstanceGroup;
import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance;
import org.onap.so.client.sdnc.beans.SDNCSvcAction;
import org.onap.so.client.sdnc.beans.SDNCSvcOperation;
-import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestActionEnumeration;
-import org.onap.sdnc.northbound.client.model.GenericResourceApiVnfOperationInformation;
@RunWith(MockitoJUnitRunner.class)
public class VnfTopologyOperationRequestMapperTest {
@@ -127,11 +128,11 @@ public class VnfTopologyOperationRequestMapperTest {
GenericResourceApiVnfOperationInformation vnfOpInformation =
mapper.reqMapper(SDNCSvcOperation.VNF_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN,
GenericResourceApiRequestActionEnumeration.CREATEVNFINSTANCE, vnf, serviceInstance, customer,
- cloudRegion, requestContext, true);
+ cloudRegion, requestContext, true, new URI("http://localhost:8080"));
GenericResourceApiVnfOperationInformation vnfOpInformationNullReqContext =
mapper.reqMapper(SDNCSvcOperation.VNF_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN,
GenericResourceApiRequestActionEnumeration.CREATEVNFINSTANCE, vnf, serviceInstance, customer,
- cloudRegion, null, true);
+ cloudRegion, null, true, new URI("http://localhost:8080"));
assertNull(vnfOpInformation.getServiceInformation().getOnapModelInformation().getModelCustomizationUuid());
assertEquals("vnfModelCustomizationUUID",
diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/exceptions/ContactCamundaException.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/exceptions/ContactCamundaException.java
index 6b38eec4ae..d5fc01781e 100644
--- a/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/exceptions/ContactCamundaException.java
+++ b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/exceptions/ContactCamundaException.java
@@ -23,7 +23,7 @@ package org.onap.so.apihandlerinfra.exceptions;
public class ContactCamundaException extends ApiException {
private static final String contactCamundaErrorMessage =
- "Unable to get process-instance history from Camunda for requestId: %s due to error: %s";
+ "Unable to get %s history from Camunda for requestId: %s due to error: %s";
private ContactCamundaException(Builder builder) {
super(builder);
@@ -32,9 +32,9 @@ public class ContactCamundaException extends ApiException {
public static class Builder extends ApiException.Builder<Builder> {
- public Builder(String requestId, String error, int httpResponseCode, String messageID) {
- super(contactCamundaErrorMessage.format(contactCamundaErrorMessage, requestId, error), httpResponseCode,
- messageID);
+ public Builder(String query, String requestId, String error, int httpResponseCode, String messageID) {
+ super(contactCamundaErrorMessage.format(contactCamundaErrorMessage, query, requestId, error),
+ httpResponseCode, messageID);
}
public ContactCamundaException build() {
diff --git a/mso-api-handlers/mso-api-handler-infra/pom.xml b/mso-api-handlers/mso-api-handler-infra/pom.xml
index dc665a9446..a3b9827d9f 100644
--- a/mso-api-handlers/mso-api-handler-infra/pom.xml
+++ b/mso-api-handlers/mso-api-handler-infra/pom.xml
@@ -88,6 +88,10 @@
</exclusions>
</dependency>
<dependency>
+ <groupId>org.springframework.retry</groupId>
+ <artifactId>spring-retry</artifactId>
+ </dependency>
+ <dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.6</version>
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/CamundaRequestHandler.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/CamundaRequestHandler.java
new file mode 100644
index 0000000000..451fa64585
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/CamundaRequestHandler.java
@@ -0,0 +1,180 @@
+package org.onap.so.apihandlerinfra;
+
+import java.security.GeneralSecurityException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import javax.xml.bind.DatatypeConverter;
+import org.apache.http.HttpStatus;
+import org.camunda.bpm.engine.impl.persistence.entity.HistoricActivityInstanceEntity;
+import org.camunda.bpm.engine.impl.persistence.entity.HistoricProcessInstanceEntity;
+import org.onap.so.apihandler.common.ErrorNumbers;
+import org.onap.so.apihandlerinfra.exceptions.ContactCamundaException;
+import org.onap.so.utils.CryptoUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.core.ParameterizedTypeReference;
+import org.springframework.core.env.Environment;
+import org.springframework.http.HttpEntity;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.HttpMethod;
+import org.springframework.http.ResponseEntity;
+import org.springframework.retry.policy.SimpleRetryPolicy;
+import org.springframework.retry.support.RetryTemplate;
+import org.springframework.stereotype.Component;
+import org.springframework.web.client.ResourceAccessException;
+import org.springframework.web.client.RestClientException;
+import org.springframework.web.client.RestTemplate;
+
+@Component
+public class CamundaRequestHandler {
+
+ private static Logger logger = LoggerFactory.getLogger(CamundaRequestHandler.class);
+
+ @Autowired
+ private RestTemplate restTemplate;
+
+ @Autowired
+ private Environment env;
+
+ public ResponseEntity<List<HistoricProcessInstanceEntity>> getCamundaProcessInstanceHistory(String requestId) {
+ RetryTemplate retryTemplate = setRetryTemplate();
+ String path = env.getProperty("mso.camunda.rest.history.uri") + requestId;
+ String targetUrl = env.getProperty("mso.camundaURL") + path;
+ HttpHeaders headers =
+ setCamundaHeaders(env.getRequiredProperty("mso.camundaAuth"), env.getRequiredProperty("mso.msoKey"));
+
+ HttpEntity<?> requestEntity = new HttpEntity<>(headers);
+
+ return retryTemplate.execute(context -> {
+ if (context.getLastThrowable() != null) {
+ logger.error("Retrying: Last call resulted in exception: ", context.getLastThrowable());
+ }
+ if (context.getRetryCount() == 0) {
+ logger.info("Querying Camunda for process-instance history for requestId: {}", requestId);
+ } else {
+ logger.info("Retry: {} of 3. Querying Camunda for process-instance history for requestId: {}",
+ context.getRetryCount(), requestId);
+ }
+ return restTemplate.exchange(targetUrl, HttpMethod.GET, requestEntity,
+ new ParameterizedTypeReference<List<HistoricProcessInstanceEntity>>() {});
+ });
+ }
+
+ protected ResponseEntity<List<HistoricActivityInstanceEntity>> getCamundaActivityHistory(String processInstanceId,
+ String requestId) throws ContactCamundaException {
+ RetryTemplate retryTemplate = setRetryTemplate();
+ String path = env.getProperty("mso.camunda.rest.activity.uri") + processInstanceId;
+ String targetUrl = env.getProperty("mso.camundaURL") + path;
+ HttpHeaders headers =
+ setCamundaHeaders(env.getRequiredProperty("mso.camundaAuth"), env.getRequiredProperty("mso.msoKey"));
+ HttpEntity<?> requestEntity = new HttpEntity<>(headers);
+ try {
+ return retryTemplate.execute(context -> {
+ if (context.getLastThrowable() != null) {
+ logger.error("Retrying: Last call resulted in exception: ", context.getLastThrowable());
+ }
+ if (context.getRetryCount() == 0) {
+ logger.info(
+ "Querying Camunda for activity-instance history for processInstanceId: {}, for requestId: {}",
+ processInstanceId, requestId);
+ } else {
+ logger.info(
+ "Retry: {} of 3. Querying Camunda for activity-instance history for processInstanceId: {}, for requestId: {}",
+ context.getRetryCount(), processInstanceId, requestId);
+ }
+
+ return restTemplate.exchange(targetUrl, HttpMethod.GET, requestEntity,
+ new ParameterizedTypeReference<List<HistoricActivityInstanceEntity>>() {});
+ });
+
+ } catch (RestClientException e) {
+ logger.error(
+ "Error querying Camunda for activity-instance history for processInstanceId: {}, for requestId: {}, exception: {}",
+ processInstanceId, requestId, e.getMessage());
+ throw new ContactCamundaException.Builder("activity-instance", requestId, e.toString(),
+ HttpStatus.SC_INTERNAL_SERVER_ERROR, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).cause(e).build();
+ }
+ }
+
+ protected String getTaskName(String requestId) throws ContactCamundaException {
+ ResponseEntity<List<HistoricProcessInstanceEntity>> response = null;
+ ResponseEntity<List<HistoricActivityInstanceEntity>> activityResponse = null;
+ String processInstanceId = null;
+ try {
+ response = getCamundaProcessInstanceHistory(requestId);
+ } catch (RestClientException e) {
+ logger.error("Error querying Camunda for process-instance history for requestId: {}, exception: {}",
+ requestId, e.getMessage());
+ throw new ContactCamundaException.Builder("process-instance", requestId, e.toString(),
+ HttpStatus.SC_INTERNAL_SERVER_ERROR, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).cause(e).build();
+ }
+
+ List<HistoricProcessInstanceEntity> historicProcessInstanceList = response.getBody();
+
+ if (historicProcessInstanceList != null) {
+ Collections.reverse(historicProcessInstanceList);
+ processInstanceId = historicProcessInstanceList.get(0).getId();
+ } else {
+ return "No processInstances returned for requestId: " + requestId;
+ }
+
+ if (processInstanceId != null) {
+ activityResponse = getCamundaActivityHistory(processInstanceId, requestId);
+ } else {
+ return "No processInstanceId returned for requestId: " + requestId;
+ }
+
+ return getActivityName(activityResponse.getBody());
+ }
+
+ protected String getActivityName(List<HistoricActivityInstanceEntity> activityInstanceList) {
+ String activityName = null;
+ HistoricActivityInstanceEntity activityInstance = null;
+ String result = null;
+
+ if (activityInstanceList == null || activityInstanceList.isEmpty()) {
+ result = "No results returned on activityInstance history lookup.";
+ } else {
+ activityInstance = activityInstanceList.get(0);
+ activityName = activityInstance.getActivityName();
+
+ if (activityName == null) {
+ result = "Task name is null.";
+ } else {
+ result = "Last task executed: " + activityName;
+ }
+ }
+
+ return result;
+ }
+
+ protected HttpHeaders setCamundaHeaders(String auth, String msoKey) {
+ HttpHeaders headers = new HttpHeaders();
+ List<org.springframework.http.MediaType> acceptableMediaTypes = new ArrayList<>();
+ acceptableMediaTypes.add(org.springframework.http.MediaType.APPLICATION_JSON);
+ headers.setAccept(acceptableMediaTypes);
+ try {
+ String userCredentials = CryptoUtils.decrypt(auth, msoKey);
+ if (userCredentials != null) {
+ headers.add(HttpHeaders.AUTHORIZATION,
+ "Basic " + DatatypeConverter.printBase64Binary(userCredentials.getBytes()));
+ }
+ } catch (GeneralSecurityException e) {
+ logger.error("Security exception", e);
+ }
+ return headers;
+ }
+
+ protected RetryTemplate setRetryTemplate() {
+ RetryTemplate retryTemplate = new RetryTemplate();
+ Map<Class<? extends Throwable>, Boolean> retryableExceptions = new HashMap<>();
+ retryableExceptions.put(ResourceAccessException.class, true);
+ SimpleRetryPolicy policy = new SimpleRetryPolicy(4, retryableExceptions);
+ retryTemplate.setRetryPolicy(policy);
+ return retryTemplate;
+ }
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/E2EServiceInstances.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/E2EServiceInstances.java
index af7641705e..d3a279fd8e 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/E2EServiceInstances.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/E2EServiceInstances.java
@@ -92,6 +92,8 @@ public class E2EServiceInstances {
private static final String END_OF_THE_TRANSACTION = "End of the transaction, the final response is: ";
+ private static final String SERVICE_ID = "serviceId";
+
@Autowired
private MsoRequest msoRequest;
@@ -138,7 +140,7 @@ public class E2EServiceInstances {
public Response updateE2EServiceInstance(String request, @PathParam("version") String version,
@PathParam("serviceId") String serviceId) throws ApiException {
- instanceIdMap.put("serviceId", serviceId);
+ instanceIdMap.put(SERVICE_ID, serviceId);
return updateE2EserviceInstances(request, Action.updateInstance, version);
}
@@ -155,9 +157,9 @@ public class E2EServiceInstances {
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(value = "Delete E2E Service Instance on a specified version and serviceId", response = Response.class)
public Response deleteE2EServiceInstance(String request, @PathParam("version") String version,
- @PathParam("serviceId") String serviceId) throws ApiException {
+ @PathParam(SERVICE_ID) String serviceId) throws ApiException {
- instanceIdMap.put("serviceId", serviceId);
+ instanceIdMap.put(SERVICE_ID, serviceId);
return deleteE2EserviceInstances(request, Action.deleteInstance, instanceIdMap, version);
}
@@ -167,7 +169,7 @@ public class E2EServiceInstances {
@ApiOperation(value = "Find e2eServiceInstances Requests for a given serviceId and operationId",
response = Response.class)
@Produces(MediaType.APPLICATION_JSON)
- public Response getE2EServiceInstances(@PathParam("serviceId") String serviceId,
+ public Response getE2EServiceInstances(@PathParam(SERVICE_ID) String serviceId,
@PathParam("version") String version, @PathParam("operationId") String operationId) {
return getE2EServiceInstance(serviceId, operationId, version);
}
@@ -184,10 +186,10 @@ public class E2EServiceInstances {
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(value = "Scale E2E Service Instance on a specified version", response = Response.class)
public Response scaleE2EServiceInstance(String request, @PathParam("version") String version,
- @PathParam("serviceId") String serviceId) throws ApiException {
+ @PathParam(SERVICE_ID) String serviceId) throws ApiException {
logger.debug("------------------scale begin------------------");
- instanceIdMap.put("serviceId", serviceId);
+ instanceIdMap.put(SERVICE_ID, serviceId);
return scaleE2EserviceInstances(request, Action.scaleInstance, version);
}
@@ -207,7 +209,7 @@ public class E2EServiceInstances {
public Response compareModelwithTargetVersion(String request, @PathParam("serviceId") String serviceId,
@PathParam("version") String version) throws ApiException {
- instanceIdMap.put("serviceId", serviceId);
+ instanceIdMap.put(SERVICE_ID, serviceId);
return compareModelwithTargetVersion(request, Action.compareModel, instanceIdMap, version);
}
@@ -216,7 +218,6 @@ public class E2EServiceInstances {
HashMap<String, String> instanceIdMap, String version) throws ApiException {
String requestId = UUID.randomUUID().toString();
- long startTime = System.currentTimeMillis();
CompareModelsRequest e2eCompareModelReq;
@@ -237,12 +238,12 @@ public class E2EServiceInstances {
return response;
}
- return runCompareModelBPMWorkflow(e2eCompareModelReq, requestJSON, requestId, startTime, action, version);
+ return runCompareModelBPMWorkflow(e2eCompareModelReq, requestJSON, requestId, action, version);
}
private Response runCompareModelBPMWorkflow(CompareModelsRequest e2eCompareModelReq, String requestJSON,
- String requestId, long startTime, Action action, String version) throws ApiException {
+ String requestId, Action action, String version) throws ApiException {
// Define RecipeLookupResult info here instead of query DB for efficiency
String workflowUrl = "/mso/async/services/CompareModelofE2EServiceInstance";
@@ -259,7 +260,7 @@ public class E2EServiceInstances {
// Capture audit event
logger.debug("MSO API Handler Posting call to BPEL engine for url: " + requestClient.getUrl());
- String serviceId = instanceIdMap.get("serviceId");
+ String serviceId = instanceIdMap.get(SERVICE_ID);
String serviceType = e2eCompareModelReq.getServiceType();
RequestClientParameter postParam = new RequestClientParameter.Builder().setRequestId(requestId)
.setBaseVfModule(false).setRecipeTimeout(recipeTimeout).setRequestAction(action.name())
@@ -334,7 +335,6 @@ public class E2EServiceInstances {
private Response deleteE2EserviceInstances(String requestJSON, Action action, HashMap<String, String> instanceIdMap,
String version) throws ApiException {
// TODO should be a new one or the same service instance Id
- long startTime = System.currentTimeMillis();
E2EServiceInstanceDeleteRequest e2eDelReq;
ObjectMapper mapper = new ObjectMapper();
@@ -397,7 +397,7 @@ public class E2EServiceInstances {
// Capture audit event
logger.debug("MSO API Handler Posting call to BPEL engine for url: " + requestClient.getUrl());
- String serviceId = instanceIdMap.get("serviceId");
+ String serviceId = instanceIdMap.get(SERVICE_ID);
String serviceInstanceType = e2eDelReq.getServiceType();
RequestClientParameter clientParam = new RequestClientParameter.Builder().setRequestId(requestId)
.setBaseVfModule(false).setRecipeTimeout(recipeLookupResult.getRecipeTimeout())
@@ -436,9 +436,8 @@ public class E2EServiceInstances {
private Response updateE2EserviceInstances(String requestJSON, Action action, String version) throws ApiException {
String requestId = UUID.randomUUID().toString();
- long startTime = System.currentTimeMillis();
E2EServiceInstanceRequest e2eSir;
- String serviceId = instanceIdMap.get("serviceId");
+ String serviceId = instanceIdMap.get(SERVICE_ID);
ObjectMapper mapper = new ObjectMapper();
try {
@@ -552,7 +551,6 @@ public class E2EServiceInstances {
HashMap<String, String> instanceIdMap, String version) throws ApiException {
String requestId = UUID.randomUUID().toString();
- long startTime = System.currentTimeMillis();
E2EServiceInstanceRequest e2eSir;
MsoRequest msoRequest = new MsoRequest();
@@ -663,7 +661,6 @@ public class E2EServiceInstances {
private Response scaleE2EserviceInstances(String requestJSON, Action action, String version) throws ApiException {
String requestId = UUID.randomUUID().toString();
- long startTime = System.currentTimeMillis();
E2EServiceInstanceScaleRequest e2eScaleReq;
ObjectMapper mapper = new ObjectMapper();
@@ -725,7 +722,7 @@ public class E2EServiceInstances {
// Capture audit event
logger.debug("MSO API Handler Posting call to BPEL engine for url: " + requestClient.getUrl());
- String serviceId = instanceIdMap.get("serviceId");
+ String serviceId = instanceIdMap.get(SERVICE_ID);
String serviceInstanceType = e2eScaleReq.getService().getServiceType();
RequestClientParameter postParam = new RequestClientParameter.Builder().setRequestId(requestId)
.setBaseVfModule(false).setRecipeTimeout(recipeLookupResult.getRecipeTimeout())
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/OrchestrationRequests.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/OrchestrationRequests.java
index 9e92c293bf..6f36fb2aff 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/OrchestrationRequests.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/OrchestrationRequests.java
@@ -46,6 +46,7 @@ import org.apache.http.HttpStatus;
import org.onap.so.apihandler.common.ErrorNumbers;
import org.onap.so.apihandler.common.ResponseBuilder;
import org.onap.so.apihandlerinfra.exceptions.ApiException;
+import org.onap.so.apihandlerinfra.exceptions.ContactCamundaException;
import org.onap.so.apihandlerinfra.exceptions.ValidateException;
import org.onap.so.apihandlerinfra.logging.ErrorLoggerInfo;
import org.onap.so.constants.OrchestrationRequestFormat;
@@ -91,6 +92,9 @@ public class OrchestrationRequests {
@Autowired
private ResponseBuilder builder;
+ @Autowired
+ private CamundaRequestHandler camundaRequestHandler;
+
@GET
@Path("/{version:[vV][4-7]}/{requestId}")
@ApiOperation(value = "Find Orchestrated Requests for a given requestId", response = Response.class)
@@ -424,10 +428,19 @@ public class OrchestrationRequests {
}
protected void mapRequestStatusAndExtSysErrSrcToRequest(InfraActiveRequests iar, RequestStatus status,
- String format) {
+ String format) throws ContactCamundaException {
String rollbackStatusMessage = iar.getRollbackStatusMessage();
String flowStatusMessage = iar.getFlowStatus();
String retryStatusMessage = iar.getRetryStatusMessage();
+ String taskName = null;
+
+ if (flowStatusMessage != null && !flowStatusMessage.equals("Successfully completed all Building Blocks")
+ && !flowStatusMessage.equals("All Rollback flows have completed successfully")) {
+ taskName = camundaRequestHandler.getTaskName(iar.getRequestId());
+ if (taskName != null) {
+ flowStatusMessage = flowStatusMessage + " TASK INFORMATION: " + taskName;
+ }
+ }
String statusMessages = null;
if (iar.getStatusMessage() != null) {
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/RequestHandlerUtils.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/RequestHandlerUtils.java
index c3f323459c..9ab95a2319 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/RequestHandlerUtils.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/RequestHandlerUtils.java
@@ -27,7 +27,6 @@ package org.onap.so.apihandlerinfra;
import static org.onap.so.logger.HttpHeadersConstants.REQUESTOR_ID;
import java.io.IOException;
import java.net.URL;
-import java.security.GeneralSecurityException;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.HashMap;
@@ -37,7 +36,6 @@ import java.util.Optional;
import javax.ws.rs.container.ContainerRequestContext;
import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.core.Response;
-import javax.xml.bind.DatatypeConverter;
import org.apache.commons.lang.StringUtils;
import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus;
@@ -78,21 +76,16 @@ import org.onap.so.serviceinstancebeans.RelatedInstanceList;
import org.onap.so.serviceinstancebeans.RequestParameters;
import org.onap.so.serviceinstancebeans.ServiceInstancesRequest;
import org.onap.so.serviceinstancebeans.ServiceInstancesResponse;
-import org.onap.so.utils.CryptoUtils;
import org.onap.so.utils.UUIDChecker;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.MDC;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.core.ParameterizedTypeReference;
import org.springframework.core.env.Environment;
-import org.springframework.http.HttpEntity;
-import org.springframework.http.HttpHeaders;
-import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;
import org.springframework.web.client.HttpStatusCodeException;
-import org.springframework.web.client.RestTemplate;
+import org.springframework.web.client.RestClientException;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.databind.ObjectMapper;
@@ -119,7 +112,7 @@ public class RequestHandlerUtils extends AbstractRestHandler {
private MsoRequest msoRequest;
@Autowired
- private RestTemplate restTemplate;
+ private CamundaRequestHandler camundaRequestHandler;
@Autowired
private CatalogDbClient catalogDbClient;
@@ -323,25 +316,20 @@ public class RequestHandlerUtils extends AbstractRestHandler {
public boolean camundaHistoryCheck(InfraActiveRequests duplicateRecord, InfraActiveRequests currentActiveReq)
throws RequestDbFailureException, ContactCamundaException {
String requestId = duplicateRecord.getRequestId();
- String path = env.getProperty("mso.camunda.rest.history.uri") + requestId;
- String targetUrl = env.getProperty("mso.camundaURL") + path;
- HttpHeaders headers =
- setCamundaHeaders(env.getRequiredProperty("mso.camundaAuth"), env.getRequiredProperty("mso.msoKey"));
- HttpEntity<?> requestEntity = new HttpEntity<>(headers);
ResponseEntity<List<HistoricProcessInstanceEntity>> response = null;
try {
- response = restTemplate.exchange(targetUrl, HttpMethod.GET, requestEntity,
- new ParameterizedTypeReference<List<HistoricProcessInstanceEntity>>() {});
- } catch (HttpStatusCodeException e) {
- ErrorLoggerInfo errorLoggerInfo =
- new ErrorLoggerInfo.Builder(MessageEnum.APIH_DUPLICATE_CHECK_EXC, ErrorCode.DataError)
- .errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build();
+ response = camundaRequestHandler.getCamundaProcessInstanceHistory(requestId);
+ } catch (RestClientException e) {
+ logger.error("Error querying Camunda for process-instance history for requestId: {}, exception: {}",
+ requestId, e.getMessage());
ContactCamundaException contactCamundaException =
- new ContactCamundaException.Builder(requestId, e.toString(), HttpStatus.SC_INTERNAL_SERVER_ERROR,
- ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).cause(e).errorInfo(errorLoggerInfo).build();
+ new ContactCamundaException.Builder("process-instance", requestId, e.toString(),
+ HttpStatus.SC_INTERNAL_SERVER_ERROR, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).cause(e)
+ .build();
updateStatus(currentActiveReq, Status.FAILED, contactCamundaException.getMessage());
throw contactCamundaException;
}
+
if (response.getBody().isEmpty()) {
updateStatus(duplicateRecord, Status.COMPLETE, "Request Completed");
}
@@ -355,23 +343,6 @@ public class RequestHandlerUtils extends AbstractRestHandler {
return false;
}
- protected HttpHeaders setCamundaHeaders(String auth, String msoKey) {
- HttpHeaders headers = new HttpHeaders();
- List<org.springframework.http.MediaType> acceptableMediaTypes = new ArrayList<>();
- acceptableMediaTypes.add(org.springframework.http.MediaType.APPLICATION_JSON);
- headers.setAccept(acceptableMediaTypes);
- try {
- String userCredentials = CryptoUtils.decrypt(auth, msoKey);
- if (userCredentials != null) {
- headers.add(HttpHeaders.AUTHORIZATION,
- "Basic " + DatatypeConverter.printBase64Binary(userCredentials.getBytes()));
- }
- } catch (GeneralSecurityException e) {
- logger.error("Security exception", e);
- }
- return headers;
- }
-
public ServiceInstancesRequest convertJsonToServiceInstanceRequest(String requestJSON, Actions action,
String requestId, String requestUri) throws ApiException {
try {
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/Network.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/Network.java
index c44f1f0e0a..ec3df21fdb 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/Network.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/Network.java
@@ -4,6 +4,8 @@
* ================================================================================
* Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
* ================================================================================
+ * Modifications Copyright (c) 2019 Samsung
+ * ================================================================================
* 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
@@ -38,8 +40,6 @@ import org.onap.so.db.catalog.beans.Recipe;
import org.onap.so.db.request.beans.InfraActiveRequests;
import org.onap.so.serviceinstancebeans.ServiceInstancesRequest;
import org.onap.so.serviceinstancebeans.ServiceInstancesResponse;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import org.slf4j.MDC;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
@@ -50,8 +50,6 @@ import io.swagger.annotations.ApiOperation;
@Path("/onap/so/infra/serviceInstantiation")
public class Network {
- private static Logger logger = LoggerFactory.getLogger(Network.class);
-
@Autowired
private NetworkRestHandler networkRestHandler;
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/ServiceInstance.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/ServiceInstance.java
index bf10fcc183..07e8092449 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/ServiceInstance.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/ServiceInstance.java
@@ -4,6 +4,8 @@
* ================================================================================
* Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
* ================================================================================
+ * Modifications Copyright (c) 2019 Samsung
+ * ================================================================================
* 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
@@ -38,8 +40,6 @@ import org.onap.so.db.catalog.beans.Recipe;
import org.onap.so.db.request.beans.InfraActiveRequests;
import org.onap.so.serviceinstancebeans.ServiceInstancesRequest;
import org.onap.so.serviceinstancebeans.ServiceInstancesResponse;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import org.slf4j.MDC;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
@@ -50,8 +50,6 @@ import io.swagger.annotations.ApiOperation;
@Path("/onap/so/infra/serviceInstantiation")
public class ServiceInstance {
- private static Logger logger = LoggerFactory.getLogger(ServiceInstance.class);
-
@Autowired
private ServiceInstanceRestHandler requestHandler;
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/VfModules.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/VfModules.java
index 1a2688f0b3..1b9eb1f802 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/VfModules.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/VfModules.java
@@ -4,6 +4,8 @@
* ================================================================================
* Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
* ================================================================================
+ * Modifications Copyright (c) 2019 Samsung
+ * ================================================================================
* 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
@@ -39,8 +41,6 @@ import org.onap.so.db.request.beans.InfraActiveRequests;
import org.onap.so.serviceinstancebeans.ModelType;
import org.onap.so.serviceinstancebeans.ServiceInstancesRequest;
import org.onap.so.serviceinstancebeans.ServiceInstancesResponse;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import org.slf4j.MDC;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
@@ -51,8 +51,6 @@ import io.swagger.annotations.ApiOperation;
@Path("/onap/so/infra/serviceInstantiation")
public class VfModules {
- private static Logger logger = LoggerFactory.getLogger(VfModules.class);
-
@Autowired
private VFModuleRestHandler restHandler;
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/Vnf.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/Vnf.java
index b161713a71..a8ccdeecac 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/Vnf.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/Vnf.java
@@ -4,6 +4,8 @@
* ================================================================================
* Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
* ================================================================================
+ * Modifications Copyright (c) 2019 Samsung
+ * ================================================================================
* 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
@@ -37,8 +39,6 @@ import org.onap.so.db.catalog.beans.Recipe;
import org.onap.so.db.request.beans.InfraActiveRequests;
import org.onap.so.serviceinstancebeans.ServiceInstancesRequest;
import org.onap.so.serviceinstancebeans.ServiceInstancesResponse;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import org.slf4j.MDC;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
@@ -49,8 +49,6 @@ import io.swagger.annotations.ApiOperation;
@Path("/onap/so/infra/serviceInstantiation")
public class Vnf {
- private static Logger logger = LoggerFactory.getLogger(Vnf.class);
-
@Autowired
private BpmnRequestBuilder requestBuilder;
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/Volumes.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/Volumes.java
index afabdd9c60..d3e394d6d8 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/Volumes.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/Volumes.java
@@ -4,6 +4,8 @@
* ================================================================================
* Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
* ================================================================================
+ * Modifications Copyright (c) 2019 Samsung
+ * ================================================================================
* 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
@@ -40,8 +42,6 @@ import org.onap.so.db.request.beans.InfraActiveRequests;
import org.onap.so.serviceinstancebeans.ModelType;
import org.onap.so.serviceinstancebeans.ServiceInstancesRequest;
import org.onap.so.serviceinstancebeans.ServiceInstancesResponse;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import org.slf4j.MDC;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
@@ -52,8 +52,6 @@ import io.swagger.annotations.ApiOperation;
@Path("/onap/so/infra/serviceInstantiation")
public class Volumes {
- private static Logger logger = LoggerFactory.getLogger(Volumes.class);
-
@Autowired
private BpmnRequestBuilder requestBuilder;
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/resources/application.yaml b/mso-api-handlers/mso-api-handler-infra/src/main/resources/application.yaml
index 136acfb9e1..93a4ae9489 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/resources/application.yaml
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/resources/application.yaml
@@ -26,6 +26,10 @@ mso:
uri: /sobpmnengine/task
history:
uri: /sobpmnengine/history/process-instance?variables=mso-request-id_eq_
+ activity:
+ uri: /sobpmnengine/history/activity-instance?processInstanceId=
+ camundaURL: http://localhost:8089
+ camundaAuth: E8E19DD16CC90D2E458E8FF9A884CC0452F8F3EB8E321F96038DE38D5C1B0B02DFAE00B88E2CF6E2A4101AB2C011FC161212EE
spring:
datasource:
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/CamundaRequestHandlerTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/CamundaRequestHandlerTest.java
new file mode 100644
index 0000000000..e6b5163f59
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/CamundaRequestHandlerTest.java
@@ -0,0 +1,327 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2019 AT&T 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.apihandlerinfra;
+
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.doThrow;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.util.ArrayList;
+import java.util.List;
+import org.camunda.bpm.engine.impl.persistence.entity.HistoricActivityInstanceEntity;
+import org.camunda.bpm.engine.impl.persistence.entity.HistoricProcessInstanceEntity;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.junit.runner.RunWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.Spy;
+import org.mockito.junit.MockitoJUnitRunner;
+import org.onap.so.apihandlerinfra.exceptions.ContactCamundaException;
+import org.onap.so.apihandlerinfra.exceptions.RequestDbFailureException;
+import org.springframework.core.ParameterizedTypeReference;
+import org.springframework.core.env.Environment;
+import org.springframework.http.HttpEntity;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.HttpMethod;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.client.HttpClientErrorException;
+import org.springframework.web.client.HttpStatusCodeException;
+import org.springframework.web.client.ResourceAccessException;
+import org.springframework.web.client.RestTemplate;
+import com.fasterxml.jackson.core.type.TypeReference;
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+@RunWith(MockitoJUnitRunner.class)
+public class CamundaRequestHandlerTest {
+
+ @Mock
+ private RestTemplate restTemplate;
+
+ @Mock
+ private Environment env;
+
+ @InjectMocks
+ @Spy
+ private CamundaRequestHandler camundaRequestHandler;
+
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
+
+ private static final String REQUEST_ID = "eca3a1b1-43ab-457e-ab1c-367263d148b4";
+ private ResponseEntity<List<HistoricActivityInstanceEntity>> activityInstanceResponse = null;
+ private ResponseEntity<List<HistoricProcessInstanceEntity>> processInstanceResponse = null;
+ private List<HistoricActivityInstanceEntity> activityInstanceList = null;
+ private List<HistoricProcessInstanceEntity> processInstanceList = null;
+
+
+
+ @Before
+ public void setup() throws IOException {
+ ObjectMapper mapper = new ObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+ activityInstanceList = mapper.readValue(
+ new String(Files.readAllBytes(
+ Paths.get("src/test/resources/OrchestrationRequest/ActivityInstanceHistoryResponse.json"))),
+ new TypeReference<List<HistoricActivityInstanceEntity>>() {});
+ processInstanceList = mapper.readValue(
+ new String(Files.readAllBytes(
+ Paths.get("src/test/resources/OrchestrationRequest/ProcessInstanceHistoryResponse.json"))),
+ new TypeReference<List<HistoricProcessInstanceEntity>>() {});
+ processInstanceResponse =
+ new ResponseEntity<List<HistoricProcessInstanceEntity>>(processInstanceList, HttpStatus.ACCEPTED);
+ activityInstanceResponse =
+ new ResponseEntity<List<HistoricActivityInstanceEntity>>(activityInstanceList, HttpStatus.ACCEPTED);
+
+ doReturn("/sobpmnengine/history/process-instance?variables=mso-request-id_eq_").when(env)
+ .getProperty("mso.camunda.rest.history.uri");
+ doReturn("/sobpmnengine/history/activity-instance?processInstanceId=").when(env)
+ .getProperty("mso.camunda.rest.activity.uri");
+ doReturn("auth").when(env).getRequiredProperty("mso.camundaAuth");
+ doReturn("key").when(env).getRequiredProperty("mso.msoKey");
+ doReturn("http://localhost:8089").when(env).getProperty("mso.camundaURL");
+ }
+
+ public HttpHeaders setHeaders() {
+ HttpHeaders headers = new HttpHeaders();
+ List<org.springframework.http.MediaType> acceptableMediaTypes = new ArrayList<>();
+ acceptableMediaTypes.add(org.springframework.http.MediaType.APPLICATION_JSON);
+ headers.setAccept(acceptableMediaTypes);
+ headers.add(HttpHeaders.AUTHORIZATION, "auth");
+
+ return headers;
+ }
+
+ @Test
+ public void getActivityNameTest() throws IOException {
+ String expectedActivityName = "Last task executed: BB to Execute";
+ String actualActivityName = camundaRequestHandler.getActivityName(activityInstanceList);
+
+ assertEquals(expectedActivityName, actualActivityName);
+ }
+
+ @Test
+ public void getActivityNameNullActivityNameTest() throws IOException {
+ String expectedActivityName = "Task name is null.";
+ HistoricActivityInstanceEntity activityInstance = new HistoricActivityInstanceEntity();
+ List<HistoricActivityInstanceEntity> activityInstanceList = new ArrayList<>();
+ activityInstanceList.add(activityInstance);
+
+ String actualActivityName = camundaRequestHandler.getActivityName(activityInstanceList);
+
+ assertEquals(expectedActivityName, actualActivityName);
+ }
+
+ @Test
+ public void getActivityNameNullListTest() throws IOException {
+ String expectedActivityName = "No results returned on activityInstance history lookup.";
+ List<HistoricActivityInstanceEntity> activityInstanceList = null;
+ String actualActivityName = camundaRequestHandler.getActivityName(activityInstanceList);
+
+ assertEquals(expectedActivityName, actualActivityName);
+ }
+
+ @Test
+ public void getActivityNameEmptyListTest() throws IOException {
+ String expectedActivityName = "No results returned on activityInstance history lookup.";
+ List<HistoricActivityInstanceEntity> activityInstanceList = new ArrayList<>();
+ String actualActivityName = camundaRequestHandler.getActivityName(activityInstanceList);
+
+ assertEquals(expectedActivityName, actualActivityName);
+ }
+
+ @Test
+ public void getTaskNameTest() throws IOException, ContactCamundaException {
+ doReturn(processInstanceResponse).when(camundaRequestHandler).getCamundaProcessInstanceHistory(REQUEST_ID);
+ doReturn(activityInstanceResponse).when(camundaRequestHandler)
+ .getCamundaActivityHistory("c4c6b647-a26e-11e9-b144-0242ac14000b", REQUEST_ID);
+ doReturn("Last task executed: BB to Execute").when(camundaRequestHandler).getActivityName(activityInstanceList);
+ String expectedTaskName = "Last task executed: BB to Execute";
+
+ String actualTaskName = camundaRequestHandler.getTaskName(REQUEST_ID);
+
+ assertEquals(expectedTaskName, actualTaskName);
+ }
+
+ @Test
+ public void getTaskNameNullProcessInstanceListTest() throws IOException, ContactCamundaException {
+ ResponseEntity<List<HistoricProcessInstanceEntity>> response = new ResponseEntity<>(null, HttpStatus.OK);
+ doReturn(response).when(camundaRequestHandler).getCamundaProcessInstanceHistory(REQUEST_ID);
+ String expected = "No processInstances returned for requestId: " + REQUEST_ID;
+
+ String actual = camundaRequestHandler.getTaskName(REQUEST_ID);
+
+ assertEquals(expected, actual);
+ }
+
+ @Test
+ public void getTaskNameNullProcessInstanceIdTest() throws IOException, ContactCamundaException {
+ HistoricProcessInstanceEntity processInstance = new HistoricProcessInstanceEntity();
+ List<HistoricProcessInstanceEntity> processInstanceList = new ArrayList<>();
+ processInstanceList.add(processInstance);
+ ResponseEntity<List<HistoricProcessInstanceEntity>> response =
+ new ResponseEntity<>(processInstanceList, HttpStatus.OK);
+ doReturn(response).when(camundaRequestHandler).getCamundaProcessInstanceHistory(REQUEST_ID);
+ String expected = "No processInstanceId returned for requestId: " + REQUEST_ID;
+
+ String actual = camundaRequestHandler.getTaskName(REQUEST_ID);
+
+ assertEquals(expected, actual);
+ }
+
+ @Test
+ public void getTaskNameProcessInstanceLookupFailureTest() throws IOException, ContactCamundaException {
+ doThrow(HttpClientErrorException.class).when(camundaRequestHandler)
+ .getCamundaProcessInstanceHistory(REQUEST_ID);
+
+ thrown.expect(ContactCamundaException.class);
+ camundaRequestHandler.getTaskName(REQUEST_ID);
+ }
+
+ @Test
+ public void getCamundaActivityHistoryTest() throws IOException, ContactCamundaException {
+ HttpHeaders headers = setHeaders();
+ HttpEntity<?> requestEntity = new HttpEntity<>(headers);
+ String targetUrl = "http://localhost:8089/sobpmnengine/history/activity-instance?processInstanceId="
+ + "c4c6b647-a26e-11e9-b144-0242ac14000b";
+ doReturn(activityInstanceResponse).when(restTemplate).exchange(targetUrl, HttpMethod.GET, requestEntity,
+ new ParameterizedTypeReference<List<HistoricActivityInstanceEntity>>() {});
+ doReturn(headers).when(camundaRequestHandler).setCamundaHeaders("auth", "key");
+ ResponseEntity<List<HistoricActivityInstanceEntity>> actualResponse =
+ camundaRequestHandler.getCamundaActivityHistory("c4c6b647-a26e-11e9-b144-0242ac14000b", REQUEST_ID);
+ assertEquals(activityInstanceResponse, actualResponse);
+ }
+
+ @Test
+ public void getCamundaActivityHistoryErrorTest() {
+ HttpHeaders headers = setHeaders();
+ HttpEntity<?> requestEntity = new HttpEntity<>(headers);
+ String targetUrl = "http://localhost:8089/sobpmnengine/history/activity-instance?processInstanceId="
+ + "c4c6b647-a26e-11e9-b144-0242ac14000b";
+ doThrow(new ResourceAccessException("IOException")).when(restTemplate).exchange(targetUrl, HttpMethod.GET,
+ requestEntity, new ParameterizedTypeReference<List<HistoricActivityInstanceEntity>>() {});
+ doReturn(headers).when(camundaRequestHandler).setCamundaHeaders("auth", "key");
+
+ try {
+ camundaRequestHandler.getCamundaActivityHistory("c4c6b647-a26e-11e9-b144-0242ac14000b", REQUEST_ID);
+ } catch (ContactCamundaException e) {
+ // Exception thrown after retries are completed
+ }
+
+ verify(restTemplate, times(4)).exchange(targetUrl, HttpMethod.GET, requestEntity,
+ new ParameterizedTypeReference<List<HistoricActivityInstanceEntity>>() {});
+ }
+
+ @Test
+ public void getCamundaProccesInstanceHistoryTest() throws IOException, ContactCamundaException {
+ HttpHeaders headers = setHeaders();
+ HttpEntity<?> requestEntity = new HttpEntity<>(headers);
+ String targetUrl =
+ "http://localhost:8089/sobpmnengine/history/process-instance?variables=mso-request-id_eq_" + REQUEST_ID;
+ doReturn(processInstanceResponse).when(restTemplate).exchange(targetUrl, HttpMethod.GET, requestEntity,
+ new ParameterizedTypeReference<List<HistoricProcessInstanceEntity>>() {});
+ doReturn(headers).when(camundaRequestHandler).setCamundaHeaders("auth", "key");
+
+ ResponseEntity<List<HistoricProcessInstanceEntity>> actualResponse =
+ camundaRequestHandler.getCamundaProcessInstanceHistory(REQUEST_ID);
+ assertEquals(processInstanceResponse, actualResponse);
+ }
+
+ @Test
+ public void getCamundaProccesInstanceHistoryRetryTest() {
+ HttpHeaders headers = setHeaders();
+ HttpEntity<?> requestEntity = new HttpEntity<>(headers);
+ String targetUrl =
+ "http://localhost:8089/sobpmnengine/history/process-instance?variables=mso-request-id_eq_" + REQUEST_ID;
+ doThrow(new ResourceAccessException("I/O error")).when(restTemplate).exchange(targetUrl, HttpMethod.GET,
+ requestEntity, new ParameterizedTypeReference<List<HistoricProcessInstanceEntity>>() {});
+ doReturn(headers).when(camundaRequestHandler).setCamundaHeaders("auth", "key");
+
+ try {
+ camundaRequestHandler.getCamundaProcessInstanceHistory(REQUEST_ID);
+ } catch (ResourceAccessException e) {
+ // Exception thrown after retries are completed
+ }
+ verify(restTemplate, times(4)).exchange(targetUrl, HttpMethod.GET, requestEntity,
+ new ParameterizedTypeReference<List<HistoricProcessInstanceEntity>>() {});
+ }
+
+ @Test
+ public void getCamundaProccesInstanceHistoryNoRetryTest() {
+ HttpHeaders headers = setHeaders();
+ HttpEntity<?> requestEntity = new HttpEntity<>(headers);
+ String targetUrl =
+ "http://localhost:8089/sobpmnengine/history/process-instance?variables=mso-request-id_eq_" + REQUEST_ID;
+ doThrow(HttpClientErrorException.class).when(restTemplate).exchange(targetUrl, HttpMethod.GET, requestEntity,
+ new ParameterizedTypeReference<List<HistoricProcessInstanceEntity>>() {});
+ doReturn(headers).when(camundaRequestHandler).setCamundaHeaders("auth", "key");
+
+ try {
+ camundaRequestHandler.getCamundaProcessInstanceHistory(REQUEST_ID);
+ } catch (HttpStatusCodeException e) {
+ // Exception thrown, no retries
+ }
+ verify(restTemplate, times(1)).exchange(targetUrl, HttpMethod.GET, requestEntity,
+ new ParameterizedTypeReference<List<HistoricProcessInstanceEntity>>() {});
+ }
+
+ @Test
+ public void getCamundaProccesInstanceHistoryFailThenSuccessTest() throws IOException, ContactCamundaException {
+ HttpHeaders headers = setHeaders();
+ HttpEntity<?> requestEntity = new HttpEntity<>(headers);
+ String targetUrl =
+ "http://localhost:8089/sobpmnengine/history/process-instance?variables=mso-request-id_eq_" + REQUEST_ID;
+ when(restTemplate.exchange(targetUrl, HttpMethod.GET, requestEntity,
+ new ParameterizedTypeReference<List<HistoricProcessInstanceEntity>>() {}))
+ .thenThrow(new ResourceAccessException("I/O Exception")).thenReturn(processInstanceResponse);
+ doReturn(headers).when(camundaRequestHandler).setCamundaHeaders("auth", "key");
+
+ ResponseEntity<List<HistoricProcessInstanceEntity>> actualResponse =
+ camundaRequestHandler.getCamundaProcessInstanceHistory(REQUEST_ID);
+ assertEquals(processInstanceResponse, actualResponse);
+ verify(restTemplate, times(2)).exchange(targetUrl, HttpMethod.GET, requestEntity,
+ new ParameterizedTypeReference<List<HistoricProcessInstanceEntity>>() {});
+ }
+
+ @Test
+ public void setCamundaHeadersTest() throws ContactCamundaException, RequestDbFailureException {
+ String encryptedAuth = "015E7ACF706C6BBF85F2079378BDD2896E226E09D13DC2784BA309E27D59AB9FAD3A5E039DF0BB8408"; // user:password
+ String key = "07a7159d3bf51a0e53be7a8f89699be7";
+
+ HttpHeaders headers = camundaRequestHandler.setCamundaHeaders(encryptedAuth, key);
+ List<org.springframework.http.MediaType> acceptedType = headers.getAccept();
+
+ String expectedAcceptedType = "application/json";
+ assertEquals(expectedAcceptedType, acceptedType.get(0).toString());
+ String basicAuth = headers.getFirst(HttpHeaders.AUTHORIZATION);
+ String expectedBasicAuth = "Basic dXNlcjpwYXNzd29yZA==";
+
+ assertEquals(expectedBasicAuth, basicAuth);
+ }
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/OrchestrationRequestsTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/OrchestrationRequestsTest.java
index f82f5ac746..12f0ffcc11 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/OrchestrationRequestsTest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/OrchestrationRequestsTest.java
@@ -26,6 +26,7 @@ import static com.github.tomakehurst.wiremock.client.WireMock.equalTo;
import static com.github.tomakehurst.wiremock.client.WireMock.equalToJson;
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.urlMatching;
import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
import static com.shazam.shazamcrest.MatcherAssert.assertThat;
import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
@@ -42,6 +43,7 @@ import java.util.Map;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import org.apache.http.HttpStatus;
+import org.junit.Before;
import org.junit.Test;
import org.onap.so.apihandler.common.ErrorNumbers;
import org.onap.so.db.request.beans.InfraActiveRequests;
@@ -92,6 +94,21 @@ public class OrchestrationRequestsTest extends BaseTest {
return list;
}
+ @Before
+ public void setup() throws IOException {
+ wireMockServer.stubFor(get(urlMatching("/sobpmnengine/history/process-instance.*")).willReturn(aResponse()
+ .withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ .withBody(new String(Files.readAllBytes(
+ Paths.get("src/test/resources/OrchestrationRequest/ProcessInstanceHistoryResponse.json"))))
+ .withStatus(org.apache.http.HttpStatus.SC_OK)));
+ wireMockServer.stubFor(
+ get(("/sobpmnengine/history/activity-instance?processInstanceId=c4c6b647-a26e-11e9-b144-0242ac14000b"))
+ .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ .withBody(new String(Files.readAllBytes(Paths.get(
+ "src/test/resources/OrchestrationRequest/ActivityInstanceHistoryResponse.json"))))
+ .withStatus(HttpStatus.SC_OK)));
+ }
+
@Test
public void testGetOrchestrationRequest() throws Exception {
setupTestGetOrchestrationRequest();
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/OrchestrationRequestsUnitTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/OrchestrationRequestsUnitTest.java
index fc548a715e..5023155768 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/OrchestrationRequestsUnitTest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/OrchestrationRequestsUnitTest.java
@@ -25,6 +25,7 @@ import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
+import static org.mockito.Mockito.doReturn;
import javax.ws.rs.core.Response;
import org.apache.commons.lang.StringUtils;
import org.junit.Before;
@@ -55,6 +56,8 @@ public class OrchestrationRequestsUnitTest {
private ResponseBuilder builder;
@Mock
private Response response;
+ @Mock
+ private CamundaRequestHandler camundaRequestHandler;
@Rule
public ExpectedException thrown = ExpectedException.none();
@InjectMocks
@@ -68,6 +71,7 @@ public class OrchestrationRequestsUnitTest {
private static final String FLOW_STATUS = "FlowStatus";
private static final String RETRY_STATUS_MESSAGE = "RetryStatusMessage";
private static final String ROLLBACK_STATUS_MESSAGE = "RollbackStatusMessage";
+ private static final String TASK_INFORMATION = " TASK INFORMATION: Last task executed: Call SDNC";
private InfraActiveRequests iar;
boolean includeCloudRequest = false;
private static final String ROLLBACK_EXT_SYSTEM_ERROR_SOURCE = "SDNC";
@@ -79,14 +83,23 @@ public class OrchestrationRequestsUnitTest {
iar.setRequestScope(SERVICE);
iar.setRequestId(REQUEST_ID);
iar.setServiceInstanceId(SERVICE_INSTANCE_ID);
+ iar.setExtSystemErrorSource(EXT_SYSTEM_ERROR_SOURCE);
+ iar.setRollbackExtSystemErrorSource(ROLLBACK_EXT_SYSTEM_ERROR_SOURCE);
+ iar.setFlowStatus(FLOW_STATUS);
+ iar.setRollbackStatusMessage(ROLLBACK_STATUS_MESSAGE);
+ iar.setRetryStatusMessage(RETRY_STATUS_MESSAGE);
}
@Test
public void mapInfraActiveRequestToRequestWithOriginalRequestIdTest() throws ApiException {
+ doReturn("Last task executed: Call SDNC").when(camundaRequestHandler).getTaskName(REQUEST_ID);
InstanceReferences instanceReferences = new InstanceReferences();
instanceReferences.setServiceInstanceId(SERVICE_INSTANCE_ID);
RequestStatus requestStatus = new RequestStatus();
requestStatus.setRequestState(iar.getRequestStatus());
+ requestStatus.setStatusMessage(String.format("FLOW STATUS: %s RETRY STATUS: %s ROLLBACK STATUS: %s",
+ FLOW_STATUS + TASK_INFORMATION, RETRY_STATUS_MESSAGE, ROLLBACK_STATUS_MESSAGE));
+
Request expected = new Request();
expected.setRequestId(REQUEST_ID);
expected.setOriginalRequestId(ORIGINAL_REQUEST_ID);
@@ -103,10 +116,13 @@ public class OrchestrationRequestsUnitTest {
@Test
public void mapInfraActiveRequestToRequestOriginalRequestIdNullTest() throws ApiException {
+ doReturn("Last task executed: Call SDNC").when(camundaRequestHandler).getTaskName(REQUEST_ID);
InstanceReferences instanceReferences = new InstanceReferences();
instanceReferences.setServiceInstanceId(SERVICE_INSTANCE_ID);
RequestStatus requestStatus = new RequestStatus();
requestStatus.setRequestState(iar.getRequestStatus());
+ requestStatus.setStatusMessage(String.format("FLOW STATUS: %s RETRY STATUS: %s ROLLBACK STATUS: %s",
+ FLOW_STATUS + TASK_INFORMATION, RETRY_STATUS_MESSAGE, ROLLBACK_STATUS_MESSAGE));
Request expected = new Request();
expected.setRequestId(REQUEST_ID);
expected.setInstanceReferences(instanceReferences);
@@ -120,10 +136,13 @@ public class OrchestrationRequestsUnitTest {
@Test
public void mapRequestStatusAndExtSysErrSrcToRequestFalseTest() throws ApiException {
+ doReturn("Last task executed: Call SDNC").when(camundaRequestHandler).getTaskName(REQUEST_ID);
InstanceReferences instanceReferences = new InstanceReferences();
instanceReferences.setServiceInstanceId(SERVICE_INSTANCE_ID);
RequestStatus requestStatus = new RequestStatus();
requestStatus.setRequestState(iar.getRequestStatus());
+ requestStatus.setStatusMessage(String.format("FLOW STATUS: %s RETRY STATUS: %s ROLLBACK STATUS: %s",
+ FLOW_STATUS + TASK_INFORMATION, RETRY_STATUS_MESSAGE, ROLLBACK_STATUS_MESSAGE));
Request expected = new Request();
expected.setRequestId(REQUEST_ID);
@@ -140,6 +159,7 @@ public class OrchestrationRequestsUnitTest {
@Test
public void mapRequestStatusAndExtSysErrSrcToRequestStatusDetailTest() throws ApiException {
+ doReturn(null).when(camundaRequestHandler).getTaskName(REQUEST_ID);
InstanceReferences instanceReferences = new InstanceReferences();
instanceReferences.setServiceInstanceId(SERVICE_INSTANCE_ID);
RequestStatus requestStatus = new RequestStatus();
@@ -157,11 +177,6 @@ public class OrchestrationRequestsUnitTest {
expected.setRequestScope(SERVICE);
includeCloudRequest = false;
- iar.setExtSystemErrorSource(EXT_SYSTEM_ERROR_SOURCE);
- iar.setRollbackExtSystemErrorSource(ROLLBACK_EXT_SYSTEM_ERROR_SOURCE);
- iar.setFlowStatus(FLOW_STATUS);
- iar.setRollbackStatusMessage(ROLLBACK_STATUS_MESSAGE);
- iar.setRetryStatusMessage(RETRY_STATUS_MESSAGE);
Request actual = orchestrationRequests.mapInfraActiveRequestToRequest(iar, includeCloudRequest,
OrchestrationRequestFormat.STATUSDETAIL.toString());
@@ -170,12 +185,13 @@ public class OrchestrationRequestsUnitTest {
@Test
public void mapRequestStatusAndExtSysErrSrcToRequestDetailTest() throws ApiException {
+ doReturn("Last task executed: Call SDNC").when(camundaRequestHandler).getTaskName(REQUEST_ID);
InstanceReferences instanceReferences = new InstanceReferences();
instanceReferences.setServiceInstanceId(SERVICE_INSTANCE_ID);
RequestStatus requestStatus = new RequestStatus();
requestStatus.setRequestState(iar.getRequestStatus());
requestStatus.setStatusMessage(String.format("FLOW STATUS: %s RETRY STATUS: %s ROLLBACK STATUS: %s",
- FLOW_STATUS, RETRY_STATUS_MESSAGE, ROLLBACK_STATUS_MESSAGE));
+ FLOW_STATUS + TASK_INFORMATION, RETRY_STATUS_MESSAGE, ROLLBACK_STATUS_MESSAGE));
Request expected = new Request();
expected.setRequestId(REQUEST_ID);
@@ -184,11 +200,78 @@ public class OrchestrationRequestsUnitTest {
expected.setRequestScope(SERVICE);
includeCloudRequest = false;
- iar.setExtSystemErrorSource(EXT_SYSTEM_ERROR_SOURCE);
- iar.setRollbackExtSystemErrorSource(ROLLBACK_EXT_SYSTEM_ERROR_SOURCE);
- iar.setFlowStatus(FLOW_STATUS);
- iar.setRollbackStatusMessage(ROLLBACK_STATUS_MESSAGE);
- iar.setRetryStatusMessage(RETRY_STATUS_MESSAGE);
+
+ Request actual = orchestrationRequests.mapInfraActiveRequestToRequest(iar, includeCloudRequest,
+ OrchestrationRequestFormat.DETAIL.toString());
+
+ assertThat(actual, sameBeanAs(expected));
+ }
+
+ @Test
+ public void mapRequestStatusAndExtSysErrSrcToRequestNoFlowStatusTest() throws ApiException {
+ InstanceReferences instanceReferences = new InstanceReferences();
+ instanceReferences.setServiceInstanceId(SERVICE_INSTANCE_ID);
+ RequestStatus requestStatus = new RequestStatus();
+ requestStatus.setRequestState(iar.getRequestStatus());
+ requestStatus.setStatusMessage(
+ String.format("RETRY STATUS: %s ROLLBACK STATUS: %s", RETRY_STATUS_MESSAGE, ROLLBACK_STATUS_MESSAGE));
+
+ Request expected = new Request();
+ expected.setRequestId(REQUEST_ID);
+ expected.setInstanceReferences(instanceReferences);
+ expected.setRequestStatus(requestStatus);
+ expected.setRequestScope(SERVICE);
+
+ includeCloudRequest = false;
+ iar.setFlowStatus(null);
+
+ Request actual = orchestrationRequests.mapInfraActiveRequestToRequest(iar, includeCloudRequest,
+ OrchestrationRequestFormat.DETAIL.toString());
+
+ assertThat(actual, sameBeanAs(expected));
+ }
+
+ @Test
+ public void mapRequestStatusAndExtSysErrSrcToRequestFlowStatusSuccessfulCompletionTest() throws ApiException {
+ InstanceReferences instanceReferences = new InstanceReferences();
+ instanceReferences.setServiceInstanceId(SERVICE_INSTANCE_ID);
+ RequestStatus requestStatus = new RequestStatus();
+ requestStatus.setRequestState(iar.getRequestStatus());
+ requestStatus.setStatusMessage(String.format("FLOW STATUS: %s RETRY STATUS: %s ROLLBACK STATUS: %s",
+ "Successfully completed all Building Blocks", RETRY_STATUS_MESSAGE, ROLLBACK_STATUS_MESSAGE));
+
+ Request expected = new Request();
+ expected.setRequestId(REQUEST_ID);
+ expected.setInstanceReferences(instanceReferences);
+ expected.setRequestStatus(requestStatus);
+ expected.setRequestScope(SERVICE);
+
+ includeCloudRequest = false;
+ iar.setFlowStatus("Successfully completed all Building Blocks");
+
+ Request actual = orchestrationRequests.mapInfraActiveRequestToRequest(iar, includeCloudRequest,
+ OrchestrationRequestFormat.DETAIL.toString());
+
+ assertThat(actual, sameBeanAs(expected));
+ }
+
+ @Test
+ public void mapRequestStatusAndExtSysErrSrcToRequestFlowStatusSuccessfulRollbackTest() throws ApiException {
+ InstanceReferences instanceReferences = new InstanceReferences();
+ instanceReferences.setServiceInstanceId(SERVICE_INSTANCE_ID);
+ RequestStatus requestStatus = new RequestStatus();
+ requestStatus.setRequestState(iar.getRequestStatus());
+ requestStatus.setStatusMessage(String.format("FLOW STATUS: %s RETRY STATUS: %s ROLLBACK STATUS: %s",
+ "All Rollback flows have completed successfully", RETRY_STATUS_MESSAGE, ROLLBACK_STATUS_MESSAGE));
+
+ Request expected = new Request();
+ expected.setRequestId(REQUEST_ID);
+ expected.setInstanceReferences(instanceReferences);
+ expected.setRequestStatus(requestStatus);
+ expected.setRequestScope(SERVICE);
+
+ includeCloudRequest = false;
+ iar.setFlowStatus("All Rollback flows have completed successfully");
Request actual = orchestrationRequests.mapInfraActiveRequestToRequest(iar, includeCloudRequest,
OrchestrationRequestFormat.DETAIL.toString());
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/RequestHandlerUtilsTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/RequestHandlerUtilsTest.java
index 62a6f44a63..5306888570 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/RequestHandlerUtilsTest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/RequestHandlerUtilsTest.java
@@ -76,6 +76,9 @@ public class RequestHandlerUtilsTest extends BaseTest {
@Autowired
private RequestHandlerUtils requestHandlerUtils;
+ @Autowired
+ private CamundaRequestHandler camundaRequestHandler;
+
@Value("${wiremock.server.port}")
private String wiremockPort;
@@ -327,7 +330,7 @@ public class RequestHandlerUtilsTest extends BaseTest {
public void setCamundaHeadersTest() throws ContactCamundaException, RequestDbFailureException {
String encryptedAuth = "015E7ACF706C6BBF85F2079378BDD2896E226E09D13DC2784BA309E27D59AB9FAD3A5E039DF0BB8408"; // user:password
String key = "07a7159d3bf51a0e53be7a8f89699be7";
- HttpHeaders headers = requestHandlerUtils.setCamundaHeaders(encryptedAuth, key);
+ HttpHeaders headers = camundaRequestHandler.setCamundaHeaders(encryptedAuth, key);
List<org.springframework.http.MediaType> acceptedType = headers.getAccept();
String expectedAcceptedType = "application/json";
assertEquals(expectedAcceptedType, acceptedType.get(0).toString());
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java
index b72e5124d1..4b2644bc00 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java
@@ -2917,19 +2917,6 @@ public class ServiceInstancesTest extends BaseTest {
}
@Test
- public void setCamundaHeadersTest() throws ContactCamundaException, RequestDbFailureException {
- String encryptedAuth = "015E7ACF706C6BBF85F2079378BDD2896E226E09D13DC2784BA309E27D59AB9FAD3A5E039DF0BB8408"; // user:password
- String key = "07a7159d3bf51a0e53be7a8f89699be7";
- HttpHeaders headers = requestHandlerUtils.setCamundaHeaders(encryptedAuth, key);
- List<org.springframework.http.MediaType> acceptedType = headers.getAccept();
- String expectedAcceptedType = "application/json";
- assertEquals(expectedAcceptedType, acceptedType.get(0).toString());
- String basicAuth = headers.getFirst(HttpHeaders.AUTHORIZATION);
- String expectedBasicAuth = "Basic dXNlcjpwYXNzd29yZA==";
- assertEquals(expectedBasicAuth, basicAuth);
- }
-
- @Test
public void handleReplaceInstance_Test() throws JsonParseException, JsonMappingException, IOException {
String replaceVfModule = inputStream("/ReplaceVfModule.json");
ObjectMapper mapper = new ObjectMapper();
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/OrchestrationRequest/ActivityInstanceHistoryResponse.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/OrchestrationRequest/ActivityInstanceHistoryResponse.json
new file mode 100644
index 0000000000..efd80f3347
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/OrchestrationRequest/ActivityInstanceHistoryResponse.json
@@ -0,0 +1,48 @@
+[
+ {
+ "id":"Call_BBToExecute:c4f603e4-a26e-11e9-b144-0242ac14000b",
+ "parentActivityInstanceId":"c4c6b647-a26e-11e9-b144-0242ac14000b",
+ "activityId":"Call_BBToExecute",
+ "activityName":"BB to Execute",
+ "activityType":"callActivity",
+ "processDefinitionKey":"ExecuteBuildingBlock",
+ "processDefinitionId":"ExecuteBuildingBlock:1:a46566de-a26b-11e9-b144-0242ac14000b",
+ "processInstanceId":"c4c6b647-a26e-11e9-b144-0242ac14000b",
+ "executionId":"c4f603e3-a26e-11e9-b144-0242ac14000b",
+ "taskId":null,
+ "calledProcessInstanceId":"c4f603e6-a26e-11e9-b144-0242ac14000b",
+ "calledCaseInstanceId":null,
+ "assignee":null,
+ "startTime":"2019-07-09T17:27:04.607+0000",
+ "endTime":"2019-07-09T17:27:05.545+0000",
+ "durationInMillis":938,
+ "canceled":true,
+ "completeScope":false,
+ "tenantId":null,
+ "removalTime":null,
+ "rootProcessInstanceId":"c2fd4066-a26e-11e9-b144-0242ac14000b"
+ },
+ {
+ "id":"EndEvent_0mvmk3i:c59b1d39-a26e-11e9-b144-0242ac14000b",
+ "parentActivityInstanceId":"SubProcess_0tv8zda:c5852427-a26e-11e9-b144-0242ac14000b",
+ "activityId":"EndEvent_0mvmk3i",
+ "activityName":null,
+ "activityType":"noneEndEvent",
+ "processDefinitionKey":"ExecuteBuildingBlock",
+ "processDefinitionId":"ExecuteBuildingBlock:1:a46566de-a26b-11e9-b144-0242ac14000b",
+ "processInstanceId":"c4c6b647-a26e-11e9-b144-0242ac14000b",
+ "executionId":"c5852426-a26e-11e9-b144-0242ac14000b",
+ "taskId":null,
+ "calledProcessInstanceId":null,
+ "calledCaseInstanceId":null,
+ "assignee":null,
+ "startTime":"2019-07-09T17:27:05.689+0000",
+ "endTime":"2019-07-09T17:27:05.689+0000",
+ "durationInMillis":0,
+ "canceled":false,
+ "completeScope":true,
+ "tenantId":null,
+ "removalTime":null,
+ "rootProcessInstanceId":"c2fd4066-a26e-11e9-b144-0242ac14000b"
+ }
+ ] \ No newline at end of file
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/OrchestrationRequest/OrchestrationFilterResponse.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/OrchestrationRequest/OrchestrationFilterResponse.json
index 3b2eca7ce2..96fed36d45 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/resources/OrchestrationRequest/OrchestrationFilterResponse.json
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/OrchestrationRequest/OrchestrationFilterResponse.json
@@ -61,7 +61,7 @@
},
"requestStatus": {
"requestState": "COMPLETE",
- "statusMessage": "STATUS: Vf Module has been deleted successfully. FLOW STATUS: Building blocks 1 of 3 completed. ROLLBACK STATUS: Rollback has been completed successfully.",
+ "statusMessage": "STATUS: Vf Module has been deleted successfully. FLOW STATUS: Building blocks 1 of 3 completed. TASK INFORMATION: Last task executed: BB to Execute ROLLBACK STATUS: Rollback has been completed successfully.",
"percentProgress": 100,
"timestamp": "Thu, 22 Dec 2016 08:30:28 GMT"
}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/OrchestrationRequest/OrchestrationList.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/OrchestrationRequest/OrchestrationList.json
index baddb21617..801841313a 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/resources/OrchestrationRequest/OrchestrationList.json
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/OrchestrationRequest/OrchestrationList.json
@@ -58,7 +58,7 @@
},
"requestStatus":{
"requestState":"PENDING",
- "statusMessage":"FLOW STATUS: Building blocks 1 of 3 completed. RETRY STATUS: Retry 2/5 will be started in 8 min. ROLLBACK STATUS: Rollback has been completed successfully.",
+ "statusMessage":"FLOW STATUS: Building blocks 1 of 3 completed. TASK INFORMATION: Last task executed: BB to Execute RETRY STATUS: Retry 2/5 will be started in 8 min. ROLLBACK STATUS: Rollback has been completed successfully.",
"percentProgress":0,
"timestamp": "Thu, 22 Dec 2016 08:30:28 GMT"
}
@@ -321,7 +321,7 @@
},
"requestStatus":{
"requestState":"PENDING",
- "statusMessage":"STATUS: Adding members. FLOW STATUS: Building blocks 1 of 3 completed. RETRY STATUS: Retry 2/5 will be started in 8 min. ROLLBACK STATUS: Rollback has been completed successfully.",
+ "statusMessage":"STATUS: Adding members. FLOW STATUS: Building blocks 1 of 3 completed. TASK INFORMATION: Last task executed: BB to Execute RETRY STATUS: Retry 2/5 will be started in 8 min. ROLLBACK STATUS: Rollback has been completed successfully.",
"percentProgress":0,
"timestamp": "Thu, 22 Dec 2016 08:30:28 GMT"
}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/OrchestrationRequest/ProcessInstanceHistoryResponse.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/OrchestrationRequest/ProcessInstanceHistoryResponse.json
new file mode 100644
index 0000000000..faa283463b
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/OrchestrationRequest/ProcessInstanceHistoryResponse.json
@@ -0,0 +1,44 @@
+[
+ {
+ "id":"c2fd4066-a26e-11e9-b144-0242ac14000b",
+ "businessKey":"84eacc7b-b046-4333-9272-5e8513bdd4cc",
+ "processDefinitionId":"WorkflowActionBB:1:a461210d-a26b-11e9-b144-0242ac14000b",
+ "processDefinitionKey":"WorkflowActionBB",
+ "processDefinitionName":"WorkflowActionBB",
+ "processDefinitionVersion":1,
+ "startTime":"2019-07-09T17:27:01.299+0000",
+ "endTime":"2019-07-09T17:27:06.585+0000",
+ "removalTime":null,
+ "durationInMillis":5286,
+ "startUserId":null,
+ "startActivityId":"Start_WorkflowActionBB",
+ "deleteReason":null,
+ "rootProcessInstanceId":"c2fd4066-a26e-11e9-b144-0242ac14000b",
+ "superProcessInstanceId":null,
+ "superCaseInstanceId":null,
+ "caseInstanceId":null,
+ "tenantId":null,
+ "state":"COMPLETED"
+ },
+ {
+ "id":"c4c6b647-a26e-11e9-b144-0242ac14000b",
+ "businessKey":null,
+ "processDefinitionId":"ExecuteBuildingBlock:1:a46566de-a26b-11e9-b144-0242ac14000b",
+ "processDefinitionKey":"ExecuteBuildingBlock",
+ "processDefinitionName":"ExecuteBuildingBlock",
+ "processDefinitionVersion":1,
+ "startTime":"2019-07-09T17:27:04.298+0000",
+ "endTime":"2019-07-09T17:27:05.690+0000",
+ "removalTime":null,
+ "durationInMillis":1392,
+ "startUserId":null,
+ "startActivityId":"Start_ExecuteBuildingBlock",
+ "deleteReason":null,
+ "rootProcessInstanceId":"c2fd4066-a26e-11e9-b144-0242ac14000b",
+ "superProcessInstanceId":"c2fd4066-a26e-11e9-b144-0242ac14000b",
+ "superCaseInstanceId":null,
+ "caseInstanceId":null,
+ "tenantId":null,
+ "state":"COMPLETED"
+ }
+ ] \ No newline at end of file