aboutsummaryrefslogtreecommitdiffstats
path: root/appc-config/appc-flow-controller/provider/src
diff options
context:
space:
mode:
Diffstat (limited to 'appc-config/appc-flow-controller/provider/src')
-rw-r--r--appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/node/CapabilitiesDataExtractor.java95
-rw-r--r--appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/node/EnvVariables.java30
-rw-r--r--appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/node/FlowControlNode.java225
-rw-r--r--appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/node/FlowSequenceGenerator.java149
-rw-r--r--appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/node/InputParamsCollector.java193
-rw-r--r--appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/node/JsonValidator.java19
-rw-r--r--appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/node/PropertiesLoader.java19
-rw-r--r--appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/node/ResourceUriExtractor.java19
-rw-r--r--appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/node/TransactionHandler.java19
-rw-r--r--appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/controller/node/CapabilitiesDataExtractorTest.java68
-rw-r--r--appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/controller/node/FlowControlNodeTest.java54
-rw-r--r--appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/controller/node/FlowGeneratorTest.java19
-rw-r--r--appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/controller/node/FlowSequenceGeneratorTest.java208
-rw-r--r--appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/controller/node/InputParamsCollectorTest.java130
-rw-r--r--appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/controller/node/JsonValidatorTest.java19
-rw-r--r--appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/controller/node/PropertiesLoaderTest.java19
-rw-r--r--appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/controller/node/ResourceUriExtractorTest.java19
-rw-r--r--appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/controller/node/TestRestServiceNode.java5
-rw-r--r--appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/controller/node/TransactionHandlerTest.java14
-rw-r--r--appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/executor/node/FlowControlNodeTest.java149
-rw-r--r--appc-config/appc-flow-controller/provider/src/test/resources/appc-flow-controller.properties3
21 files changed, 1039 insertions, 436 deletions
diff --git a/appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/node/CapabilitiesDataExtractor.java b/appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/node/CapabilitiesDataExtractor.java
new file mode 100644
index 000000000..b740e4feb
--- /dev/null
+++ b/appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/node/CapabilitiesDataExtractor.java
@@ -0,0 +1,95 @@
+/*
+ * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2018 Nokia. 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.appc.flow.controller.node;
+
+import static org.onap.appc.flow.controller.utils.FlowControllerConstants.VF_MODULE;
+import static org.onap.appc.flow.controller.utils.FlowControllerConstants.VM;
+import static org.onap.appc.flow.controller.utils.FlowControllerConstants.VNF;
+import static org.onap.appc.flow.controller.utils.FlowControllerConstants.VNFC;
+
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+import com.fasterxml.jackson.core.type.TypeReference;
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import org.onap.appc.flow.controller.dbervices.FlowControlDBService;
+import org.onap.appc.flow.controller.interfaceData.Capabilities;
+import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
+import org.onap.ccsdk.sli.core.sli.SvcLogicException;
+
+public class CapabilitiesDataExtractor {
+
+ private static final EELFLogger log = EELFManager.getInstance().getLogger(CapabilitiesDataExtractor.class);
+
+ private final FlowControlDBService dbService;
+ private final ObjectMapper mapper;
+
+ public CapabilitiesDataExtractor() {
+ this(FlowControlDBService.initialise());
+ }
+
+ /**
+ * Ctor for tests, prefer to use default one
+ */
+ public CapabilitiesDataExtractor(FlowControlDBService dbService) {
+ this.dbService = dbService;
+
+ mapper = new ObjectMapper();
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+ mapper.enable(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
+ }
+
+ Capabilities getCapabilitiesData(SvcLogicContext ctx) throws SvcLogicException, IOException {
+
+ String fn = "FlowExecutorNode.getCapabilitiesData";
+ String capabilitiesData = dbService.getCapabilitiesData(ctx);
+ log.info(fn + "capabilitiesDataInput:" + capabilitiesData);
+
+ Capabilities capabilities = new Capabilities();
+ if (capabilitiesData == null) {
+ return capabilities;
+ }
+
+ JsonNode capabilitiesNode = mapper.readTree(capabilitiesData);
+ log.info("capabilitiesNode:" + capabilitiesNode.toString());
+
+ capabilities.getVfModule().addAll(extractParameterList(capabilitiesNode, VF_MODULE));
+ capabilities.getVnfc().addAll(extractParameterList(capabilitiesNode, VNFC));
+ capabilities.getVnf().addAll(extractParameterList(capabilitiesNode, VNF));
+ capabilities.getVm().addAll(extractParameterList(capabilitiesNode, VM));
+
+ log.info("Capabilities Output:" + capabilities.toString());
+
+ return capabilities;
+ }
+
+ private <T> List<T> extractParameterList(JsonNode root, String parameter) throws IOException {
+ JsonNode parameterNode = root.get(parameter);
+ if (parameterNode == null) {
+ return new ArrayList<>();
+ }
+ return mapper.readValue(parameterNode.toString(), new TypeReference<List<T>>() {});
+ }
+
+} \ No newline at end of file
diff --git a/appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/node/EnvVariables.java b/appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/node/EnvVariables.java
index 6cc3b7550..bac1f6cb0 100644
--- a/appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/node/EnvVariables.java
+++ b/appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/node/EnvVariables.java
@@ -1,9 +1,30 @@
+/*
+ * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2018 Nokia. 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.appc.flow.controller.node;
import java.util.function.Function;
/**
- * Wrapper for accessing environment variables
+ * Wrapper which allows to mock static calls of System.getenv()
+ *
+ * @see System#getenv()
*/
class EnvVariables {
@@ -13,13 +34,6 @@ class EnvVariables {
envSupplier = System::getenv;
}
- /**
- * Allows to override environment variables in tests, prefer to use default constructor
- */
- EnvVariables(Function<String, String> envSupplier) {
- this.envSupplier = envSupplier;
- }
-
String getenv(String variable) {
return envSupplier.apply(variable);
}
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 28130e777..fd883601f 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
@@ -97,19 +97,18 @@ import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin;
public class FlowControlNode implements SvcLogicJavaPlugin {
private static final EELFLogger log = EELFManager.getInstance().getLogger(FlowControlNode.class);
- private static final String SDNC_CONFIG_DIR_VAR = "SDNC_CONFIG_DIR";
- private final EnvVariables envVariables;
private final FlowControlDBService dbService;
+ private final FlowSequenceGenerator flowSequenceGenerator;
public FlowControlNode() {
- this.envVariables = new EnvVariables();
this.dbService = FlowControlDBService.initialise();
+ this.flowSequenceGenerator = new FlowSequenceGenerator();
}
- FlowControlNode(EnvVariables envVariables, FlowControlDBService dbService) {
- this.envVariables = envVariables;
+ FlowControlNode(FlowControlDBService dbService, FlowSequenceGenerator flowSequenceGenerator) {
this.dbService = dbService;
+ this.flowSequenceGenerator = flowSequenceGenerator;
}
public void processFlow(Map<String, String> inParams, SvcLogicContext ctx)
@@ -154,7 +153,7 @@ public class FlowControlNode implements SvcLogicJavaPlugin {
.getAttributeKeySet()
.forEach(key -> log.debug(key + "=" + ctx.getAttribute(key)));
- String flowSequence = getFlowSequence(inParams, ctx, localContext);
+ String flowSequence = flowSequenceGenerator.getFlowSequence(inParams, ctx, localContext);
log.debug("Received Flow Sequence : " + flowSequence);
HashMap<Integer, Transaction> transactionMap = createTransactionMap(flowSequence, localContext);
@@ -162,81 +161,6 @@ public class FlowControlNode implements SvcLogicJavaPlugin {
log.info("Executed all the transaction successfully");
}
- String getFlowSequence(Map<String, String> inParams, SvcLogicContext ctx, SvcLogicContext localContext) throws Exception {
- String flowSequence = null;
- if (localContext.getAttribute(SEQUENCE_TYPE) != null) {
- if (localContext.getAttribute(GENERATION_NODE) != null) {
- GraphExecutor transactionExecutor = new GraphExecutor();
- Boolean generatorExists = transactionExecutor.hasGraph(
- "APPC_COMMOM",
- localContext.getAttribute(GENERATION_NODE),
- null,
- "sync"
- );
-
- if (generatorExists) {
- flowSequence = transactionExecutor.executeGraph(
- "APPC_COMMOM",
- localContext.getAttribute(GENERATION_NODE),
- null, "sync", null)
- .getProperty(FLOW_SEQUENCE);
- } else {
- throw new Exception("Can not find Custom defined Flow Generator for "
- + localContext.getAttribute(GENERATION_NODE));
- }
-
- } else if ((localContext.getAttribute(SEQUENCE_TYPE)).equalsIgnoreCase(DESINGTIME)) {
-
- localContext.setAttribute(VNFC_TYPE, ctx.getAttribute(VNFC_TYPE));
- flowSequence = dbService.getDesignTimeFlowModel(localContext);
-
- if (flowSequence == null) {
- throw new Exception("Flow Sequence is not found User Designed VNF " + ctx.getAttribute(VNF_TYPE));
- }
-
- } else if ((localContext.getAttribute(SEQUENCE_TYPE)).equalsIgnoreCase(RUNTIME)) {
-
- Transaction transaction = new Transaction();
- String input = collectInputParams(ctx, transaction);
- log.info("CollectInputParamsData-Input: " + input);
-
- RestExecutor restExe = new RestExecutor();
- Map<String, String> flowSeq = restExe.execute(transaction, localContext);
-
- JSONObject sequence = new JSONObject(flowSeq.get("restResponse"));
- if (sequence.has("output")) {
- flowSequence = sequence.getJSONObject("output").toString();
- }
- log.info("MultistepSequenceGenerator-Output: " + flowSequence);
-
- if (flowSequence == null) {
- throw new Exception("Failed to get the Flow Sequece runtime for VNF type"
- + ctx.getAttribute(VNF_TYPE));
- }
-
- } else if ((localContext.getAttribute(SEQUENCE_TYPE)).equalsIgnoreCase(EXTERNAL)) {
- //String input = collectInputParams(localContext);
- // flowSequnce = ""; //get it from the External interface calling the Rest End point - TBD
- //if(flowSequnce == null)
-
- throw new Exception("Flow Sequence not found for " + ctx.getAttribute(VNF_TYPE));
-
- } else {
- //No other type of model supported...
- //in Future can get flowModel from other generators which will be included here
- throw new Exception("No information found for sequence Owner Design-Time Vs Run-Time");
- }
-
- } else {
- FlowGenerator flowGenerator = new FlowGenerator();
- Transactions trans = flowGenerator.createSingleStepModel(inParams, ctx);
- ObjectMapper mapper = new ObjectMapper();
- flowSequence = mapper.writeValueAsString(trans);
- log.debug("Single step Flow Sequence : " + flowSequence);
- }
- return flowSequence;
- }
-
private void executeAllTransaction(HashMap<Integer, Transaction> transactionMap, SvcLogicContext ctx)
throws Exception {
@@ -380,143 +304,4 @@ public class FlowControlNode implements SvcLogicJavaPlugin {
//get a field in transction class as transactionhandle interface and register the Handler here for each trnactions
}
- private String collectInputParams(SvcLogicContext ctx, Transaction transaction) throws Exception {
-
- String fn = "FlowExecuteNode.collectInputParams";
- Properties prop = loadProperties();
- log.info("Loaded Properties " + prop.toString());
-
- String vnfId = ctx.getAttribute(VNF_ID);
- String inputData = null;
- log.debug(fn + "vnfId :" + vnfId);
-
- if (StringUtils.isBlank(vnfId)) {
- throw new Exception("VnfId is missing");
- }
-
- try {
- ActionIdentifier actionIdentifier = new ActionIdentifier();
- log.debug("Enter ActionIdentifier");
- if (StringUtils.isNotBlank(vnfId)) {
- actionIdentifier.setVnfId(vnfId);
- }
- if (StringUtils.isNotBlank(ctx.getAttribute(VSERVER_ID))) {
- actionIdentifier.setVserverId(ctx.getAttribute(VSERVER_ID));
- }
- if (StringUtils.isNotBlank(ctx.getAttribute(VNFC_NAME))) {
- actionIdentifier.setVnfcName(ctx.getAttribute(VNFC_NAME));
- }
- log.info("ActionIdentifierData" + actionIdentifier.toString());
-
- RequestInfo requestInfo = new RequestInfo();
- log.info("Enter RequestInfo");
- requestInfo.setAction(ctx.getAttribute(REQUEST_ACTION));
- requestInfo.setActionLevel(ctx.getAttribute(ACTION_LEVEL));
- requestInfo.setPayload(ctx.getAttribute(PAYLOAD));
- requestInfo.setActionIdentifier(actionIdentifier);
- log.debug("RequestInfo: " + requestInfo.toString());
-
- InventoryInfo inventoryInfo = new InventoryInfoExtractor().getInventoryInfo(ctx, vnfId);
- DependencyInfo dependencyInfo = getDependencyInfo(ctx);
- Capabilities capabilities = getCapabilitiesData(ctx);
-
- Input input = new Input();
- log.info("Enter InputData");
- input.setRequestInfo(requestInfo);
- input.setInventoryInfo(inventoryInfo);
- input.setDependencyInfo(dependencyInfo);
- input.setCapabilities(capabilities);
- log.info(fn + "Input parameters:" + input.toString());
-
- ObjectMapper mapper = new ObjectMapper();
- mapper.setSerializationInclusion(Include.NON_NULL);
- mapper.configure(SerializationFeature.WRAP_ROOT_VALUE, true);
- inputData = mapper.writeValueAsString(input);
- log.info("InputDataJson:" + inputData);
-
- } catch (Exception e) {
- log.error("Error occurred in " + fn, e);
- }
-
- String resourceUri = prop.getProperty(SEQ_GENERATOR_URL);
- log.info(fn + "resourceUri= " + resourceUri);
-
- EncryptionTool et = EncryptionTool.getInstance();
- String pass = et.decrypt(prop.getProperty(SEQ_GENERATOR_PWD));
-
- transaction.setPayload(inputData);
- transaction.setExecutionRPC("POST");
- transaction.setuId(prop.getProperty(SEQ_GENERATOR_UID));
- transaction.setPswd(pass);
- transaction.setExecutionEndPoint(resourceUri);
-
- return inputData;
- }
-
- DependencyInfo getDependencyInfo(SvcLogicContext ctx) throws SvcLogicException, IOException {
-
- String fn = "FlowExecutorNode.getDependencyInfo";
- String dependencyData = dbService.getDependencyInfo(ctx);
- log.info(fn + "dependencyDataInput:" + dependencyData);
-
- 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 SvcLogicException, IOException {
-
- String fn = "FlowExecutorNode.getCapabilitiesData";
- String capabilitiesData = dbService.getCapabilitiesData(ctx);
- log.info(fn + "capabilitiesDataInput:" + capabilitiesData);
-
- Capabilities capabilities = new Capabilities();
- if (capabilitiesData == null) {
- return capabilities;
- }
-
- ObjectMapper mapper = new ObjectMapper();
- mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
- mapper.enable(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
-
- JsonNode capabilitiesNode = mapper.readTree(capabilitiesData);
- log.info("capabilitiesNode:" + capabilitiesNode.toString());
-
- capabilities.getVfModule().addAll(extractParameterList(mapper, capabilitiesNode, VF_MODULE));
- capabilities.getVnfc().addAll(extractParameterList(mapper, capabilitiesNode, VNFC));
- capabilities.getVnf().addAll(extractParameterList(mapper, capabilitiesNode, VNF));
- capabilities.getVm().addAll(extractParameterList(mapper, capabilitiesNode, VM));
-
- log.info("Capabilities Output:" + capabilities.toString());
-
- return capabilities;
- }
-
- private <T> List<T> extractParameterList(ObjectMapper mapper, JsonNode root, String parameter) throws IOException {
- JsonNode parameterNode = root.get(parameter);
- if (parameterNode == null) {
- return new ArrayList<>();
- }
- return mapper.readValue(parameterNode.toString(), new TypeReference<List<T>>() {});
- }
-
- private Properties loadProperties() throws Exception {
- String directory = envVariables.getenv(SDNC_CONFIG_DIR_VAR);
- if (directory == null) {
- throw new Exception("Cannot find Property file -" + SDNC_CONFIG_DIR_VAR);
- }
- String path = directory + APPC_FLOW_CONTROLLER;
- return PropertiesLoader.load(path);
- }
}
diff --git a/appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/node/FlowSequenceGenerator.java b/appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/node/FlowSequenceGenerator.java
new file mode 100644
index 000000000..db5791305
--- /dev/null
+++ b/appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/node/FlowSequenceGenerator.java
@@ -0,0 +1,149 @@
+/*
+ * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2018 Nokia. 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.appc.flow.controller.node;
+
+import static org.onap.appc.flow.controller.utils.FlowControllerConstants.DESINGTIME;
+import static org.onap.appc.flow.controller.utils.FlowControllerConstants.EXTERNAL;
+import static org.onap.appc.flow.controller.utils.FlowControllerConstants.FLOW_SEQUENCE;
+import static org.onap.appc.flow.controller.utils.FlowControllerConstants.GENERATION_NODE;
+import static org.onap.appc.flow.controller.utils.FlowControllerConstants.RUNTIME;
+import static org.onap.appc.flow.controller.utils.FlowControllerConstants.SEQUENCE_TYPE;
+import static org.onap.appc.flow.controller.utils.FlowControllerConstants.VNFC_TYPE;
+import static org.onap.appc.flow.controller.utils.FlowControllerConstants.VNF_TYPE;
+
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import java.util.Map;
+import org.json.JSONObject;
+import org.onap.appc.flow.controller.data.Transaction;
+import org.onap.appc.flow.controller.data.Transactions;
+import org.onap.appc.flow.controller.dbervices.FlowControlDBService;
+import org.onap.appc.flow.controller.executorImpl.GraphExecutor;
+import org.onap.appc.flow.controller.executorImpl.RestExecutor;
+import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
+
+/**
+ * Helper class for FlowControlNode
+ */
+class FlowSequenceGenerator {
+
+ private static final EELFLogger log = EELFManager.getInstance().getLogger(FlowSequenceGenerator.class);
+
+ static final String MODULE = "APPC_COMMOM";
+
+ private final FlowControlDBService dbService;
+ private final FlowGenerator flowGenerator;
+ private final GraphExecutor transactionExecutor;
+ private final RestExecutor restExecutor;
+ private final InputParamsCollector inputParamsCollector;
+
+ FlowSequenceGenerator() {
+ this.dbService = FlowControlDBService.initialise();
+ this.flowGenerator = new FlowGenerator();
+ this.transactionExecutor = new GraphExecutor();
+ this.restExecutor = new RestExecutor();
+ this.inputParamsCollector = new InputParamsCollector();
+ }
+
+ /**
+ * Constructor for tests, prefer to use default one
+ */
+ FlowSequenceGenerator(FlowControlDBService dbService, FlowGenerator flowGenerator,
+ GraphExecutor graphExecutor, RestExecutor restExecutor, EnvVariables envVariables) {
+ this.dbService = dbService;
+ this.flowGenerator = flowGenerator;
+ this.transactionExecutor = graphExecutor;
+ this.restExecutor = restExecutor;
+ this.inputParamsCollector = new InputParamsCollector(envVariables, dbService);
+ }
+
+ String getFlowSequence(Map<String, String> inParams, SvcLogicContext ctx, SvcLogicContext localContext)
+ throws Exception {
+
+ String flowSequence;
+ if (localContext.getAttribute(SEQUENCE_TYPE) == null) {
+ Transactions trans = flowGenerator.createSingleStepModel(inParams, ctx);
+ ObjectMapper mapper = new ObjectMapper();
+ flowSequence = mapper.writeValueAsString(trans);
+ log.debug("Single step Flow Sequence : " + flowSequence);
+
+ return flowSequence;
+ }
+
+ if (localContext.getAttribute(GENERATION_NODE) != null) {
+ flowSequence = generationNode(localContext.getAttribute(GENERATION_NODE));
+ } else {
+ flowSequence = getFlowSequenceFromType(ctx, localContext, localContext.getAttribute(SEQUENCE_TYPE));
+ }
+ return flowSequence;
+ }
+
+ private String generationNode(String generationNode) throws Exception {
+ if (!transactionExecutor.hasGraph(MODULE, generationNode, null, "sync")) {
+ throw new Exception("Can not find Custom defined Flow Generator for " + generationNode);
+ }
+ return transactionExecutor
+ .executeGraph(MODULE, generationNode, null, "sync", null)
+ .getProperty(FLOW_SEQUENCE);
+ }
+
+ private String getFlowSequenceFromType(SvcLogicContext ctx, SvcLogicContext localContext,
+ String sequenceType) throws Exception {
+ String flowSequence;
+ String vnfType = ctx.getAttribute(VNF_TYPE);
+ if (sequenceType.equalsIgnoreCase(DESINGTIME)) {
+
+ localContext.setAttribute(VNFC_TYPE, ctx.getAttribute(VNFC_TYPE));
+ flowSequence = dbService.getDesignTimeFlowModel(localContext);
+
+ if (flowSequence == null) {
+ throw new Exception("Flow Sequence is not found User Designed VNF " + vnfType);
+ }
+ } else if (sequenceType.equalsIgnoreCase(RUNTIME)) {
+
+ Transaction transaction = inputParamsCollector.collectInputParams(ctx);
+ log.info("CollectInputParamsData-Input: " + transaction.getPayload());
+
+ Map<String, String> flowSeq = restExecutor.execute(transaction, localContext);
+
+ JSONObject output = new JSONObject(flowSeq.get("restResponse")).optJSONObject("output");
+ if (output == null) {
+ throw new Exception("Failed to get the Flow Sequence runtime for VNF type " + vnfType);
+ }
+ flowSequence = output.toString();
+ log.info("MultistepSequenceGenerator-Output: " + flowSequence);
+
+ } else if (sequenceType.equalsIgnoreCase(EXTERNAL)) {
+ //String input = collectInputParams(localContext);
+ // flowSequnce = ""; //get it from the External interface calling the Rest End point - TBD
+ //if(flowSequnce == null)
+
+ throw new Exception("Flow Sequence not found for " + vnfType);
+
+ } else {
+ //No other type of model supported...
+ //in Future can get flowModel from other generators which will be included here
+ throw new Exception("No information found for sequence Owner Design-Time Vs Run-Time");
+ }
+ return flowSequence;
+ }
+
+}
diff --git a/appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/node/InputParamsCollector.java b/appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/node/InputParamsCollector.java
new file mode 100644
index 000000000..1a7e2bc00
--- /dev/null
+++ b/appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/node/InputParamsCollector.java
@@ -0,0 +1,193 @@
+/*
+ * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2018 Nokia. 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.appc.flow.controller.node;
+
+import static org.onap.appc.flow.controller.utils.FlowControllerConstants.ACTION_LEVEL;
+import static org.onap.appc.flow.controller.utils.FlowControllerConstants.APPC_FLOW_CONTROLLER;
+import static org.onap.appc.flow.controller.utils.FlowControllerConstants.PAYLOAD;
+import static org.onap.appc.flow.controller.utils.FlowControllerConstants.REQUEST_ACTION;
+import static org.onap.appc.flow.controller.utils.FlowControllerConstants.SEQ_GENERATOR_PWD;
+import static org.onap.appc.flow.controller.utils.FlowControllerConstants.SEQ_GENERATOR_UID;
+import static org.onap.appc.flow.controller.utils.FlowControllerConstants.SEQ_GENERATOR_URL;
+import static org.onap.appc.flow.controller.utils.FlowControllerConstants.VNFC_NAME;
+import static org.onap.appc.flow.controller.utils.FlowControllerConstants.VNF_ID;
+import static org.onap.appc.flow.controller.utils.FlowControllerConstants.VSERVER_ID;
+
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+import com.fasterxml.jackson.annotation.JsonInclude.Include;
+import com.fasterxml.jackson.core.type.TypeReference;
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.SerializationFeature;
+import java.io.IOException;
+import java.util.List;
+import java.util.Properties;
+import java.util.function.Consumer;
+import org.apache.commons.lang3.StringUtils;
+import org.onap.appc.flow.controller.data.Transaction;
+import org.onap.appc.flow.controller.dbervices.FlowControlDBService;
+import org.onap.appc.flow.controller.interfaceData.ActionIdentifier;
+import org.onap.appc.flow.controller.interfaceData.Capabilities;
+import org.onap.appc.flow.controller.interfaceData.DependencyInfo;
+import org.onap.appc.flow.controller.interfaceData.Input;
+import org.onap.appc.flow.controller.interfaceData.InventoryInfo;
+import org.onap.appc.flow.controller.interfaceData.RequestInfo;
+import org.onap.appc.flow.controller.interfaceData.Vnfcs;
+import org.onap.appc.flow.controller.utils.EncryptionTool;
+import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
+import org.onap.ccsdk.sli.core.sli.SvcLogicException;
+
+class InputParamsCollector {
+
+ private static final EELFLogger log = EELFManager.getInstance().getLogger(InputParamsCollector.class);
+
+ private final EnvVariables envVariables;
+ private final FlowControlDBService dbService;
+
+ static final String SDNC_CONFIG_DIR_VAR = "SDNC_CONFIG_DIR";
+
+ InputParamsCollector() {
+ this.envVariables = new EnvVariables();
+ this.dbService = FlowControlDBService.initialise();
+ }
+
+ InputParamsCollector(EnvVariables envVariables, FlowControlDBService dbService) {
+ this.envVariables = envVariables;
+ this.dbService = dbService;
+ }
+
+ Transaction collectInputParams(SvcLogicContext ctx) throws Exception {
+
+ String fn = "FlowExecuteNode.collectInputParams";
+ Properties prop = loadProperties();
+ log.info("Loaded Properties " + prop.toString());
+
+ String vnfId = ctx.getAttribute(VNF_ID);
+ log.debug(fn + "vnfId :" + vnfId);
+
+ if (StringUtils.isBlank(vnfId)) {
+ throw new Exception("VnfId is missing");
+ }
+
+ String resourceUri = prop.getProperty(SEQ_GENERATOR_URL);
+ log.info(fn + "resourceUri= " + resourceUri);
+
+ String pass = EncryptionTool.getInstance().decrypt(prop.getProperty(SEQ_GENERATOR_PWD));
+
+ Transaction transaction = new Transaction();
+ transaction.setPayload(getInputData(ctx, fn, vnfId));
+ transaction.setExecutionRPC("POST");
+ transaction.setuId(prop.getProperty(SEQ_GENERATOR_UID));
+ transaction.setPswd(pass);
+ transaction.setExecutionEndPoint(resourceUri);
+
+ return transaction;
+ }
+
+ private String getInputData(SvcLogicContext ctx, String fn, String vnfId) throws IOException, SvcLogicException {
+ ActionIdentifier actionIdentifier = new ActionIdentifier();
+ log.debug("Enter ActionIdentifier");
+
+ applyIfNotBlank(vnfId, actionIdentifier::setVnfId);
+ applyIfNotBlank(ctx.getAttribute(VSERVER_ID), actionIdentifier::setVserverId);
+ applyIfNotBlank(ctx.getAttribute(VNFC_NAME), actionIdentifier::setVnfcName);
+
+ log.info("ActionIdentifierData" + actionIdentifier.toString());
+
+ log.info("Enter RequestInfo");
+ RequestInfo requestInfo = getRequestInfo(ctx, actionIdentifier);
+ log.debug("RequestInfo: " + requestInfo.toString());
+
+ InventoryInfo inventoryInfo = new InventoryInfoExtractor().getInventoryInfo(ctx, vnfId);
+ Capabilities capabilities = new CapabilitiesDataExtractor(dbService).getCapabilitiesData(ctx);
+ DependencyInfo dependencyInfo = getDependencyInfo(ctx);
+
+ log.info("Enter InputData");
+ Input input = getInput(requestInfo, inventoryInfo, dependencyInfo, capabilities);
+ log.info(fn + "Input parameters:" + input.toString());
+
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.setSerializationInclusion(Include.NON_NULL);
+ mapper.configure(SerializationFeature.WRAP_ROOT_VALUE, true);
+ String inputData = mapper.writeValueAsString(input);
+ log.info("InputDataJson:" + inputData);
+
+ return inputData;
+ }
+
+ private Input getInput(RequestInfo requestInfo, InventoryInfo inventoryInfo,
+ DependencyInfo dependencyInfo, Capabilities capabilities) {
+ Input input = new Input();
+ input.setRequestInfo(requestInfo);
+ input.setInventoryInfo(inventoryInfo);
+ input.setDependencyInfo(dependencyInfo);
+ input.setCapabilities(capabilities);
+ return input;
+ }
+
+ private RequestInfo getRequestInfo(SvcLogicContext ctx, ActionIdentifier actionIdentifier) {
+ RequestInfo requestInfo = new RequestInfo();
+ requestInfo.setAction(ctx.getAttribute(REQUEST_ACTION));
+ requestInfo.setActionLevel(ctx.getAttribute(ACTION_LEVEL));
+ requestInfo.setPayload(ctx.getAttribute(PAYLOAD));
+ requestInfo.setActionIdentifier(actionIdentifier);
+ return requestInfo;
+ }
+
+ DependencyInfo getDependencyInfo(SvcLogicContext ctx) throws SvcLogicException, IOException {
+
+ String fn = "FlowExecutorNode.getDependencyInfo";
+ String dependencyData = dbService.getDependencyInfo(ctx);
+ log.info(fn + "dependencyDataInput:" + dependencyData);
+
+ 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;
+ }
+
+ private Properties loadProperties() throws Exception {
+ String directory = envVariables.getenv(SDNC_CONFIG_DIR_VAR);
+ if (directory == null) {
+ throw new Exception("Cannot find Property file -" + SDNC_CONFIG_DIR_VAR);
+ }
+ String path = directory + APPC_FLOW_CONTROLLER;
+ return PropertiesLoader.load(path);
+ }
+
+ private void applyIfNotBlank(String parameter, Consumer<String> consumer) {
+ if (StringUtils.isNotBlank(parameter)) {
+ consumer.accept(parameter);
+ }
+ }
+
+}
diff --git a/appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/node/JsonValidator.java b/appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/node/JsonValidator.java
index 78d530533..038d35b5d 100644
--- a/appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/node/JsonValidator.java
+++ b/appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/node/JsonValidator.java
@@ -1,3 +1,22 @@
+/*
+ * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2018 Nokia. 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.appc.flow.controller.node;
import com.att.eelf.configuration.EELFLogger;
diff --git a/appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/node/PropertiesLoader.java b/appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/node/PropertiesLoader.java
index 28792bb10..854f476a1 100644
--- a/appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/node/PropertiesLoader.java
+++ b/appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/node/PropertiesLoader.java
@@ -1,3 +1,22 @@
+/*
+ * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2018 Nokia. 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.appc.flow.controller.node;
import java.io.FileInputStream;
diff --git a/appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/node/ResourceUriExtractor.java b/appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/node/ResourceUriExtractor.java
index cd07952cf..c36a74be7 100644
--- a/appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/node/ResourceUriExtractor.java
+++ b/appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/node/ResourceUriExtractor.java
@@ -1,3 +1,22 @@
+/*
+ * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2018 Nokia. 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.appc.flow.controller.node;
import static org.onap.appc.flow.controller.utils.FlowControllerConstants.HTTP;
diff --git a/appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/node/TransactionHandler.java b/appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/node/TransactionHandler.java
index af9e84589..b4becd9b1 100644
--- a/appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/node/TransactionHandler.java
+++ b/appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/node/TransactionHandler.java
@@ -1,3 +1,22 @@
+/*
+ * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2018 Nokia. 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.appc.flow.controller.node;
import static org.onap.appc.flow.controller.utils.FlowControllerConstants.INPUT_REQUEST_ACTION;
diff --git a/appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/controller/node/CapabilitiesDataExtractorTest.java b/appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/controller/node/CapabilitiesDataExtractorTest.java
new file mode 100644
index 000000000..c373840ab
--- /dev/null
+++ b/appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/controller/node/CapabilitiesDataExtractorTest.java
@@ -0,0 +1,68 @@
+/*
+ * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2018 Nokia. 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.appc.flow.controller.node;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.appc.flow.controller.dbervices.FlowControlDBService;
+import org.onap.appc.flow.controller.interfaceData.Capabilities;
+import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
+
+public class CapabilitiesDataExtractorTest {
+
+ private CapabilitiesDataExtractor capabilitiesDataExtractor;
+ private FlowControlDBService dbService;
+ private SvcLogicContext ctx;
+
+ @Before
+ public void setUp() {
+ dbService = mock(FlowControlDBService.class);
+ ctx = mock(SvcLogicContext.class);
+ capabilitiesDataExtractor = new CapabilitiesDataExtractor(dbService);
+ }
+
+ @Test
+ public void should_handle_capabilities_full_config() throws Exception {
+
+ String jsonPayload = "{'vnf':['vnf-1', 'vnf-2'],'vf-module':['vf-module-1', 'vf-module-2'],'vnfc':['vnfc-1', 'vnfc-2'],'vm':['vm-1', 'vm-2']}";
+ when(dbService.getCapabilitiesData(ctx)).thenReturn(jsonPayload.replaceAll("'","\""));
+
+ Capabilities capabilitiesData = capabilitiesDataExtractor.getCapabilitiesData(ctx);
+
+ Assert.assertEquals("Capabilities [vnf=[vnf-1, vnf-2], vfModule=[vf-module-1, vf-module-2], vm=[vm-1, vm-2], vnfc=[vnfc-1, vnfc-2]]", capabilitiesData.toString());
+ }
+
+ @Test
+ public void should_handle_capabilities_config_with_missing_params() throws Exception {
+
+ // CASE: vm is empty, vnfc is absent
+ String jsonPayload = "{'vnf':['vnf-1', 'vnf-2'],'vf-module':['vf-module-1'],'vm':[]}";
+ when(dbService.getCapabilitiesData(ctx)).thenReturn(jsonPayload.replaceAll("'","\""));
+
+ Capabilities capabilitiesData = capabilitiesDataExtractor.getCapabilitiesData(ctx);
+
+ Assert.assertEquals("Capabilities [vnf=[vnf-1, vnf-2], vfModule=[vf-module-1], vm=[], vnfc=[]]", capabilitiesData.toString());
+ }
+
+} \ No newline at end of file
diff --git a/appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/controller/node/FlowControlNodeTest.java b/appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/controller/node/FlowControlNodeTest.java
index d171f5f8b..b3c47925a 100644
--- a/appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/controller/node/FlowControlNodeTest.java
+++ b/appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/controller/node/FlowControlNodeTest.java
@@ -36,67 +36,23 @@ import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.onap.appc.flow.controller.dbervices.FlowControlDBService;
-import org.onap.appc.flow.controller.interfaceData.Capabilities;
import org.onap.appc.flow.controller.interfaceData.DependencyInfo;
import org.onap.appc.flow.controller.interfaceData.Vnfcs;
import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
public class FlowControlNodeTest {
- private SvcLogicContext ctx;
private FlowControlDBService dbService;
+ private SvcLogicContext ctx;
+ private FlowControlNode flowControlNode;
+ private FlowSequenceGenerator flowSequenceGenerator;
@Before
public void setUp() {
ctx = mock(SvcLogicContext.class);
dbService = mock(FlowControlDBService.class);
- }
-
- @Test
- public void should_handle_capabilities_full_config() throws Exception {
-
- String jsonPayload = "{'vnf':['vnf-1', 'vnf-2'],'vf-module':['vf-module-1', 'vf-module-2'],'vnfc':['vnfc-1', 'vnfc-2'],'vm':['vm-1', 'vm-2']}";
- when(dbService.getCapabilitiesData(ctx)).thenReturn(jsonPayload.replaceAll("'","\""));
-
- FlowControlNode flowControlNode = new FlowControlNode(null, dbService);
- Capabilities capabilitiesData = flowControlNode.getCapabilitiesData(ctx);
-
- Assert.assertEquals("Capabilities [vnf=[vnf-1, vnf-2], vfModule=[vf-module-1, vf-module-2], vm=[vm-1, vm-2], vnfc=[vnfc-1, vnfc-2]]", capabilitiesData.toString());
- }
-
- @Test
- public void should_handle_capabilities_config_with_missing_params() throws Exception {
-
- // vm is empty, vnfc is absent
- String jsonPayload = "{'vnf':['vnf-1', 'vnf-2'],'vf-module':['vf-module-1'],'vm':[]}";
- when(dbService.getCapabilitiesData(ctx)).thenReturn(jsonPayload.replaceAll("'","\""));
-
- FlowControlNode flowControlNode = new FlowControlNode(null, dbService);
- Capabilities capabilitiesData = flowControlNode.getCapabilitiesData(ctx);
-
- Assert.assertEquals("Capabilities [vnf=[vnf-1, vnf-2], vfModule=[vf-module-1], vm=[], vnfc=[]]", capabilitiesData.toString());
- }
-
- @Test
- public void should_handle_dependency_config() throws Exception {
-
- Vnfcs vnfcs = new Vnfcs();
- vnfcs.setVnfcType("some-type");
- vnfcs.setResilience("some-resilence");
- vnfcs.setMandatory("some-mandatory");
- Map<String, List<Vnfcs>> input = new HashMap<>();
- List<Vnfcs> list = new ArrayList<>();
- list.add(vnfcs);
- list.add(vnfcs);
- input.put("vnfcs", list);
-
- String jsonPayload = new ObjectMapper().writeValueAsString(input);
-
- when(dbService.getDependencyInfo(ctx)).thenReturn(jsonPayload);
-
- FlowControlNode flowControlNode = new FlowControlNode(null, dbService);
- DependencyInfo dependencyInfo = flowControlNode.getDependencyInfo(ctx);
+ flowSequenceGenerator = mock(FlowSequenceGenerator.class);
- Assert.assertEquals("DependencyInfo [vnfcs=[Vnfcs [vnfcType=some-type, mandatory=some-mandatory, resilience=some-resilence, parents=[]], Vnfcs [vnfcType=some-type, mandatory=some-mandatory, resilience=some-resilence, parents=[]]]]", dependencyInfo.toString());
+ flowControlNode = new FlowControlNode(dbService, flowSequenceGenerator);
}
}
diff --git a/appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/controller/node/FlowGeneratorTest.java b/appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/controller/node/FlowGeneratorTest.java
index 5981fc0b6..1d4fb6951 100644
--- a/appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/controller/node/FlowGeneratorTest.java
+++ b/appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/controller/node/FlowGeneratorTest.java
@@ -1,3 +1,22 @@
+/*
+ * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2018 Nokia. 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.appc.flow.controller.node;
import static org.mockito.Mockito.mock;
diff --git a/appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/controller/node/FlowSequenceGeneratorTest.java b/appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/controller/node/FlowSequenceGeneratorTest.java
new file mode 100644
index 000000000..533de5840
--- /dev/null
+++ b/appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/controller/node/FlowSequenceGeneratorTest.java
@@ -0,0 +1,208 @@
+/*
+ * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2018 Nokia. 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.appc.flow.controller.node;
+
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+import static org.onap.appc.flow.controller.node.FlowSequenceGenerator.MODULE;
+import static org.onap.appc.flow.controller.node.InputParamsCollector.SDNC_CONFIG_DIR_VAR;
+import static org.onap.appc.flow.controller.utils.FlowControllerConstants.DESINGTIME;
+import static org.onap.appc.flow.controller.utils.FlowControllerConstants.EXTERNAL;
+import static org.onap.appc.flow.controller.utils.FlowControllerConstants.FLOW_SEQUENCE;
+import static org.onap.appc.flow.controller.utils.FlowControllerConstants.GENERATION_NODE;
+import static org.onap.appc.flow.controller.utils.FlowControllerConstants.RUNTIME;
+import static org.onap.appc.flow.controller.utils.FlowControllerConstants.SEQUENCE_TYPE;
+import static org.onap.appc.flow.controller.utils.FlowControllerConstants.VNFC_TYPE;
+import static org.onap.appc.flow.controller.utils.FlowControllerConstants.VNF_ID;
+import static org.onap.appc.flow.controller.utils.FlowControllerConstants.VNF_TYPE;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.onap.appc.flow.controller.data.Transaction;
+import org.onap.appc.flow.controller.data.Transactions;
+import org.onap.appc.flow.controller.dbervices.FlowControlDBService;
+import org.onap.appc.flow.controller.executorImpl.GraphExecutor;
+import org.onap.appc.flow.controller.executorImpl.RestExecutor;
+import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
+
+public class FlowSequenceGeneratorTest {
+
+ private FlowControlDBService dbService;
+ private Map<String, String> inParams;
+ private SvcLogicContext localCtx;
+ private SvcLogicContext ctx;
+ private FlowGenerator flowGenerator;
+ private GraphExecutor graphExecutor;
+ private FlowSequenceGenerator flowSequenceGenerator;
+ private RestExecutor restExecutor;
+
+ @Rule
+ public ExpectedException expectedException = ExpectedException.none();
+
+ @Before
+ public void setUp() {
+ inParams = new HashMap<>();
+ ctx = mock(SvcLogicContext.class);
+ localCtx = mock(SvcLogicContext.class);
+ dbService = mock(FlowControlDBService.class);
+ flowGenerator = mock(FlowGenerator.class);
+ graphExecutor = mock(GraphExecutor.class);
+ restExecutor = mock(RestExecutor.class);
+
+ EnvVariables envVariables = mock(EnvVariables.class);
+
+ when(envVariables.getenv(SDNC_CONFIG_DIR_VAR)).thenReturn("./src/test/resources");
+
+ flowSequenceGenerator = new FlowSequenceGenerator(
+ dbService,
+ flowGenerator,
+ graphExecutor,
+ restExecutor,
+ envVariables
+ );
+ }
+
+ @Test
+ public void sequence_type_is_null() throws Exception {
+
+ Transaction transaction = new Transaction();
+ transaction.setExecutionType("mock-flow-generator");
+ ArrayList<Transaction> transactionList = new ArrayList<>();
+ transactionList.add(transaction);
+ Transactions transactions = new Transactions();
+ transactions.setTransactions(transactionList);
+
+ when(flowGenerator.createSingleStepModel(inParams, ctx)).thenReturn(transactions);
+
+ String seq = flowSequenceGenerator.getFlowSequence(inParams, ctx, localCtx);
+
+ Assert.assertEquals("{\"transactions\":[{\"executionType\":\"mock-flow-generator\",\"uId\":null,\"statusCode\":null,\"pswd\":null,\"executionEndPoint\":null,\"executionModule\":null,\"executionRPC\":null,\"status\":\"PENDING\",\"transaction-id\":0,\"action\":null,\"action-level\":null,\"action-identifier\":null,\"parameters\":null,\"state\":null,\"precheck\":null,\"payload\":null,\"responses\":null}]}", seq);
+ }
+
+ @Test
+ public void sequence_type_is_not_null_generator_and_generator_node_exists() throws Exception {
+
+ when(localCtx.getAttribute(SEQUENCE_TYPE)).thenReturn("some-seq-type");
+ when(localCtx.getAttribute(GENERATION_NODE)).thenReturn("some-gen-node");
+
+ when(graphExecutor.hasGraph(MODULE, "some-gen-node", null,"sync")).thenReturn(true);
+
+ Properties properties = new Properties();
+ properties.setProperty(FLOW_SEQUENCE, "flow-sequence");
+ when(graphExecutor.executeGraph(MODULE, "some-gen-node", null, "sync", null)).thenReturn(properties);
+
+ String seq = flowSequenceGenerator.getFlowSequence(inParams, ctx, localCtx);
+
+ Assert.assertEquals("flow-sequence", seq);
+ }
+
+ @Test
+ public void sequence_type_is_not_null_generator_exists_but_generator_node_not_exists() throws Exception {
+
+ when(localCtx.getAttribute(SEQUENCE_TYPE)).thenReturn("some-seq-type");
+ when(localCtx.getAttribute(GENERATION_NODE)).thenReturn("some-gen-node");
+
+ when(graphExecutor.hasGraph(MODULE, "some-gen-node", null,"sync")).thenReturn(false);
+
+ expectedException.expectMessage("Can not find Custom defined Flow Generator for some-gen-node");
+ flowSequenceGenerator.getFlowSequence(inParams, ctx, localCtx);
+ }
+
+ @Test
+ public void sequence_type_is_design_time() throws Exception {
+
+ when(localCtx.getAttribute(SEQUENCE_TYPE)).thenReturn(DESINGTIME);
+ when(dbService.getDesignTimeFlowModel(localCtx)).thenReturn("flow-sequence");
+
+ String flowSequence = flowSequenceGenerator.getFlowSequence(inParams, ctx, localCtx);
+ verify(localCtx).setAttribute(VNFC_TYPE, ctx.getAttribute(VNFC_TYPE));
+
+ Assert.assertEquals("flow-sequence", flowSequence);
+ }
+
+ @Test
+ public void sequence_type_is_design_time_but_got_null() throws Exception {
+
+ when(localCtx.getAttribute(SEQUENCE_TYPE)).thenReturn(DESINGTIME);
+ when(ctx.getAttribute(VNF_TYPE)).thenReturn("some-vnf-type");
+ when(dbService.getDesignTimeFlowModel(localCtx)).thenReturn(null);
+
+ expectedException.expectMessage("Flow Sequence is not found User Designed VNF some-vnf-type");
+ flowSequenceGenerator.getFlowSequence(inParams, ctx, localCtx);
+ verify(localCtx).setAttribute(VNFC_TYPE, ctx.getAttribute(VNFC_TYPE));
+ }
+
+ @Test
+ public void sequence_type_is_runtime() throws Exception {
+ when(localCtx.getAttribute(SEQUENCE_TYPE)).thenReturn(RUNTIME);
+ when(ctx.getAttribute(VNF_TYPE)).thenReturn("some-vnf-type");
+ when(ctx.getAttribute(VNF_ID)).thenReturn("some-vnf-id");
+
+ Map<String, String> map = new HashMap<>();
+ map.put("restResponse", "{'output':{'dummy-json-object':'some-param'}}".replaceAll("'", "\""));
+ when(restExecutor.execute(any(Transaction.class), eq(localCtx))).thenReturn(map);
+
+ String flowSequence = flowSequenceGenerator.getFlowSequence(inParams, ctx, localCtx);
+
+ Assert.assertEquals("{'dummy-json-object':'some-param'}".replaceAll("'", "\""), flowSequence);
+ }
+
+ @Test
+ public void sequence_type_is_runtime_but_got_null() throws Exception {
+ when(localCtx.getAttribute(SEQUENCE_TYPE)).thenReturn(RUNTIME);
+ when(ctx.getAttribute(VNF_TYPE)).thenReturn("some-vnf-type");
+ when(ctx.getAttribute(VNF_ID)).thenReturn("some-vnf-id");
+
+ Map<String, String> map = new HashMap<>();
+ map.put("restResponse", "{}".replaceAll("'", "\""));
+ when(restExecutor.execute(any(Transaction.class), eq(localCtx))).thenReturn(map);
+
+ expectedException.expectMessage("Failed to get the Flow Sequence runtime for VNF type some-vnf-type");
+ flowSequenceGenerator.getFlowSequence(inParams, ctx, localCtx);
+ }
+
+ @Test
+ public void sequence_type_is_external() throws Exception {
+ when(localCtx.getAttribute(SEQUENCE_TYPE)).thenReturn(EXTERNAL);
+ when(ctx.getAttribute(VNF_TYPE)).thenReturn("some-vnf-type");
+
+ expectedException.expectMessage("Flow Sequence not found for some-vnf-type");
+ flowSequenceGenerator.getFlowSequence(inParams, ctx, localCtx);
+ }
+
+ @Test
+ public void unknown_sequence() throws Exception {
+ when(localCtx.getAttribute(SEQUENCE_TYPE)).thenReturn("some-unknown-type");
+
+ expectedException.expectMessage("No information found for sequence Owner Design-Time Vs Run-Time");
+ flowSequenceGenerator.getFlowSequence(inParams, ctx, localCtx);
+ }
+
+} \ No newline at end of file
diff --git a/appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/controller/node/InputParamsCollectorTest.java b/appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/controller/node/InputParamsCollectorTest.java
new file mode 100644
index 000000000..dbf821e99
--- /dev/null
+++ b/appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/controller/node/InputParamsCollectorTest.java
@@ -0,0 +1,130 @@
+/*
+ * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2018 Nokia. 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.appc.flow.controller.node;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+import static org.onap.appc.flow.controller.node.InputParamsCollector.SDNC_CONFIG_DIR_VAR;
+import static org.onap.appc.flow.controller.utils.FlowControllerConstants.ACTION_LEVEL;
+import static org.onap.appc.flow.controller.utils.FlowControllerConstants.PAYLOAD;
+import static org.onap.appc.flow.controller.utils.FlowControllerConstants.REQUEST_ACTION;
+import static org.onap.appc.flow.controller.utils.FlowControllerConstants.VNFC_NAME;
+import static org.onap.appc.flow.controller.utils.FlowControllerConstants.VNF_ID;
+import static org.onap.appc.flow.controller.utils.FlowControllerConstants.VSERVER_ID;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.appc.flow.controller.data.Transaction;
+import org.onap.appc.flow.controller.dbervices.FlowControlDBService;
+import org.onap.appc.flow.controller.interfaceData.DependencyInfo;
+import org.onap.appc.flow.controller.interfaceData.Vnfcs;
+import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
+
+public class InputParamsCollectorTest {
+
+ private SvcLogicContext ctx;
+ private FlowControlDBService dbService;
+ private EnvVariables envVariables;
+ private InputParamsCollector inputParamsCollector;
+
+ @Before
+ public void setUp() {
+
+ ctx = mock(SvcLogicContext.class);
+ dbService = mock(FlowControlDBService.class);
+ envVariables = mock(EnvVariables.class);
+
+ when(envVariables.getenv(SDNC_CONFIG_DIR_VAR)).thenReturn("./src/test/resources");
+
+ inputParamsCollector = new InputParamsCollector(envVariables, dbService);
+ }
+
+ @Test
+ public void should_collect_input_params() throws Exception {
+
+ when(ctx.getAttribute(VNF_ID)).thenReturn("some-vnf-id");
+ when(ctx.getAttribute(REQUEST_ACTION)).thenReturn("some-request-action");
+ when(ctx.getAttribute(ACTION_LEVEL)).thenReturn("some-action-level");
+ when(ctx.getAttribute(PAYLOAD)).thenReturn("some-payload");
+ when(ctx.getAttribute(VSERVER_ID)).thenReturn("some-vserver-id");
+ when(ctx.getAttribute(VNFC_NAME)).thenReturn("some-vnfc-name");
+
+ when(dbService.getCapabilitiesData(ctx)).thenReturn(
+ "{'vnf':['vnf-1', 'vnf-2'],'vf-module':['vf-module-1', 'vf-module-2'],'vnfc':['vnfc-1', 'vnfc-2'],'vm':['vm-1', 'vm-2']}"
+ .replaceAll("'", "\""));
+ when(dbService.getDependencyInfo(ctx)).thenReturn(dependencyInfoPayload());
+
+ Transaction transaction = inputParamsCollector.collectInputParams(ctx);
+
+ Assert.assertEquals(
+ "{\"input\":{\"request-info\":{\"action\":\"some-request-action\",\"payload\":\"some-payload\",\"action-level\":\"some-action-level\",\"action-identifier\":{\"vnf-id\":\"some-vnf-id\",\"vserver-id\":\"some-vserver-id\",\"vnfc-name\":\"some-vnfc-name\"}},\"inventory-info\":{\"vnf-info\":{\"vnf-id\":\"some-vnf-id\",\"vm\":[]}},\"dependency-info\":{\"vnfcs\":[{\"vnfc-type\":\"some-type\",\"mandatory\":\"some-mandatory\",\"resilience\":\"some-resilience\",\"parents\":[]},{\"vnfc-type\":\"some-type\",\"mandatory\":\"some-mandatory\",\"resilience\":\"some-resilience\",\"parents\":[]}]},\"capabilities\":{\"vnf\":[\"vnf-1\",\"vnf-2\"],\"vm\":[\"vm-1\",\"vm-2\"],\"vnfc\":[\"vnfc-1\",\"vnfc-2\"],\"vf-module\":[\"vf-module-1\",\"vf-module-2\"]}}}",
+ transaction.getPayload());
+ Assert.assertEquals("POST", transaction.getExecutionRPC());
+ Assert.assertEquals("seq-generator-uid", transaction.getuId());
+ Assert.assertEquals("some-pswd", transaction.getPswd());
+ Assert.assertEquals("exec-endpoint", transaction.getExecutionEndPoint());
+ }
+
+ @Test
+ public void should_handle_dependency_config() throws Exception {
+
+ Vnfcs vnfcs = new Vnfcs();
+ vnfcs.setVnfcType("some-type");
+ vnfcs.setResilience("some-resilience");
+ vnfcs.setMandatory("some-mandatory");
+ Map<String, List<Vnfcs>> input = new HashMap<>();
+ List<Vnfcs> list = new ArrayList<>();
+ list.add(vnfcs);
+ list.add(vnfcs);
+ input.put("vnfcs", list);
+
+ String jsonPayload = new ObjectMapper().writeValueAsString(input);
+
+ when(dbService.getDependencyInfo(ctx)).thenReturn(jsonPayload);
+
+ DependencyInfo dependencyInfo = inputParamsCollector.getDependencyInfo(ctx);
+
+ Assert.assertEquals(
+ "DependencyInfo [vnfcs=[Vnfcs [vnfcType=some-type, mandatory=some-mandatory, resilience=some-resilience, parents=[]], Vnfcs [vnfcType=some-type, mandatory=some-mandatory, resilience=some-resilience, parents=[]]]]",
+ dependencyInfo.toString());
+ }
+
+ private String dependencyInfoPayload() throws JsonProcessingException {
+ Vnfcs vnfcs = new Vnfcs();
+ vnfcs.setVnfcType("some-type");
+ vnfcs.setResilience("some-resilience");
+ vnfcs.setMandatory("some-mandatory");
+ Map<String, List<Vnfcs>> input = new HashMap<>();
+ List<Vnfcs> list = new ArrayList<>();
+ list.add(vnfcs);
+ list.add(vnfcs);
+ input.put("vnfcs", list);
+
+ return new ObjectMapper().writeValueAsString(input);
+ }
+
+} \ No newline at end of file
diff --git a/appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/controller/node/JsonValidatorTest.java b/appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/controller/node/JsonValidatorTest.java
index fd6f92018..e1a412d45 100644
--- a/appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/controller/node/JsonValidatorTest.java
+++ b/appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/controller/node/JsonValidatorTest.java
@@ -1,3 +1,22 @@
+/*
+ * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2018 Nokia. 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.appc.flow.controller.node;
import com.fasterxml.jackson.databind.JsonNode;
diff --git a/appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/controller/node/PropertiesLoaderTest.java b/appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/controller/node/PropertiesLoaderTest.java
index 66bf802c3..10bd94018 100644
--- a/appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/controller/node/PropertiesLoaderTest.java
+++ b/appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/controller/node/PropertiesLoaderTest.java
@@ -1,3 +1,22 @@
+/*
+ * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2018 Nokia. 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.appc.flow.controller.node;
import java.io.FileNotFoundException;
diff --git a/appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/controller/node/ResourceUriExtractorTest.java b/appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/controller/node/ResourceUriExtractorTest.java
index 28a202c2d..e3f108e4a 100644
--- a/appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/controller/node/ResourceUriExtractorTest.java
+++ b/appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/controller/node/ResourceUriExtractorTest.java
@@ -1,3 +1,22 @@
+/*
+ * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2018 Nokia. 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.appc.flow.controller.node;
import static org.mockito.Mockito.mock;
diff --git a/appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/controller/node/TestRestServiceNode.java b/appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/controller/node/TestRestServiceNode.java
index 20a1fd3f9..fdf665a8e 100644
--- a/appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/controller/node/TestRestServiceNode.java
+++ b/appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/controller/node/TestRestServiceNode.java
@@ -27,6 +27,7 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.mockito.Mockito.when;
+import static org.onap.appc.flow.controller.node.InputParamsCollector.SDNC_CONFIG_DIR_VAR;
import static org.onap.appc.flow.controller.node.RestServiceNode.REST_RESPONSE;
import static org.onap.appc.flow.controller.utils.FlowControllerConstants.INPUT_PARAM_RESPONSE_PREFIX;
@@ -47,7 +48,6 @@ import org.onap.ccsdk.sli.core.sli.SvcLogicException;
public class TestRestServiceNode {
private static final String RESOURCE_URI = "resource-uri";
- private static final String MOCK_ENV = "src/test/resources";
private static final String REST_BODY_RESPONSE = "{ 'state' : 'TEST' }";
private RestServiceNode restServiceNode;
@@ -87,7 +87,8 @@ public class TestRestServiceNode {
when(restExecutorMock.execute(eq(transaction), any(SvcLogicContext.class)))
.thenReturn(restResponseMap);
- EnvVariables envVariables = new EnvVariables(envKey -> MOCK_ENV);
+ EnvVariables envVariables = mock(EnvVariables.class);
+ when(envVariables.getenv(SDNC_CONFIG_DIR_VAR)).thenReturn("src/test/resources");
restServiceNode = new RestServiceNode(transactionHandlerMock, restExecutorMock, uriExtractorMock, envVariables);
}
diff --git a/appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/controller/node/TransactionHandlerTest.java b/appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/controller/node/TransactionHandlerTest.java
index 637a9ea6e..158e0c93b 100644
--- a/appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/controller/node/TransactionHandlerTest.java
+++ b/appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/controller/node/TransactionHandlerTest.java
@@ -1,24 +1,22 @@
-/*-
+/*
* ============LICENSE_START=======================================================
* ONAP : APPC
* ================================================================================
- * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
+ * Copyright (C) 2018 Nokia. 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=========================================================
+ * ============LICENSE_END=========================================================
*/
-
package org.onap.appc.flow.controller.node;
import static org.mockito.Mockito.mock;
diff --git a/appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/executor/node/FlowControlNodeTest.java b/appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/executor/node/FlowControlNodeTest.java
deleted file mode 100644
index ba6f0c7ce..000000000
--- a/appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/executor/node/FlowControlNodeTest.java
+++ /dev/null
@@ -1,149 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP : APPC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Copyright (C) 2017 Amdocs
- * =============================================================================
- * 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.
- *
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.appc.flow.executor.node;
-
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.verify;
-
-import java.io.FileInputStream;
-import java.io.InputStream;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Properties;
-
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.mockito.Mock;
-import org.mockito.Mockito;
-import org.onap.appc.flow.controller.data.Transaction;
-import org.onap.appc.flow.controller.data.Transactions;
-import org.onap.appc.flow.controller.dbervices.FlowControlDBService;
-import org.onap.appc.flow.controller.node.FlowControlNode;
-import org.onap.appc.flow.controller.utils.FlowControllerConstants;
-import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
-import org.onap.ccsdk.sli.core.sli.SvcLogicException;
-import org.powermock.api.mockito.PowerMockito;
-import org.powermock.reflect.Whitebox;
-
-public class FlowControlNodeTest {
- @Mock
- FlowControlDBService dbservice = FlowControlDBService.initialise();
- @Mock
- FlowControlNode f = new FlowControlNode();
-
- Properties props = new Properties();
- private static final String SDNC_CONFIG_DIR_VAR = "SDNC_CONFIG_DIR";
- @Before
- public void setUp() throws Exception
-
- {
- FlowControlDBService dbservice = FlowControlDBService.initialise();
- }
- @Ignore("Test is taking 60 seconds")
- @Test(expected=Exception.class)
- public final void testProcessFlow() throws Exception {
- SvcLogicContext ctx = new SvcLogicContext();
-
- ctx.setAttribute("request-id","test");
- ctx.setAttribute("vnf-type","test");
- ctx.setAttribute("action-level","HealthCheck");
- ctx.setAttribute("request-action","HealthCheck");
- ctx.setAttribute("response-prefix","response-prefix");
-
- Map<String, String> inParams = new HashMap<String, String>();
- inParams.put("responsePrefix", "responsePrefix");
-
-
- Whitebox.invokeMethod(f, "processFlow",inParams, ctx);
- /*Properties props = new Properties();
- PowerMockito.spy(FlowControlNode.class);
- Transactions trans =null;
- HashMap<Integer, Transaction> transactionMap = null;
- String artifact_content="{‘PlaybookName’:’service_start’,‘EnvParameters’:{‘vnf_instance’:’$vnf_instance’},’Timeout’:600}";
- String capabilitiesData = "SUCCESS";
- System.out.println("End Test when");*/
-
-
- }
- @Ignore("Test is taking 60 seconds")
- @Test(expected=Exception.class)
- public void testprocessFlowSequence() throws Exception
- {
- Map<String, String> inparams = new HashMap<String,String>();
- SvcLogicContext ctx = new SvcLogicContext();
- ctx.setAttribute( " SEQUENCE-TYPE","test");
- ctx.setAttribute("flow-sequence", "1");
- ctx.setAttribute( "DesignTime","test");
- ctx.setAttribute( "vnf-type","test" );
-
- Whitebox.invokeMethod(f, "processFlowSequence",inparams, ctx, ctx);
-
- }
- @Test
- public void testexeuteAllTransaction() throws Exception
- {
- Map<Integer, Transaction> transactionMap = new HashMap<Integer,Transaction>();
- SvcLogicContext ctx = new SvcLogicContext();
- Whitebox.invokeMethod(f, "executeAllTransaction",transactionMap, ctx);
-
- }
- @Test
- public void testexeutepreProcessor() throws Exception
- {
- Map<Integer, Transaction> transactionMap = new HashMap<Integer,Transaction>();
- Transaction transaction = new Transaction();
- Whitebox.invokeMethod(f, "preProcessor",transactionMap, transaction);
-
- }
- @Test(expected=Exception.class)
- public void testcollectInputParams() throws Exception
- {
- SvcLogicContext ctx = new SvcLogicContext();
-
- Transaction transaction = new Transaction();
- Whitebox.invokeMethod(f, "collectInputParams",ctx, transaction);
-
- }
- @Ignore("Test is taking 60 seconds")
- @Test(expected=Exception.class)
- public void testgetDependencyInfo() throws Exception
- {
- SvcLogicContext ctx = new SvcLogicContext();
- Whitebox.invokeMethod(f, "getDependencyInfo",ctx);
-
- }
- public void testgetCapabilitesDatass() throws Exception
- {
- SvcLogicContext ctx = new SvcLogicContext();
- Whitebox.invokeMethod(f, "getDependencyInfo",ctx);
-
- }
-
-
-}
diff --git a/appc-config/appc-flow-controller/provider/src/test/resources/appc-flow-controller.properties b/appc-config/appc-flow-controller/provider/src/test/resources/appc-flow-controller.properties
index 0bbe7f207..e09a85e15 100644
--- a/appc-config/appc-flow-controller/provider/src/test/resources/appc-flow-controller.properties
+++ b/appc-config/appc-flow-controller/provider/src/test/resources/appc-flow-controller.properties
@@ -23,3 +23,6 @@
healthcheck.mock=false
healthcheck.default-rest-user=User
healthcheck.default-rest-pass=@#asd723%^
+seq_generator.uid=seq-generator-uid
+seq_generator.pwd=some-pswd
+seq_generator_url=exec-endpoint