6bb1cb2a422d466a695ca2d5df5c61c7312a30ea
[appc.git] / appc-config / appc-flow-controller / provider / src / test / java / org / openecomp / appc / flow / executor / node / FlowControlNodeTest.java
1 /*-\r
2  * ============LICENSE_START=======================================================\r
3  * ONAP : APPC\r
4  * ================================================================================\r
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.\r
6  * ================================================================================\r
7  * Copyright (C) 2017 Amdocs\r
8  * =============================================================================\r
9  * Licensed under the Apache License, Version 2.0 (the "License");\r
10  * you may not use this file except in compliance with the License.\r
11  * You may obtain a copy of the License at\r
12  *\r
13  *      http://www.apache.org/licenses/LICENSE-2.0\r
14  *\r
15  * Unless required by applicable law or agreed to in writing, software\r
16  * distributed under the License is distributed on an "AS IS" BASIS,\r
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
18  * See the License for the specific language governing permissions and\r
19  * limitations under the License.\r
20  *\r
21  * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
22  * ============LICENSE_END=========================================================\r
23  */\r
24 \r
25 package org.openecomp.appc.flow.executor.node;\r
26 \r
27 import static org.mockito.Mockito.doReturn;\r
28 import static org.mockito.Mockito.verify;\r
29 \r
30 import java.io.FileInputStream;\r
31 import java.io.InputStream;\r
32 import java.util.HashMap;\r
33 import java.util.Map;\r
34 import java.util.Properties;\r
35 \r
36 import org.junit.After;\r
37 import org.junit.AfterClass;\r
38 import org.junit.Before;\r
39 import org.junit.BeforeClass;\r
40 import org.junit.Test;\r
41 import org.mockito.Mock;\r
42 import org.mockito.Mockito;\r
43 import org.openecomp.appc.flow.controller.data.Transaction;\r
44 import org.openecomp.appc.flow.controller.data.Transactions;\r
45 import org.openecomp.appc.flow.controller.dbervices.FlowControlDBService;\r
46 import org.openecomp.appc.flow.controller.node.FlowControlNode;\r
47 import org.openecomp.appc.flow.controller.utils.FlowControllerConstants;\r
48 import org.onap.ccsdk.sli.core.sli.SvcLogicContext;\r
49 import org.onap.ccsdk.sli.core.sli.SvcLogicException;\r
50 import org.powermock.api.mockito.PowerMockito;\r
51 import org.powermock.reflect.Whitebox;\r
52 \r
53 public class FlowControlNodeTest {\r
54         @Mock\r
55         FlowControlDBService dbservice = FlowControlDBService.initialise();\r
56         @Mock\r
57         FlowControlNode f = new FlowControlNode();\r
58         \r
59         Properties props = new Properties();\r
60         private static final String SDNC_CONFIG_DIR_VAR = "SDNC_CONFIG_DIR";\r
61         @Before\r
62         public void setUp() throws Exception \r
63 \r
64         {\r
65                 FlowControlDBService dbservice = FlowControlDBService.initialise();\r
66         }\r
67         @Test(expected=Exception.class)\r
68         public final void testProcessFlow() throws Exception {\r
69                 SvcLogicContext  ctx = new SvcLogicContext();\r
70                 \r
71                 ctx.setAttribute("request-id","test");\r
72                 ctx.setAttribute("vnf-type","test");\r
73                 ctx.setAttribute("action-level","HealthCheck");\r
74                                 ctx.setAttribute("request-action","HealthCheck");\r
75                                 ctx.setAttribute("response-prefix","response-prefix");\r
76                 \r
77                 Map<String, String> inParams = new HashMap<String, String>();\r
78                 inParams.put("responsePrefix", "responsePrefix");\r
79                 \r
80 \r
81                 Whitebox.invokeMethod(f, "processFlow",inParams, ctx);\r
82                 /*Properties props = new Properties();\r
83                 PowerMockito.spy(FlowControlNode.class);\r
84               Transactions trans =null;\r
85               HashMap<Integer, Transaction> transactionMap = null;\r
86                  String  artifact_content="{‘PlaybookName’:’service_start’,‘EnvParameters’:{‘vnf_instance’:’$vnf_instance’},’Timeout’:600}";\r
87                         String capabilitiesData = "SUCCESS";\r
88               System.out.println("End Test when");*/\r
89               \r
90               \r
91         }\r
92         @Test \r
93         public void testgetInventoryInfo() throws Exception \r
94         {\r
95                 SvcLogicContext  ctx = new SvcLogicContext();\r
96                  String  vnfid = "test";\r
97               ctx.setAttribute( " tmp.vnfInfo.vnf.vnf-name","test");\r
98               ctx.setAttribute("tmp.vnfInfo.vm-count", "0");\r
99               ctx.setAttribute( " tmp.vnfInfo.vnf.vnf-type","test");\r
100               ctx.setAttribute( "tmp.vnfInfo.vm[0 ].vserverId","test" );\r
101               ctx.setAttribute( "tmp.vnfInfo.vm[0 ].vnfc-name","test" );\r
102               ctx.setAttribute( "tmp.vnfInfo.vm[0].vnfc-type","test" );\r
103               ctx.setAttribute( " tmp.vnfInfo.vm[0].vnfc-count","1");\r
104              \r
105                 Whitebox.invokeMethod(f, "getInventoryInfo", ctx, vnfid);\r
106                 \r
107         }\r
108                 @Test(expected=Exception.class)\r
109         public void testprocessFlowSequence() throws Exception \r
110         {\r
111                 Map<String, String> inparams = new HashMap<String,String>();\r
112                 SvcLogicContext  ctx = new SvcLogicContext();\r
113               ctx.setAttribute( " SEQUENCE-TYPE","test");\r
114               ctx.setAttribute("flow-sequence", "1");\r
115               ctx.setAttribute( "DesignTime","test");\r
116               ctx.setAttribute( "vnf-type","test" );\r
117              \r
118                 Whitebox.invokeMethod(f, "processFlowSequence",inparams, ctx, ctx);\r
119                 \r
120         }\r
121         @Test\r
122         public void testexeuteAllTransaction() throws Exception \r
123         {\r
124                 Map<Integer, Transaction> transactionMap = new HashMap<Integer,Transaction>();\r
125                 SvcLogicContext  ctx = new SvcLogicContext();\r
126                 Whitebox.invokeMethod(f, "exeuteAllTransaction",transactionMap, ctx);\r
127                 \r
128         }\r
129         @Test\r
130         public void testexeutepreProcessor() throws Exception \r
131         {\r
132         Map<Integer, Transaction> transactionMap = new HashMap<Integer,Transaction>();\r
133         Transaction transaction = new Transaction();\r
134         Whitebox.invokeMethod(f, "preProcessor",transactionMap, transaction);\r
135         \r
136         }\r
137                 @Test(expected=Exception.class)\r
138         public void testcollectInputParams() throws Exception \r
139         {\r
140         SvcLogicContext  ctx = new SvcLogicContext();\r
141 \r
142         Transaction transaction = new Transaction();\r
143         Whitebox.invokeMethod(f, "collectInputParams",ctx, transaction);\r
144         \r
145         }\r
146         @Test(expected=Exception.class)\r
147         public void testgetDependencyInfo() throws Exception\r
148         {\r
149                 SvcLogicContext  ctx = new SvcLogicContext();\r
150                 Whitebox.invokeMethod(f, "getDependencyInfo",ctx);\r
151                 \r
152         }\r
153         public void testgetCapabilitesDatass() throws Exception\r
154         {\r
155                 SvcLogicContext  ctx = new SvcLogicContext();\r
156                 Whitebox.invokeMethod(f, "getDependencyInfo",ctx);\r
157                 \r
158         }\r
159         \r
160         \r
161 }\r