2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.openecomp.appc.flow.executor.node;
23 import java.io.InputStream;
24 import java.util.Enumeration;
25 import java.util.HashMap;
26 import java.util.Properties;
28 import org.junit.Before;
29 import org.junit.Test;
30 import org.openecomp.appc.flow.controller.data.Transaction;
31 import org.openecomp.appc.flow.controller.executorImpl.RestExecutor;
32 import org.openecomp.appc.flow.controller.interfaceData.ActionIdentifier;
33 import org.openecomp.appc.flow.controller.interfaceData.InventoryInfo;
34 import org.openecomp.appc.flow.controller.interfaceData.RequestInfo;
35 import org.openecomp.appc.flow.controller.interfaceData.Vm;
36 import org.openecomp.appc.flow.controller.interfaceData.VnfInfo;
37 import org.openecomp.appc.flow.controller.interfaceData.Vnfcslist;
38 import org.openecomp.appc.flow.controller.node.FlowControlNode;
39 import org.openecomp.appc.flow.controller.node.RestServiceNode;
40 import org.openecomp.appc.flow.controller.utils.FlowControllerConstants;
41 import org.openecomp.sdnc.sli.SvcLogicContext;
43 public class TestRestServiceNode {
47 Properties props = new Properties();
48 InputStream propStr = getClass().getResourceAsStream("/svclogic.properties");
49 if (propStr == null) {
50 System.err.println("src/test/resources/svclogic.properties missing");
53 System.out.println("Got Properties");
56 } catch (Exception e) {
58 System.err.println("Could not initialize properties");
60 // Add properties to global properties
62 Enumeration propNames = props.keys();
64 while (propNames.hasMoreElements()) {
66 String propName = (String) propNames.nextElement();
67 System.setProperty(propName, props.getProperty(propName));
68 System.out.println("propName" + propName + " Value: " + props.getProperty(propName));
76 public void testRestServiceNode() throws Exception {
78 SvcLogicContext ctx = new SvcLogicContext();
79 ctx.setAttribute(FlowControllerConstants.VNF_TYPE, "vUSP - vDBE-IPX HUB");
80 ctx.setAttribute(FlowControllerConstants.REQUEST_ACTION, "healthcheck");
81 ctx.setAttribute(FlowControllerConstants.VNFC_TYPE, "TESTVNFC-CF");
82 ctx.setAttribute(FlowControllerConstants.REQUEST_ID,"TESTCOMMONFRMWK");
83 ctx.setAttribute("host-ip-address","127.0.0.1");
84 ctx.setAttribute("port-number","8888");
85 ctx.setAttribute("request-action-type","GET");
86 ctx.setAttribute("context", "loader/restconf/operations/appc-provider-lcm:health-check");
88 HashMap<String, String> inParams = new HashMap<String, String>();
89 RestServiceNode rsn = new RestServiceNode();
90 inParams.put("output-state", "state");
91 inParams.put("responsePrefix", "healthcheck");
92 rsn.sendRequest(inParams, ctx);
94 for (Object key : ctx.getAttributeKeySet()) {
95 String parmName = (String) key;
96 String parmValue = ctx.getAttribute(parmName);
97 System.out.println(parmName + "=" + parmValue);
105 public void testInputParamsRestServiceNode() throws Exception {
106 SvcLogicContext ctx = new SvcLogicContext();
107 ctx.setAttribute("vnf-id", "test");
108 ctx.setAttribute("tmp.vnfInfo.vm-count", "1");
109 ctx.setAttribute("tmp.vnfInfo.vm[0].vnfc-count", "1");
110 RestExecutor restExe = new RestExecutor();
111 Transaction transaction = new Transaction();
113 FlowControlNode node = new FlowControlNode();
114 //String output =node.collectInputParams(ctx, transaction);
116 // Properties props = new Properties();
117 // props.setProperty("SEQ_GENERATOR_URL", "test");
118 //System.out.println(output);
119 //transaction.setExecutionEndPoint(resourceUri);
120 HashMap<String,String>flowSeq= restExe.execute(transaction, ctx);
121 String flowSequnce=flowSeq.get("restResponse");
122 System.out.println(flowSequnce);