summaryrefslogtreecommitdiffstats
path: root/appc-config/appc-flow-controller/provider/src/main/java
diff options
context:
space:
mode:
authorkurczews <krzysztof.kurczewski@nokia.com>2018-03-02 14:44:03 +0100
committerTakamune Cho <tc012c@att.com>2018-03-13 15:19:18 +0000
commit04dee786c77757d8e9b86e9228cba46d717ecd40 (patch)
tree5b258071e5f7ed45a6a113278fceb7af89cc47ab /appc-config/appc-flow-controller/provider/src/main/java
parentd206edd8b89ddd251b24e635227fae2814b0152e (diff)
Improve coverage FlowControlNode #8
* refactor & test dependency info method * extract get flow sequence method Change-Id: I6c9ab49676b6c325196ec179e863038550b5dad6 Issue-ID: APPC-440 Signed-off-by: kurczews <krzysztof.kurczewski@nokia.com>
Diffstat (limited to 'appc-config/appc-flow-controller/provider/src/main/java')
-rw-r--r--appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/node/FlowControlNode.java52
1 files changed, 29 insertions, 23 deletions
diff --git a/appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/node/FlowControlNode.java b/appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/node/FlowControlNode.java
index 16e869040..28130e777 100644
--- a/appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/node/FlowControlNode.java
+++ b/appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/node/FlowControlNode.java
@@ -66,7 +66,6 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import java.io.IOException;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -150,11 +149,21 @@ public class FlowControlNode implements SvcLogicJavaPlugin {
String fn = "FlowExecutorNode.processflowSequence";
log.debug(fn + "Received model for flow : " + localContext.toString());
-
+
+ localContext
+ .getAttributeKeySet()
+ .forEach(key -> log.debug(key + "=" + ctx.getAttribute(key)));
+
+ String flowSequence = getFlowSequence(inParams, ctx, localContext);
+
+ log.debug("Received Flow Sequence : " + flowSequence);
+ HashMap<Integer, Transaction> transactionMap = createTransactionMap(flowSequence, localContext);
+ executeAllTransaction(transactionMap, ctx);
+ log.info("Executed all the transaction successfully");
+ }
+
+ String getFlowSequence(Map<String, String> inParams, SvcLogicContext ctx, SvcLogicContext localContext) throws Exception {
String flowSequence = null;
- for (String key : localContext.getAttributeKeySet()) {
- log.debug(key + "=" + ctx.getAttribute(key));
- }
if (localContext.getAttribute(SEQUENCE_TYPE) != null) {
if (localContext.getAttribute(GENERATION_NODE) != null) {
GraphExecutor transactionExecutor = new GraphExecutor();
@@ -225,11 +234,7 @@ public class FlowControlNode implements SvcLogicJavaPlugin {
flowSequence = mapper.writeValueAsString(trans);
log.debug("Single step Flow Sequence : " + flowSequence);
}
-
- log.debug("Received Flow Sequence : " + flowSequence);
- HashMap<Integer, Transaction> transactionMap = createTransactionMap(flowSequence, localContext);
- executeAllTransaction(transactionMap, ctx);
- log.info("Executed all the transaction successfully");
+ return flowSequence;
}
private void executeAllTransaction(HashMap<Integer, Transaction> transactionMap, SvcLogicContext ctx)
@@ -448,28 +453,29 @@ public class FlowControlNode implements SvcLogicJavaPlugin {
return inputData;
}
- private DependencyInfo getDependencyInfo(SvcLogicContext ctx) throws Exception {
+ DependencyInfo getDependencyInfo(SvcLogicContext ctx) throws SvcLogicException, IOException {
String fn = "FlowExecutorNode.getDependencyInfo";
- DependencyInfo dependencyInfo = new DependencyInfo();
String dependencyData = dbService.getDependencyInfo(ctx);
log.info(fn + "dependencyDataInput:" + dependencyData);
- if (dependencyData != null) {
- ObjectMapper mapper = new ObjectMapper();
- mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
- mapper.enable(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
- //JsonNode dependencyInfoData = mapper.readTree(dependencyData).get("dependencyInfo");
- JsonNode vnfcData = mapper.readTree(dependencyData).get("vnfcs");
- List<Vnfcs> vnfclist = Arrays.asList(mapper.readValue(vnfcData.toString(), Vnfcs[].class));
- dependencyInfo.getVnfcs().addAll(vnfclist);
-
- log.info("Dependency Output:" + dependencyInfo.toString());
+ DependencyInfo dependencyInfo = new DependencyInfo();
+ if (dependencyData == null) {
+ return dependencyInfo;
}
+
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+ mapper.enable(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
+ //JsonNode dependencyInfoData = mapper.readTree(dependencyData).get("dependencyInfo");
+ JsonNode vnfcData = mapper.readTree(dependencyData).get("vnfcs");
+ dependencyInfo.getVnfcs().addAll(mapper.readValue(vnfcData.toString(), new TypeReference<List<Vnfcs>>(){}));
+
+ log.info("Dependency Output:" + dependencyInfo.toString());
return dependencyInfo;
}
- Capabilities getCapabilitiesData(SvcLogicContext ctx) throws Exception {
+ Capabilities getCapabilitiesData(SvcLogicContext ctx) throws SvcLogicException, IOException {
String fn = "FlowExecutorNode.getCapabilitiesData";
String capabilitiesData = dbService.getCapabilitiesData(ctx);