aboutsummaryrefslogtreecommitdiffstats
path: root/bpmn/so-bpmn-tasks
diff options
context:
space:
mode:
authorRob Daugherty <rd472p@att.com>2018-11-01 16:52:27 +0000
committerGerrit Code Review <gerrit@onap.org>2018-11-01 16:52:27 +0000
commitf6f78668938bcfb66bc4fd6a977a1641815db58e (patch)
tree2278d595fc1fc33832627c8139b64a2f33933b1e /bpmn/so-bpmn-tasks
parenta233b62a56517e06ce63b8d801bcdebd6df18af5 (diff)
parentd3759e15184562647ea83b92cf02140fc705cb0d (diff)
Merge "Update Logic" into casablanca
Diffstat (limited to 'bpmn/so-bpmn-tasks')
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java62
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java6
2 files changed, 38 insertions, 30 deletions
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java
index 8bc499c310..d8a6fc2e1d 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java
@@ -81,6 +81,7 @@ public class WorkflowAction {
private static final String WORKFLOW_ACTION_ERROR_MESSAGE = "WorkflowActionErrorMessage";
private static final String SERVICE_INSTANCES = "serviceInstances";
+ private static final String VF_MODULES = "vfModules";
private static final String WORKFLOW_ACTION_WAS_UNABLE_TO_VERIFY_IF_THE_INSTANCE_NAME_ALREADY_EXIST_IN_AAI = "WorkflowAction was unable to verify if the instance name already exist in AAI.";
private static final String G_ORCHESTRATION_FLOW = "gOrchestrationFlow";
private static final String G_ACTION = "requestAction";
@@ -665,35 +666,38 @@ public class WorkflowAction {
}
protected Resource extractResourceIdAndTypeFromUri(String uri) {
- Pattern patt = Pattern.compile(
- "[vV]\\d+.*?(?:(?:/(?<type>" + supportedTypes + ")(?:/(?<id>[^/]+))?)(?:/(?<action>[^/]+))?)?$");
- Matcher m = patt.matcher(uri);
- Boolean generated = false;
-
- if (m.find()) {
- logger.debug("found match on {} : {} " , uri , m);
- String type = m.group("type");
- String id = m.group("id");
- String action = m.group("action");
- if (type == null) {
- throw new IllegalArgumentException("Uri could not be parsed. No type found. " + uri);
- }
- if (action == null) {
- if (type.equals(SERVICE_INSTANCES) && (id == null || id.equals("assign"))) {
- id = UUID.randomUUID().toString();
- generated = true;
- }
- } else {
- if (action.matches(supportedTypes)) {
- id = UUID.randomUUID().toString();
- generated = true;
- type = action;
- }
- }
- return new Resource(WorkflowType.fromString(convertTypeFromPlural(type)), id, generated);
- } else {
- throw new IllegalArgumentException("Uri could not be parsed: " + uri);
- }
+ Pattern patt = Pattern.compile(
+ "[vV]\\d+.*?(?:(?:/(?<type>" + supportedTypes + ")(?:/(?<id>[^/]+))?)(?:/(?<action>[^/]+))?)?$");
+ Matcher m = patt.matcher(uri);
+ Boolean generated = false;
+
+ if (m.find()) {
+ logger.debug("found match on {} : {} " , uri , m);
+ String type = m.group("type");
+ String id = m.group("id");
+ String action = m.group("action");
+ if (type == null) {
+ throw new IllegalArgumentException("Uri could not be parsed. No type found. " + uri);
+ }
+ if (action == null) {
+ if (type.equals(SERVICE_INSTANCES) && (id == null || id.equals("assign"))) {
+ id = UUID.randomUUID().toString();
+ generated = true;
+ }else if (type.equals(VF_MODULES) && id.equals("scaleOut")) {
+ id = UUID.randomUUID().toString();
+ generated = true;
+ }
+ } else {
+ if (action.matches(supportedTypes)) {
+ id = UUID.randomUUID().toString();
+ generated = true;
+ type = action;
+ }
+ }
+ return new Resource(WorkflowType.fromString(convertTypeFromPlural(type)), id, generated);
+ } else {
+ throw new IllegalArgumentException("Uri could not be parsed: " + uri);
+ }
}
protected String validateResourceIdInAAI(String generatedResourceId, WorkflowType type, String instanceName,
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java
index 65d16adb40..c27b5dd655 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java
@@ -1318,7 +1318,7 @@ public class WorkflowActionTest extends BaseTaskTest {
String uri5 = "'/v6/serviceInstances/123/vnfs";
String uri6 = "/v6/serviceInstances/123/vnfs/1234/someAction";
String uri7 = "/v6/serviceInstances/123/vnfs/1234/vfModules/5678/replace";
-
+ String uri8 = "/v6/serviceInstances/123/vnfs/1234/vfModules/scaleOut";
Resource expected1 = new Resource(WorkflowType.SERVICE, "123", true);
Resource expected2 = new Resource(WorkflowType.VNF, "1234", false);
Resource expected3 = new Resource(WorkflowType.VNF, "1234", false);
@@ -1344,6 +1344,10 @@ public class WorkflowActionTest extends BaseTaskTest {
result = workflowAction.extractResourceIdAndTypeFromUri(uri7);
assertEquals(expected4.getResourceId(),result.getResourceId());
assertEquals(expected4.getResourceType(),result.getResourceType());
+ result = workflowAction.extractResourceIdAndTypeFromUri(uri8);
+ assertEquals(UUID.randomUUID().toString().length(),result.getResourceId().length());
+ assertEquals("VfModule", result.getResourceType().toString());
+
}
@Test