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