3 * ============LICENSE_START=======================================================
5 * ================================================================================
6 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
7 * =============================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
20 * ECOMP is a trademark and service mark of AT&T Intellectual Property.
21 * ============LICENSE_END=========================================================
23 package org.onap.appc.flow.executor.node;
25 import java.io.InputStream;
26 import java.util.Enumeration;
27 import java.util.HashMap;
28 import java.util.Properties;
30 import org.junit.Before;
31 import org.junit.Test;
32 import org.onap.appc.flow.controller.data.Transaction;
33 import org.onap.appc.flow.controller.executorImpl.RestExecutor;
34 import org.onap.appc.flow.controller.interfaceData.ActionIdentifier;
35 import org.onap.appc.flow.controller.interfaceData.InventoryInfo;
36 import org.onap.appc.flow.controller.interfaceData.RequestInfo;
37 import org.onap.appc.flow.controller.interfaceData.Vm;
38 import org.onap.appc.flow.controller.interfaceData.VnfInfo;
39 import org.onap.appc.flow.controller.interfaceData.Vnfcslist;
40 import org.onap.appc.flow.controller.node.FlowControlNode;
41 import org.onap.appc.flow.controller.node.RestServiceNode;
42 import org.onap.appc.flow.controller.utils.FlowControllerConstants;
43 import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
45 public class TestRestServiceNode {
47 @Test(expected=Exception.class)
48 public void testRestServiceNode() throws Exception {
50 SvcLogicContext ctx = new SvcLogicContext();
51 ctx.setAttribute(FlowControllerConstants.VNF_TYPE, "vUSP - vDBE-IPX HUB");
52 ctx.setAttribute(FlowControllerConstants.REQUEST_ACTION, "healthcheck");
53 ctx.setAttribute(FlowControllerConstants.VNFC_TYPE, "TESTVNFC-CF");
54 ctx.setAttribute(FlowControllerConstants.REQUEST_ID,"TESTCOMMONFRMWK");
55 ctx.setAttribute("host-ip-address","127.0.0.1");
56 ctx.setAttribute("port-number","8888");
57 ctx.setAttribute("request-action-type","GET");
58 ctx.setAttribute("context", "loader/restconf/operations/appc-provider-lcm:health-check");
60 HashMap<String, String> inParams = new HashMap<String, String>();
61 RestServiceNode rsn = new RestServiceNode();
62 inParams.put("output-state", "state");
63 inParams.put("responsePrefix", "healthcheck");
64 rsn.sendRequest(inParams, ctx);
66 for (Object key : ctx.getAttributeKeySet()) {
67 String parmName = (String) key;
68 String parmValue = ctx.getAttribute(parmName);
75 @Test(expected=Exception.class)
76 public void testInputParamsRestServiceNode() throws Exception {
77 SvcLogicContext ctx = new SvcLogicContext();
78 ctx.setAttribute("vnf-id", "test");
79 ctx.setAttribute("tmp.vnfInfo.vm-count", "1");
80 ctx.setAttribute("tmp.vnfInfo.vm[0].vnfc-count", "1");
81 RestExecutor restExe = new RestExecutor();
82 Transaction transaction = new Transaction();
84 FlowControlNode node = new FlowControlNode();
85 HashMap<String,String>flowSeq= restExe.execute(transaction, ctx);
86 String flowSequnce=flowSeq.get("restResponse");