summaryrefslogtreecommitdiffstats
path: root/appc-config/appc-flow-controller
diff options
context:
space:
mode:
authorGeorge, Lina (lg941u) <lg941u@att.com>2018-03-30 12:16:21 -0400
committerSkip Wonnell <skip@att.com>2018-03-30 13:35:20 -0500
commitb32e6f295fc0aaf37b78140aedd417d8064c1020 (patch)
tree9eb85b0c7a8b06b41e015cf7931fe5c6d2be20e4 /appc-config/appc-flow-controller
parent4ca53fd0b0e79e6c361a1495a1ac70f502ac829a (diff)
Changes to get properties from southbound propfile
Issue-ID: APPC-816 Change-Id: If08eb895526ba3998faf059be9b9c595b0f82b4d Signed-off-by: George, Lina (lg941u) <lg941u@att.com>
Diffstat (limited to 'appc-config/appc-flow-controller')
-rw-r--r--appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/executorImpl/RestExecutor.java57
-rw-r--r--appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/node/ResourceUriExtractor.java96
-rw-r--r--appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/node/RestServiceNode.java158
-rw-r--r--appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/utils/FlowControllerConstants.java15
-rw-r--r--appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/controller/node/ResourceUriExtractorTest.java117
-rw-r--r--appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/controller/node/TestRestServiceNode.java277
-rw-r--r--appc-config/appc-flow-controller/provider/src/test/resources/appc_southbound.properties28
7 files changed, 383 insertions, 365 deletions
diff --git a/appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/executorImpl/RestExecutor.java b/appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/executorImpl/RestExecutor.java
index d18f2a3e2..45c00215e 100644
--- a/appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/executorImpl/RestExecutor.java
+++ b/appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/executorImpl/RestExecutor.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP : APPC
* ================================================================================
- * Copyright (C) 2017-18 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
* =============================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,9 +15,7 @@
* 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=========================================================
+ * * ============LICENSE_END=========================================================
*/
package org.onap.appc.flow.controller.executorImpl;
@@ -51,7 +49,7 @@ public class RestExecutor implements FlowExecutorInterface {
private static final EELFLogger log = EELFManager.getInstance().getLogger(RestExecutor.class);
@Override
- public Map<String, String> execute(Transaction transaction, SvcLogicContext ctx) throws Exception{
+ public Map<String, String> execute(Transaction transaction, SvcLogicContext ctx) throws Exception {
log.info("Configuring Rest Operation....." + transaction.toString());
Map<String, String> outputMessage = new HashMap<>();
Client client = null;
@@ -61,35 +59,29 @@ public class RestExecutor implements FlowExecutorInterface {
SSLContext sslContext = SSLContext.getInstance("SSL");
sslContext.init(null, new javax.net.ssl.TrustManager[] {new SecureRestClientTrustManager()}, null);
DefaultClientConfig defaultClientConfig = new DefaultClientConfig();
- defaultClientConfig.getProperties().put(
- HTTPSProperties.PROPERTY_HTTPS_PROPERTIES,
+ defaultClientConfig.getProperties().put(HTTPSProperties.PROPERTY_HTTPS_PROPERTIES,
new HTTPSProperties(getHostnameVerifier(), sslContext));
client = createClient(defaultClientConfig);
- client.addFilter(new HTTPBasicAuthFilter(transaction.getuId(), transaction.getPswd()));
+ if ((transaction.getuId() != null) && (transaction.getPswd() != null)) {
+ client.addFilter(new HTTPBasicAuthFilter(transaction.getuId(), transaction.getPswd()));
+ }
WebResource webResource = client.resource(new URI(transaction.getExecutionEndPoint()));
webResource.setProperty("Content-Type", "application/json;charset=UTF-8");
- ClientResponse clientResponse = getClientResponse(transaction, webResource)
- .orElseThrow(() -> new Exception(
- "Cannot determine the state of : "
- + transaction.getActionLevel()
- + " HTTP response is null"));
+ ClientResponse clientResponse = getClientResponse(transaction, webResource).orElseThrow(() -> new Exception(
+ "Cannot determine the state of : " + transaction.getActionLevel() + " HTTP response is null"));
processClientResponse(clientResponse, transaction, outputMessage);
log.info("Completed Rest Operation.....");
} catch (Exception e) {
- log.debug("failed in RESTCONT Action ("
- + transaction.getExecutionRPC()
- + ") for the resource "
- + transaction.getExecutionEndPoint()
- + ", fault message :"
- + e.getMessage());
+ log.debug("failed in RESTCONT Action (" + transaction.getExecutionRPC() + ") for the resource "
+ + transaction.getExecutionEndPoint() + ", fault message :" + e.getMessage());
throw new Exception("Error While Sending Rest Request", e);
} finally {
- if(client != null) {
+ if (client != null) {
client.destroy();
}
}
@@ -105,28 +97,27 @@ public class RestExecutor implements FlowExecutorInterface {
}
private Optional<ClientResponse> getClientResponse(Transaction transaction, WebResource webResource) {
- String responseDataType=MediaType.APPLICATION_JSON;
- String requestDataType=MediaType.APPLICATION_JSON;
+ String responseDataType = MediaType.APPLICATION_JSON;
+ String requestDataType = MediaType.APPLICATION_JSON;
ClientResponse clientResponse = null;
log.info("Starting Rest Operation.....");
- if(HttpMethod.GET.equalsIgnoreCase(transaction.getExecutionRPC())) {
+ if (HttpMethod.GET.equalsIgnoreCase(transaction.getExecutionRPC())) {
clientResponse = webResource.accept(responseDataType).get(ClientResponse.class);
- }else if(HttpMethod.POST.equalsIgnoreCase(transaction.getExecutionRPC())) {
+ } else if (HttpMethod.POST.equalsIgnoreCase(transaction.getExecutionRPC())) {
clientResponse = webResource.type(requestDataType).post(ClientResponse.class, transaction.getPayload());
- }else if(HttpMethod.PUT.equalsIgnoreCase(transaction.getExecutionRPC())) {
+ } else if (HttpMethod.PUT.equalsIgnoreCase(transaction.getExecutionRPC())) {
clientResponse = webResource.type(requestDataType).put(ClientResponse.class, transaction.getPayload());
- }else if(HttpMethod.DELETE.equalsIgnoreCase(transaction.getExecutionRPC())) {
+ } else if (HttpMethod.DELETE.equalsIgnoreCase(transaction.getExecutionRPC())) {
clientResponse = webResource.delete(ClientResponse.class);
}
return Optional.ofNullable(clientResponse);
}
- private void processClientResponse (ClientResponse clientResponse,
- Transaction transaction,
- Map<String, String> outputMessage ) throws Exception {
+ private void processClientResponse(ClientResponse clientResponse, Transaction transaction,
+ Map<String, String> outputMessage) throws Exception {
- if(clientResponse.getStatus() == Status.OK.getStatusCode()) {
+ if (clientResponse.getStatus() == Status.OK.getStatusCode()) {
Response response = new Response();
response.setResponseCode(String.valueOf(Status.OK.getStatusCode()));
transaction.setResponses(Collections.singletonList(response));
@@ -136,10 +127,8 @@ public class RestExecutor implements FlowExecutorInterface {
if (StringUtils.isNotBlank(errorMsg)) {
log.debug("Error Message from Client Response" + errorMsg);
}
- throw new Exception("Cannot determine the state of : "
- + transaction.getActionLevel()
- + " HTTP error code : "
- + clientResponse.getStatus());
+ throw new Exception("Cannot determine the state of : " + transaction.getActionLevel()
+ + " HTTP error code : " + clientResponse.getStatus());
}
}
}
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 c36a74be7..af65b1259 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
@@ -2,13 +2,15 @@
* ============LICENSE_START=======================================================
* ONAP : APPC
* ================================================================================
- * Copyright (C) 2018 Nokia. All rights reserved.
+ * Copyright (C) 2018 Nokia. All rights reserved.
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
* =============================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * 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,
@@ -22,68 +24,74 @@ package org.onap.appc.flow.controller.node;
import static org.onap.appc.flow.controller.utils.FlowControllerConstants.HTTP;
import static org.onap.appc.flow.controller.utils.FlowControllerConstants.INPUT_CONTEXT;
import static org.onap.appc.flow.controller.utils.FlowControllerConstants.INPUT_HOST_IP_ADDRESS;
-import static org.onap.appc.flow.controller.utils.FlowControllerConstants.INPUT_PORT_NUMBER;
import static org.onap.appc.flow.controller.utils.FlowControllerConstants.INPUT_REQUEST_ACTION;
import static org.onap.appc.flow.controller.utils.FlowControllerConstants.INPUT_SUB_CONTEXT;
import static org.onap.appc.flow.controller.utils.FlowControllerConstants.INPUT_URL;
-
+import static org.onap.appc.flow.controller.utils.FlowControllerConstants.VNF_TYPE;
+import static org.onap.appc.flow.controller.utils.FlowControllerConstants.REST_PROTOCOL;
+import static org.onap.appc.flow.controller.utils.FlowControllerConstants.REST_PORT;
+import static org.onap.appc.flow.controller.utils.FlowControllerConstants.REST_CONTEXT_URL;
import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
import java.util.Properties;
import org.apache.commons.lang.StringUtils;
import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
-import org.onap.ccsdk.sli.core.sli.SvcLogicException;
/**
* Helper class for RestServiceNode
*/
class ResourceUriExtractor {
- private static final EELFLogger log = EELFManager.getInstance().getLogger(RestServiceNode.class);
+ private static final EELFLogger log = EELFManager.getInstance().getLogger(RestServiceNode.class);
- String extractResourceUri(SvcLogicContext ctx, Properties prop) throws Exception {
- String resourceUri = ctx.getAttribute(INPUT_URL);
+ String extractResourceUri(SvcLogicContext ctx, Properties prop) throws Exception {
+ String resourceUri = ctx.getAttribute(INPUT_URL);
- if (StringUtils.isBlank(resourceUri)) {
- resourceUri = getAddress(ctx);
- log.info("resourceUri= " + resourceUri);
- resourceUri += getContext(ctx, prop);
- log.info("resourceUri= " + resourceUri);
- resourceUri += getSubContext(ctx, prop);
- }
- log.info("resourceUri= " + resourceUri);
+ if (StringUtils.isBlank(resourceUri)) {
+ resourceUri = getAddress(ctx, prop);
+ log.info("resourceUri= " + resourceUri);
+ resourceUri += getContext(ctx, prop);
+ log.info("resourceUri= " + resourceUri);
+ resourceUri += getSubContext(ctx, prop);
+ }
+ log.info("resourceUri= " + resourceUri);
- return resourceUri;
- }
+ return resourceUri;
+ }
- private String getAddress(SvcLogicContext ctx) {
- String address = ctx.getAttribute(INPUT_HOST_IP_ADDRESS);
- String port = ctx.getAttribute(INPUT_PORT_NUMBER);
- return HTTP + address + ":" + port;
- }
+ private String getAddress(SvcLogicContext ctx, Properties prop) {
+ String address = ctx.getAttribute(INPUT_HOST_IP_ADDRESS);
+ String portPath = ctx.getAttribute(VNF_TYPE) + "." + (REST_PROTOCOL) + "."
+ + ctx.getAttribute(INPUT_REQUEST_ACTION) + "." + (REST_PORT);
+ String port = prop.getProperty(portPath);
+ return HTTP + address + ":" + port;
+ }
- private String getContext(SvcLogicContext ctx, Properties prop) throws Exception {
- String context;
- if (StringUtils.isNotBlank(ctx.getAttribute(INPUT_CONTEXT))) {
- context = "/" + ctx.getAttribute(INPUT_CONTEXT);
- } else if (prop.getProperty(ctx.getAttribute(INPUT_REQUEST_ACTION) + ".context") != null) {
- context = "/" + prop.getProperty(ctx.getAttribute(INPUT_REQUEST_ACTION) + ".context");
- } else {
- throw new Exception("Could Not found the context for operation " + ctx.getAttribute(INPUT_REQUEST_ACTION));
+ private String getContext(SvcLogicContext ctx, Properties prop) throws Exception {
+ String context;
+ String urlPath = ctx.getAttribute(VNF_TYPE) + "." + REST_PROTOCOL + "." + ctx.getAttribute(INPUT_REQUEST_ACTION)
+ + "." + REST_CONTEXT_URL;
+ if (StringUtils.isNotBlank(ctx.getAttribute(INPUT_CONTEXT))) {
+ context = "/" + ctx.getAttribute(INPUT_CONTEXT);
+ } else if (prop.getProperty(urlPath) != null) {
+ context = "/" + prop.getProperty(urlPath);
+ } else {
+ throw new Exception("Could not find the context for operation " + ctx.getAttribute(INPUT_REQUEST_ACTION));
+ }
+ return context;
}
- return context;
- }
- private String getSubContext(SvcLogicContext ctx, Properties prop) throws Exception {
- String subContext;
- if (StringUtils.isNotBlank(ctx.getAttribute(INPUT_SUB_CONTEXT))) {
- subContext = "/" + ctx.getAttribute(INPUT_SUB_CONTEXT);
- } else if (prop.getProperty(ctx.getAttribute(INPUT_REQUEST_ACTION) + ".sub-context") != null) {
- subContext = "/" + prop.getProperty(ctx.getAttribute(INPUT_REQUEST_ACTION) + ".sub-context");
- } else {
- throw new Exception("Could Not found the sub context for operation " + ctx.getAttribute(INPUT_REQUEST_ACTION));
+ private String getSubContext(SvcLogicContext ctx, Properties prop) throws Exception {
+ String subContext;
+ if (StringUtils.isNotBlank(ctx.getAttribute(INPUT_SUB_CONTEXT))) {
+ subContext = "/" + ctx.getAttribute(INPUT_SUB_CONTEXT);
+ } else if (prop.getProperty(ctx.getAttribute(INPUT_REQUEST_ACTION) + ".sub-context") != null) {
+ subContext = "/" + prop.getProperty(ctx.getAttribute(INPUT_REQUEST_ACTION) + ".sub-context");
+ } else {
+ throw new Exception(
+ "Could not find the sub context for operation " + ctx.getAttribute(INPUT_REQUEST_ACTION));
+ }
+ return subContext;
}
- return subContext;
- }
-} \ No newline at end of file
+}
diff --git a/appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/node/RestServiceNode.java b/appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/node/RestServiceNode.java
index 184ba3b1b..b8625db84 100644
--- a/appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/node/RestServiceNode.java
+++ b/appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/node/RestServiceNode.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP : APPC
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
* =============================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,21 +15,18 @@
* 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=========================================================
+ * * ============LICENSE_END=========================================================
*/
package org.onap.appc.flow.controller.node;
-import static org.onap.appc.flow.controller.utils.FlowControllerConstants.APPC_FLOW_CONTROLLER;
+import static org.onap.appc.flow.controller.utils.FlowControllerConstants.APPC_SOUTHBOUND;
import static org.onap.appc.flow.controller.utils.FlowControllerConstants.INPUT_PARAM_RESPONSE_PREFIX;
import static org.onap.appc.flow.controller.utils.FlowControllerConstants.OUTPUT_PARAM_ERROR_MESSAGE;
import static org.onap.appc.flow.controller.utils.FlowControllerConstants.OUTPUT_PARAM_STATUS;
import static org.onap.appc.flow.controller.utils.FlowControllerConstants.OUTPUT_STATUS_FAILURE;
import static org.onap.appc.flow.controller.utils.FlowControllerConstants.OUTPUT_STATUS_MESSAGE;
import static org.onap.appc.flow.controller.utils.FlowControllerConstants.OUTPUT_STATUS_SUCCESS;
-
import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
import com.fasterxml.jackson.databind.JsonNode;
@@ -44,82 +41,81 @@ import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin;
public class RestServiceNode implements SvcLogicJavaPlugin {
- private static final EELFLogger log = EELFManager.getInstance().getLogger(RestServiceNode.class);
- private static final String SDNC_CONFIG_DIR_VAR = "SDNC_CONFIG_DIR";
-
- static final String REST_RESPONSE = "restResponse";
-
- private final TransactionHandler transactionHandler;
- private final RestExecutor restExecutor;
- private final ResourceUriExtractor resourceUriExtractor;
- private final EnvVariables envVariables;
-
- public RestServiceNode() {
- this.transactionHandler = new TransactionHandler();
- this.restExecutor = new RestExecutor();
- this.resourceUriExtractor = new ResourceUriExtractor();
- this.envVariables = new EnvVariables();
- }
-
- /**
- * Constructor for tests, prefer to use no arg constructor
- */
- RestServiceNode(TransactionHandler transactionHandler, RestExecutor restExecutor,
- ResourceUriExtractor uriExtractor, EnvVariables envVariables) {
- this.transactionHandler = transactionHandler;
- this.restExecutor = restExecutor;
- this.resourceUriExtractor = uriExtractor;
- this.envVariables = envVariables;
- }
-
- public void sendRequest(Map<String, String> inParams, SvcLogicContext ctx)
- throws SvcLogicException {
- String fn = "RestServiceNode.sendRequest";
- log.info("Received processParamKeys call with params : " + inParams);
- String responsePrefix = inParams.get(INPUT_PARAM_RESPONSE_PREFIX);
- try {
- responsePrefix = StringUtils.isNotBlank(responsePrefix) ? (responsePrefix + ".") : "";
- //Remove below for Block
- for (String key : ctx.getAttributeKeySet()) {
- log.info(fn + "Getting Key = " + key + "and Value = " + ctx.getAttribute(key));
- }
-
- Properties prop = loadProperties();
- log.info("Loaded Properties " + prop.toString());
-
- String resourceUri = resourceUriExtractor.extractResourceUri(ctx, prop);
-
- log.info("Rest Constructed URL : " + resourceUri);
-
- Transaction transaction = transactionHandler.buildTransaction(ctx, prop, resourceUri);
- Map<String, String> output = restExecutor.execute(transaction, ctx);
-
- String json = output.get(REST_RESPONSE);
- log.info("Received response from Interface " + json);
-
- JsonNode validatedJson = JsonValidator.validate(json);
-
- if (validatedJson != null) {
- log.info("state is " + validatedJson.findValue("state"));
- ctx.setAttribute(responsePrefix + OUTPUT_STATUS_MESSAGE, output.get(REST_RESPONSE));
- }
-
- ctx.setAttribute(responsePrefix + OUTPUT_PARAM_STATUS, OUTPUT_STATUS_SUCCESS);
-
- } catch (Exception e) {
- ctx.setAttribute(responsePrefix + OUTPUT_PARAM_STATUS, OUTPUT_STATUS_FAILURE);
- ctx.setAttribute(responsePrefix + OUTPUT_PARAM_ERROR_MESSAGE, e.getMessage());
- log.error("Error Message : " + e.getMessage(), e);
- throw new SvcLogicException(e.getMessage());
+ private static final EELFLogger log = EELFManager.getInstance().getLogger(RestServiceNode.class);
+ public static final String APPC_CONFIG_DIR_VAR = "APPC_CONFIG_DIR";
+
+ static final String REST_RESPONSE = "restResponse";
+
+ private final TransactionHandler transactionHandler;
+ private final RestExecutor restExecutor;
+ private final ResourceUriExtractor resourceUriExtractor;
+ private final EnvVariables envVariables;
+
+ public RestServiceNode() {
+ this.transactionHandler = new TransactionHandler();
+ this.restExecutor = new RestExecutor();
+ this.resourceUriExtractor = new ResourceUriExtractor();
+ this.envVariables = new EnvVariables();
+ }
+
+ /**
+ * Constructor for tests, prefer to use no arg constructor
+ */
+ RestServiceNode(TransactionHandler transactionHandler, RestExecutor restExecutor, ResourceUriExtractor uriExtractor,
+ EnvVariables envVariables) {
+ this.transactionHandler = transactionHandler;
+ this.restExecutor = restExecutor;
+ this.resourceUriExtractor = uriExtractor;
+ this.envVariables = envVariables;
+ }
+
+ public void sendRequest(Map<String, String> inParams, SvcLogicContext ctx) throws SvcLogicException {
+ String fn = "RestServiceNode.sendRequest";
+ log.info("Received processParamKeys call with params : " + inParams);
+ String responsePrefix = inParams.get(INPUT_PARAM_RESPONSE_PREFIX);
+ try {
+ responsePrefix = StringUtils.isNotBlank(responsePrefix) ? (responsePrefix + ".") : "";
+ // Remove below for Block
+ for (String key : ctx.getAttributeKeySet()) {
+ log.info(fn + "Getting Key = " + key + "and Value = " + ctx.getAttribute(key));
+ }
+
+ Properties prop = loadProperties();
+ log.info("Loaded Properties " + prop.toString());
+
+ String resourceUri = resourceUriExtractor.extractResourceUri(ctx, prop);
+
+ log.info("Rest Constructed URL : " + resourceUri);
+
+ Transaction transaction = transactionHandler.buildTransaction(ctx, prop, resourceUri);
+ Map<String, String> output = restExecutor.execute(transaction, ctx);
+
+ String json = output.get(REST_RESPONSE);
+ log.info("Received response from Interface " + json);
+
+ JsonNode validatedJson = JsonValidator.validate(json);
+
+ if (validatedJson != null) {
+ log.info("state is " + validatedJson.findValue("state"));
+ ctx.setAttribute(responsePrefix + OUTPUT_STATUS_MESSAGE, output.get(REST_RESPONSE));
+ }
+
+ ctx.setAttribute(responsePrefix + OUTPUT_PARAM_STATUS, OUTPUT_STATUS_SUCCESS);
+
+ } catch (Exception e) {
+ ctx.setAttribute(responsePrefix + OUTPUT_PARAM_STATUS, OUTPUT_STATUS_FAILURE);
+ ctx.setAttribute(responsePrefix + OUTPUT_PARAM_ERROR_MESSAGE, e.getMessage());
+ log.error("Error Message : " + e.getMessage(), e);
+ throw new SvcLogicException(e.getMessage());
+ }
}
- }
- 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);
+ private Properties loadProperties() throws Exception {
+ String directory = envVariables.getenv(APPC_CONFIG_DIR_VAR);
+ if (directory == null) {
+ throw new Exception("Cannot find Property file: " + APPC_CONFIG_DIR_VAR);
+ }
+ String path = directory + APPC_SOUTHBOUND;
+ return PropertiesLoader.load(path);
}
- 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/utils/FlowControllerConstants.java b/appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/utils/FlowControllerConstants.java
index 502438c31..275dd431f 100644
--- a/appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/utils/FlowControllerConstants.java
+++ b/appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/utils/FlowControllerConstants.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP : APPC
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
* =============================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,9 +15,7 @@
* 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=========================================================
+ * * ============LICENSE_END=========================================================
*/
package org.onap.appc.flow.controller.utils;
@@ -42,6 +40,7 @@ public class FlowControllerConstants {
public static final String DESINGTIME = "DesignTime";
public static final String RUNTIME = "RunTime";
public static final String APPC_FLOW_CONTROLLER = "/appc-flow-controller.properties";
+ public static final String APPC_SOUTHBOUND = "/appc_southbound.properties";
public static final String VNF_TYPE = "vnf-type";
public static final String ACTION = "action";
public static final String VNFC_TYPE = "vnfc-type";
@@ -98,7 +97,7 @@ public class FlowControllerConstants {
public static final String OUTPUT_STATUS_MESSAGE = "status-message";
public static final String HEALTHY = "healthy";
public static final String INPUT_URL = "input.url";
- public static final String INPUT_HOST_IP_ADDRESS = "host-ip-address";
+ public static final String INPUT_HOST_IP_ADDRESS = "request-parameters.host-ip-address";
public static final String INPUT_PORT_NUMBER = "port-number";
public static final String INPUT_CONTEXT = "context";
public static final String INPUT_SUB_CONTEXT = "sub-context";
@@ -116,4 +115,10 @@ public class FlowControllerConstants {
public static final String VF_MODULE = "vf-module";
public static final String VNFC_NAME = "vnfc-name";
public static final String AAI_VNF_TYPE = "aai-vnf-type";
+ public static final String REST_PROTOCOL = "REST";
+ public static final String HEALTHCHECK ="HealthCheck";
+ public static final String REST_USER="user";
+ public static final String REST_PWD="password";
+ public static final String REST_PORT="port";
+ public static final String REST_CONTEXT_URL="url";
}
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 e3f108e4a..34227587a 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
@@ -3,12 +3,14 @@
* ONAP : APPC
* ================================================================================
* Copyright (C) 2018 Nokia. All rights reserved.
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
* =============================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * 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,
@@ -23,11 +25,13 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import static org.onap.appc.flow.controller.utils.FlowControllerConstants.INPUT_CONTEXT;
import static org.onap.appc.flow.controller.utils.FlowControllerConstants.INPUT_HOST_IP_ADDRESS;
-import static org.onap.appc.flow.controller.utils.FlowControllerConstants.INPUT_PORT_NUMBER;
import static org.onap.appc.flow.controller.utils.FlowControllerConstants.INPUT_REQUEST_ACTION;
import static org.onap.appc.flow.controller.utils.FlowControllerConstants.INPUT_SUB_CONTEXT;
import static org.onap.appc.flow.controller.utils.FlowControllerConstants.INPUT_URL;
-
+import static org.onap.appc.flow.controller.utils.FlowControllerConstants.REST_CONTEXT_URL;
+import static org.onap.appc.flow.controller.utils.FlowControllerConstants.REST_PORT;
+import static org.onap.appc.flow.controller.utils.FlowControllerConstants.REST_PROTOCOL;
+import static org.onap.appc.flow.controller.utils.FlowControllerConstants.VNF_TYPE;
import java.util.Properties;
import org.junit.Assert;
import org.junit.Before;
@@ -38,73 +42,74 @@ import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
public class ResourceUriExtractorTest {
- private Properties prop;
- private SvcLogicContext ctx;
-
- @Rule
- public ExpectedException expectedException = ExpectedException.none();
- private ResourceUriExtractor resourceUriExtractor;
-
- @Before
- public void setUp() {
- ctx = mock(SvcLogicContext.class);
- prop = mock(Properties.class);
- resourceUriExtractor = new ResourceUriExtractor();
- }
+ private Properties prop;
+ private SvcLogicContext ctx;
- @Test
- public void should_return_input_url_if_exist() throws Exception {
- ctx = mock(SvcLogicContext.class);
- when(ctx.getAttribute(INPUT_URL)).thenReturn("http://localhost:8080");
+ @Rule
+ public ExpectedException expectedException = ExpectedException.none();
+ private ResourceUriExtractor resourceUriExtractor;
- resourceUriExtractor = new ResourceUriExtractor();
- String resourceUri = resourceUriExtractor.extractResourceUri(ctx, prop);
+ @Before
+ public void setUp() {
+ ctx = mock(SvcLogicContext.class);
+ prop = mock(Properties.class);
+ resourceUriExtractor = new ResourceUriExtractor();
+ }
- Assert.assertEquals("http://localhost:8080", resourceUri);
- }
+ @Test
+ public void should_return_input_url_if_exist() throws Exception {
+ ctx = mock(SvcLogicContext.class);
+ when(ctx.getAttribute(INPUT_URL)).thenReturn("http://localhost:8080");
- @Test
- public void should_extract_url_input_if_context_input_provided() throws Exception {
- when(ctx.getAttribute(INPUT_URL)).thenReturn("");
- when(ctx.getAttribute(INPUT_HOST_IP_ADDRESS)).thenReturn("localhost");
- when(ctx.getAttribute(INPUT_PORT_NUMBER)).thenReturn("8080");
+ resourceUriExtractor = new ResourceUriExtractor();
+ String resourceUri = resourceUriExtractor.extractResourceUri(ctx, prop);
- when(ctx.getAttribute(INPUT_CONTEXT)).thenReturn("input-context");
- when(ctx.getAttribute(INPUT_SUB_CONTEXT)).thenReturn("input-sub-context");
+ Assert.assertEquals("http://localhost:8080", resourceUri);
+ }
- String resourceUri = resourceUriExtractor.extractResourceUri(ctx, prop);
+ @Test
+ public void should_extract_url_input_if_context_input_provided() throws Exception {
+ when(ctx.getAttribute(INPUT_URL)).thenReturn("");
+ when(ctx.getAttribute(INPUT_HOST_IP_ADDRESS)).thenReturn("localhost");
+ when(prop.getProperty(ctx.getAttribute(VNF_TYPE) + "." + (REST_PROTOCOL) + "."
+ + ctx.getAttribute(INPUT_REQUEST_ACTION) + "." + (REST_PORT))).thenReturn("8080");
- Assert.assertEquals("http://localhost:8080/input-context/input-sub-context", resourceUri);
- }
+ when(ctx.getAttribute(INPUT_CONTEXT)).thenReturn("input-context");
+ when(ctx.getAttribute(INPUT_SUB_CONTEXT)).thenReturn("input-sub-context");
- @Test
- public void should_extract_url_input_if_request_action_provided() throws Exception {
+ String resourceUri = resourceUriExtractor.extractResourceUri(ctx, prop);
- when(ctx.getAttribute(INPUT_URL)).thenReturn("");
- when(ctx.getAttribute(INPUT_HOST_IP_ADDRESS)).thenReturn("localhost");
- when(ctx.getAttribute(INPUT_PORT_NUMBER)).thenReturn("8080");
+ Assert.assertEquals("http://localhost:8080/input-context/input-sub-context", resourceUri);
+ }
- when(ctx.getAttribute(INPUT_REQUEST_ACTION)).thenReturn("request-action");
- when(ctx.getAttribute(INPUT_REQUEST_ACTION)).thenReturn("request-action");
+ @Test
+ public void should_extract_url_input_if_request_action_provided() throws Exception {
+ when(ctx.getAttribute(INPUT_REQUEST_ACTION)).thenReturn("request-action");
+ when(ctx.getAttribute(INPUT_URL)).thenReturn("");
+ when(ctx.getAttribute(INPUT_HOST_IP_ADDRESS)).thenReturn("localhost");
+ when(prop.getProperty(ctx.getAttribute(VNF_TYPE) + "." + (REST_PROTOCOL) + "."
+ + ctx.getAttribute(INPUT_REQUEST_ACTION) + "." + (REST_PORT))).thenReturn("8080");
- when(prop.getProperty("request-action.context")).thenReturn("ra-context");
- when(prop.getProperty("request-action.sub-context")).thenReturn("ra-sub-context");
+ when(prop.getProperty(ctx.getAttribute(VNF_TYPE) + "." + REST_PROTOCOL + "."
+ + ctx.getAttribute(INPUT_REQUEST_ACTION) + "." + REST_CONTEXT_URL)).thenReturn("ra-context");
+ when(prop.getProperty("request-action.sub-context")).thenReturn("ra-sub-context");
- String resourceUri = resourceUriExtractor.extractResourceUri(ctx, prop);
+ String resourceUri = resourceUriExtractor.extractResourceUri(ctx, prop);
- Assert.assertEquals("http://localhost:8080/ra-context/ra-sub-context", resourceUri);
- }
+ Assert.assertEquals("http://localhost:8080/ra-context/ra-sub-context", resourceUri);
+ }
- @Test
- public void should_throw_exception_if_missing_context() throws Exception {
- when(ctx.getAttribute(INPUT_URL)).thenReturn("");
- when(ctx.getAttribute(INPUT_HOST_IP_ADDRESS)).thenReturn("localhost");
- when(ctx.getAttribute(INPUT_PORT_NUMBER)).thenReturn("8080");
+ @Test
+ public void should_throw_exception_if_missing_context() throws Exception {
+ when(ctx.getAttribute(INPUT_URL)).thenReturn("");
+ when(ctx.getAttribute(INPUT_HOST_IP_ADDRESS)).thenReturn("localhost");
+ when(prop.getProperty(ctx.getAttribute(VNF_TYPE) + "." + (REST_PROTOCOL) + "."
+ + ctx.getAttribute(INPUT_REQUEST_ACTION) + "." + (REST_PORT))).thenReturn("8080");
- expectedException.expect(Exception.class);
- expectedException.expectMessage("Could Not found the context for operation null");
+ expectedException.expect(Exception.class);
+ expectedException.expectMessage("Could not find the context for operation null");
- resourceUriExtractor.extractResourceUri(ctx, prop);
- }
+ resourceUriExtractor.extractResourceUri(ctx, prop);
+ }
-} \ No newline at end of file
+}
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 fdf665a8e..001581402 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
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP : APPC
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
* =============================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,9 +15,7 @@
* 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=========================================================
+ * * ============LICENSE_END=========================================================
*/
package org.onap.appc.flow.controller.node;
@@ -27,10 +25,9 @@ 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.APPC_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;
-
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
@@ -47,144 +44,134 @@ import org.onap.ccsdk.sli.core.sli.SvcLogicException;
public class TestRestServiceNode {
- private static final String RESOURCE_URI = "resource-uri";
- private static final String REST_BODY_RESPONSE = "{ 'state' : 'TEST' }";
-
- private RestServiceNode restServiceNode;
-
- private ResourceUriExtractor uriExtractorMock;
- private TransactionHandler transactionHandlerMock;
- private RestExecutor restExecutorMock;
-
- private SvcLogicContext ctxMock;
- private Transaction transaction;
- private Map<String, String> params;
-
- @Rule
- public ExpectedException expectedException = ExpectedException.none();
-
- @Before
- public void setUp() throws Exception {
-
- uriExtractorMock = mock(ResourceUriExtractor.class);
- transactionHandlerMock = mock(TransactionHandler.class);
- restExecutorMock = mock(RestExecutor.class);
- ctxMock = mock(SvcLogicContext.class);
- transaction = mock(Transaction.class);
-
- // given
- params = new HashMap<>();
-
- HashMap<String, String> restResponseMap = new HashMap<>();
- restResponseMap.put(REST_RESPONSE, REST_BODY_RESPONSE.replaceAll("'", "\""));
-
- when(uriExtractorMock
- .extractResourceUri(any(SvcLogicContext.class), any(Properties.class)))
- .thenReturn(RESOURCE_URI);
- when(transactionHandlerMock
- .buildTransaction(any(SvcLogicContext.class), any(Properties.class), eq(RESOURCE_URI)))
- .thenReturn(transaction);
- when(restExecutorMock.execute(eq(transaction), any(SvcLogicContext.class)))
- .thenReturn(restResponseMap);
-
- EnvVariables envVariables = mock(EnvVariables.class);
- when(envVariables.getenv(SDNC_CONFIG_DIR_VAR)).thenReturn("src/test/resources");
- restServiceNode = new RestServiceNode(transactionHandlerMock, restExecutorMock, uriExtractorMock, envVariables);
- }
-
- @Test
- public void should_send_request() throws Exception {
- // given
- params.put(INPUT_PARAM_RESPONSE_PREFIX, "some-prefix");
-
- // when
- restServiceNode.sendRequest(params, ctxMock);
-
- // then
- verify(uriExtractorMock)
- .extractResourceUri(eq(ctxMock), any(Properties.class));
- verify(transactionHandlerMock)
- .buildTransaction(eq(ctxMock), any(Properties.class), eq(RESOURCE_URI));
- verify(restExecutorMock)
- .execute(transaction, ctxMock);
- verifyNoMoreInteractions(uriExtractorMock, transactionHandlerMock, restExecutorMock);
- }
-
- @Test
- public void should_rethrow_exception_from_uri_extractor() throws Exception {
- when(uriExtractorMock
- .extractResourceUri(eq(ctxMock), any(Properties.class)))
- .thenThrow(new Exception("resource uri exception"));
-
- expectedException.expect(SvcLogicException.class);
- expectedException.expectMessage("resource uri exception");
-
- restServiceNode.sendRequest(params, ctxMock);
- }
-
- @Test
- public void should_rethrow_exception_from_transaction_handler() throws Exception {
- when(transactionHandlerMock
- .buildTransaction(eq(ctxMock), any(Properties.class), eq(RESOURCE_URI)))
- .thenThrow(new Exception("transaction exception"));
-
- expectedException.expect(SvcLogicException.class);
- expectedException.expectMessage("transaction exception");
-
- restServiceNode.sendRequest(params, ctxMock);
- }
-
- @Test
- public void should_rethrow_exception_from_rest_executor() throws Exception {
- when(restExecutorMock
- .execute(transaction, ctxMock))
- .thenThrow(new Exception("rest executor exception"));
-
- expectedException.expect(SvcLogicException.class);
- expectedException.expectMessage("rest executor exception");
-
- restServiceNode.sendRequest(params, ctxMock);
- }
-
- @Ignore("missing asserts")
- @Test(expected = Exception.class)
- public void testRestServiceNode() throws Exception {
-
- SvcLogicContext ctx = new SvcLogicContext();
- ctx.setAttribute(FlowControllerConstants.VNF_TYPE, "vUSP - vDBE-IPX HUB");
- ctx.setAttribute(FlowControllerConstants.REQUEST_ACTION, "healthcheck");
- ctx.setAttribute(FlowControllerConstants.VNFC_TYPE, "TESTVNFC-CF");
- ctx.setAttribute(FlowControllerConstants.REQUEST_ID, "TESTCOMMONFRMWK");
- ctx.setAttribute("host-ip-address", "127.0.0.1");
- ctx.setAttribute("port-number", "8888");
- ctx.setAttribute("request-action-type", "GET");
- ctx.setAttribute("context", "loader/restconf/operations/appc-provider-lcm:health-check");
-
- HashMap<String, String> inParams = new HashMap<String, String>();
- RestServiceNode rsn = new RestServiceNode();
- inParams.put("output-state", "state");
- inParams.put("responsePrefix", "healthcheck");
- rsn.sendRequest(inParams, ctx);
-
- for (Object key : ctx.getAttributeKeySet()) {
- String parmName = (String) key;
- String parmValue = ctx.getAttribute(parmName);
+ private static final String RESOURCE_URI = "resource-uri";
+ private static final String REST_BODY_RESPONSE = "{ 'state' : 'TEST' }";
+
+ private RestServiceNode restServiceNode;
+
+ private ResourceUriExtractor uriExtractorMock;
+ private TransactionHandler transactionHandlerMock;
+ private RestExecutor restExecutorMock;
+
+ private SvcLogicContext ctxMock;
+ private Transaction transaction;
+ private Map<String, String> params;
+
+ @Rule
+ public ExpectedException expectedException = ExpectedException.none();
+
+ @Before
+ public void setUp() throws Exception {
+
+ uriExtractorMock = mock(ResourceUriExtractor.class);
+ transactionHandlerMock = mock(TransactionHandler.class);
+ restExecutorMock = mock(RestExecutor.class);
+ ctxMock = mock(SvcLogicContext.class);
+ transaction = mock(Transaction.class);
+
+ // given
+ params = new HashMap<>();
+
+ HashMap<String, String> restResponseMap = new HashMap<>();
+ restResponseMap.put(REST_RESPONSE, REST_BODY_RESPONSE.replaceAll("'", "\""));
+
+ when(uriExtractorMock.extractResourceUri(any(SvcLogicContext.class), any(Properties.class)))
+ .thenReturn(RESOURCE_URI);
+ when(transactionHandlerMock.buildTransaction(any(SvcLogicContext.class), any(Properties.class),
+ eq(RESOURCE_URI))).thenReturn(transaction);
+ when(restExecutorMock.execute(eq(transaction), any(SvcLogicContext.class))).thenReturn(restResponseMap);
+
+ EnvVariables envVariables = mock(EnvVariables.class);
+ when(envVariables.getenv(APPC_CONFIG_DIR_VAR)).thenReturn("src/test/resources");
+ restServiceNode = new RestServiceNode(transactionHandlerMock, restExecutorMock, uriExtractorMock, envVariables);
+ }
+
+ @Test
+ public void should_send_request() throws Exception {
+ // given
+ params.put(INPUT_PARAM_RESPONSE_PREFIX, "some-prefix");
+
+ // when
+ restServiceNode.sendRequest(params, ctxMock);
+
+ // then
+ verify(uriExtractorMock).extractResourceUri(eq(ctxMock), any(Properties.class));
+ verify(transactionHandlerMock).buildTransaction(eq(ctxMock), any(Properties.class), eq(RESOURCE_URI));
+ verify(restExecutorMock).execute(transaction, ctxMock);
+ verifyNoMoreInteractions(uriExtractorMock, transactionHandlerMock, restExecutorMock);
+ }
+
+ @Test
+ public void should_rethrow_exception_from_uri_extractor() throws Exception {
+ when(uriExtractorMock.extractResourceUri(eq(ctxMock), any(Properties.class)))
+ .thenThrow(new Exception("resource uri exception"));
+
+ expectedException.expect(SvcLogicException.class);
+ expectedException.expectMessage("resource uri exception");
+
+ restServiceNode.sendRequest(params, ctxMock);
+ }
+
+ @Test
+ public void should_rethrow_exception_from_transaction_handler() throws Exception {
+ when(transactionHandlerMock.buildTransaction(eq(ctxMock), any(Properties.class), eq(RESOURCE_URI)))
+ .thenThrow(new Exception("transaction exception"));
+
+ expectedException.expect(SvcLogicException.class);
+ expectedException.expectMessage("transaction exception");
+
+ restServiceNode.sendRequest(params, ctxMock);
+ }
+
+ @Test
+ public void should_rethrow_exception_from_rest_executor() throws Exception {
+ when(restExecutorMock.execute(transaction, ctxMock)).thenThrow(new Exception("rest executor exception"));
+
+ expectedException.expect(SvcLogicException.class);
+ expectedException.expectMessage("rest executor exception");
+
+ restServiceNode.sendRequest(params, ctxMock);
+ }
+
+ @Ignore("missing asserts")
+ @Test(expected = Exception.class)
+ public void testRestServiceNode() throws Exception {
+
+ SvcLogicContext ctx = new SvcLogicContext();
+ ctx.setAttribute(FlowControllerConstants.VNF_TYPE, "vUSP - vDBE-IPX HUB");
+ ctx.setAttribute(FlowControllerConstants.REQUEST_ACTION, "healthcheck");
+ ctx.setAttribute(FlowControllerConstants.VNFC_TYPE, "TESTVNFC-CF");
+ ctx.setAttribute(FlowControllerConstants.REQUEST_ID, "TESTCOMMONFRMWK");
+ ctx.setAttribute("host-ip-address", "127.0.0.1");
+ ctx.setAttribute("port-number", "8888");
+ ctx.setAttribute("request-action-type", "GET");
+ ctx.setAttribute("context", "loader/restconf/operations/appc-provider-lcm:health-check");
+
+ HashMap<String, String> inParams = new HashMap<String, String>();
+ RestServiceNode rsn = new RestServiceNode();
+ inParams.put("output-state", "state");
+ inParams.put("responsePrefix", "healthcheck");
+ rsn.sendRequest(inParams, ctx);
+
+ for (Object key : ctx.getAttributeKeySet()) {
+ String parmName = (String) key;
+ String parmValue = ctx.getAttribute(parmName);
+ }
+ }
+
+ @Ignore("missing asserts")
+ @Test(expected = Exception.class)
+ public void testInputParamsRestServiceNode() throws Exception {
+ SvcLogicContext ctx = new SvcLogicContext();
+ ctx.setAttribute("vnf-id", "test");
+ ctx.setAttribute("tmp.vnfInfo.vm-count", "1");
+ ctx.setAttribute("tmp.vnfInfo.vm[0].vnfc-count", "1");
+ RestExecutor restExe = new RestExecutor();
+ Transaction transaction = new Transaction();
+
+ FlowControlNode node = new FlowControlNode();
+ Map<String, String> flowSeq = restExe.execute(transaction, ctx);
+ String flowSequnce = flowSeq.get("restResponse");
+
}
- }
-
- @Ignore("missing asserts")
- @Test(expected = Exception.class)
- public void testInputParamsRestServiceNode() throws Exception {
- SvcLogicContext ctx = new SvcLogicContext();
- ctx.setAttribute("vnf-id", "test");
- ctx.setAttribute("tmp.vnfInfo.vm-count", "1");
- ctx.setAttribute("tmp.vnfInfo.vm[0].vnfc-count", "1");
- RestExecutor restExe = new RestExecutor();
- Transaction transaction = new Transaction();
-
- FlowControlNode node = new FlowControlNode();
- Map<String, String> flowSeq = restExe.execute(transaction, ctx);
- String flowSequnce = flowSeq.get("restResponse");
-
- }
}
diff --git a/appc-config/appc-flow-controller/provider/src/test/resources/appc_southbound.properties b/appc-config/appc-flow-controller/provider/src/test/resources/appc_southbound.properties
new file mode 100644
index 000000000..9b2ce827c
--- /dev/null
+++ b/appc-config/appc-flow-controller/provider/src/test/resources/appc_southbound.properties
@@ -0,0 +1,28 @@
+###
+# ============LICENSE_START=======================================================
+# ONAP : APP-C
+# ================================================================================
+# Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+# ================================================================================
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# ============LICENSE_END=========================================================
+###
+
+# test properties used by RestServiceNode
+
+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 \ No newline at end of file