DGXMLGenerator sonar fixes
[appc.git] / appc-config / appc-flow-controller / provider / src / test / java / org / onap / appc / flow / executor / node / TestRestServiceNode.java
1
2 /*-
3  * ============LICENSE_START=======================================================
4  * ONAP : APPC
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
11  *
12  *      http://www.apache.org/licenses/LICENSE-2.0
13  *
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.
19  *
20  * ECOMP is a trademark and service mark of AT&T Intellectual Property.
21  * ============LICENSE_END=========================================================
22  */
23 package org.onap.appc.flow.executor.node;
24
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;
32
33 import java.util.HashMap;
34 import java.util.Map;
35
36 public class TestRestServiceNode {
37
38     @Test(expected=Exception.class)
39     public void testRestServiceNode() throws Exception {
40
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");
50
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);
56
57         for (Object key : ctx.getAttributeKeySet()) {
58             String parmName = (String) key;
59             String parmValue = ctx.getAttribute(parmName);
60         }
61
62
63     }
64
65
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();
74
75         FlowControlNode node = new FlowControlNode();
76         Map<String,String> flowSeq= restExe.execute(transaction, ctx);
77         String flowSequnce=flowSeq.get("restResponse");
78
79     }
80 }