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 org.junit.Test;
26 import org.onap.appc.flow.controller.data.Transaction;
27 import org.onap.appc.flow.controller.executorImpl.RestExecutor;
28 import org.onap.appc.flow.controller.node.FlowControlNode;
29 import org.onap.appc.flow.controller.node.RestServiceNode;
30 import org.onap.appc.flow.controller.utils.FlowControllerConstants;
31 import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
33 import java.util.HashMap;
36 public class TestRestServiceNode {
38 @Test(expected=Exception.class)
39 public void testRestServiceNode() throws Exception {
41 SvcLogicContext ctx = new SvcLogicContext();
42 ctx.setAttribute(FlowControllerConstants.VNF_TYPE, "vUSP - vDBE-IPX HUB");
43 ctx.setAttribute(FlowControllerConstants.REQUEST_ACTION, "healthcheck");
44 ctx.setAttribute(FlowControllerConstants.VNFC_TYPE, "TESTVNFC-CF");
45 ctx.setAttribute(FlowControllerConstants.REQUEST_ID,"TESTCOMMONFRMWK");
46 ctx.setAttribute("host-ip-address","127.0.0.1");
47 ctx.setAttribute("port-number","8888");
48 ctx.setAttribute("request-action-type","GET");
49 ctx.setAttribute("context", "loader/restconf/operations/appc-provider-lcm:health-check");
51 HashMap<String, String> inParams = new HashMap<String, String>();
52 RestServiceNode rsn = new RestServiceNode();
53 inParams.put("output-state", "state");
54 inParams.put("responsePrefix", "healthcheck");
55 rsn.sendRequest(inParams, ctx);
57 for (Object key : ctx.getAttributeKeySet()) {
58 String parmName = (String) key;
59 String parmValue = ctx.getAttribute(parmName);
66 @Test(expected=Exception.class)
67 public void testInputParamsRestServiceNode() throws Exception {
68 SvcLogicContext ctx = new SvcLogicContext();
69 ctx.setAttribute("vnf-id", "test");
70 ctx.setAttribute("tmp.vnfInfo.vm-count", "1");
71 ctx.setAttribute("tmp.vnfInfo.vm[0].vnfc-count", "1");
72 RestExecutor restExe = new RestExecutor();
73 Transaction transaction = new Transaction();
75 FlowControlNode node = new FlowControlNode();
76 Map<String,String> flowSeq= restExe.execute(transaction, ctx);
77 String flowSequnce=flowSeq.get("restResponse");