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.onap.ccsdk.sli.core.sli.SvcLogicContext;
43 public class TestRestServiceNode {
45 @Test(expected=Exception.class)
46 public void testRestServiceNode() throws Exception {
48 SvcLogicContext ctx = new SvcLogicContext();
49 ctx.setAttribute(FlowControllerConstants.VNF_TYPE, "vUSP - vDBE-IPX HUB");
50 ctx.setAttribute(FlowControllerConstants.REQUEST_ACTION, "healthcheck");
51 ctx.setAttribute(FlowControllerConstants.VNFC_TYPE, "TESTVNFC-CF");
52 ctx.setAttribute(FlowControllerConstants.REQUEST_ID,"TESTCOMMONFRMWK");
53 ctx.setAttribute("host-ip-address","127.0.0.1");
54 ctx.setAttribute("port-number","8888");
55 ctx.setAttribute("request-action-type","GET");
56 ctx.setAttribute("context", "loader/restconf/operations/appc-provider-lcm:health-check");
58 HashMap<String, String> inParams = new HashMap<String, String>();
59 RestServiceNode rsn = new RestServiceNode();
60 inParams.put("output-state", "state");
61 inParams.put("responsePrefix", "healthcheck");
62 rsn.sendRequest(inParams, ctx);
64 for (Object key : ctx.getAttributeKeySet()) {
65 String parmName = (String) key;
66 String parmValue = ctx.getAttribute(parmName);
73 @Test(expected=Exception.class)
74 public void testInputParamsRestServiceNode() throws Exception {
75 SvcLogicContext ctx = new SvcLogicContext();
76 ctx.setAttribute("vnf-id", "test");
77 ctx.setAttribute("tmp.vnfInfo.vm-count", "1");
78 ctx.setAttribute("tmp.vnfInfo.vm[0].vnfc-count", "1");
79 RestExecutor restExe = new RestExecutor();
80 Transaction transaction = new Transaction();
82 FlowControlNode node = new FlowControlNode();
83 HashMap<String,String>flowSeq= restExe.execute(transaction, ctx);
84 String flowSequnce=flowSeq.get("restResponse");