Second part of onap rename
[appc.git] / appc-config / appc-flow-controller / provider / src / test / java / org / onap / 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.onap.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.Ignore;\r
41 import org.junit.Test;\r
42 import org.mockito.Mock;\r
43 import org.mockito.Mockito;\r
44 import org.onap.appc.flow.controller.data.Transaction;\r
45 import org.onap.appc.flow.controller.data.Transactions;\r
46 import org.onap.appc.flow.controller.dbervices.FlowControlDBService;\r
47 import org.onap.appc.flow.controller.node.FlowControlNode;\r
48 import org.onap.appc.flow.controller.utils.FlowControllerConstants;\r
49 import org.onap.ccsdk.sli.core.sli.SvcLogicContext;\r
50 import org.onap.ccsdk.sli.core.sli.SvcLogicException;\r
51 import org.powermock.api.mockito.PowerMockito;\r
52 import org.powermock.reflect.Whitebox;\r
53 \r
54 public class FlowControlNodeTest {\r
55         @Mock\r
56         FlowControlDBService dbservice = FlowControlDBService.initialise();\r
57         @Mock\r
58         FlowControlNode f = new FlowControlNode();\r
59         \r
60         Properties props = new Properties();\r
61         private static final String SDNC_CONFIG_DIR_VAR = "SDNC_CONFIG_DIR";\r
62         @Before\r
63         public void setUp() throws Exception \r
64 \r
65         {\r
66                 FlowControlDBService dbservice = FlowControlDBService.initialise();\r
67         }\r
68         @Ignore("Test is taking 60 seconds")\r
69         @Test(expected=Exception.class)\r
70         public final void testProcessFlow() throws Exception {\r
71                 SvcLogicContext  ctx = new SvcLogicContext();\r
72                 \r
73                 ctx.setAttribute("request-id","test");\r
74                 ctx.setAttribute("vnf-type","test");\r
75                 ctx.setAttribute("action-level","HealthCheck");\r
76                                 ctx.setAttribute("request-action","HealthCheck");\r
77                                 ctx.setAttribute("response-prefix","response-prefix");\r
78                 \r
79                 Map<String, String> inParams = new HashMap<String, String>();\r
80                 inParams.put("responsePrefix", "responsePrefix");\r
81                 \r
82 \r
83                 Whitebox.invokeMethod(f, "processFlow",inParams, ctx);\r
84                 /*Properties props = new Properties();\r
85                 PowerMockito.spy(FlowControlNode.class);\r
86               Transactions trans =null;\r
87               HashMap<Integer, Transaction> transactionMap = null;\r
88                  String  artifact_content="{‘PlaybookName’:’service_start’,‘EnvParameters’:{‘vnf_instance’:’$vnf_instance’},’Timeout’:600}";\r
89                         String capabilitiesData = "SUCCESS";\r
90               System.out.println("End Test when");*/\r
91               \r
92               \r
93         }\r
94         @Test \r
95         public void testgetInventoryInfo() throws Exception \r
96         {\r
97                 SvcLogicContext  ctx = new SvcLogicContext();\r
98                  String  vnfid = "test";\r
99               ctx.setAttribute( " tmp.vnfInfo.vnf.vnf-name","test");\r
100               ctx.setAttribute("tmp.vnfInfo.vm-count", "0");\r
101               ctx.setAttribute( " tmp.vnfInfo.vnf.vnf-type","test");\r
102               ctx.setAttribute( "tmp.vnfInfo.vm[0 ].vserverId","test" );\r
103               ctx.setAttribute( "tmp.vnfInfo.vm[0 ].vnfc-name","test" );\r
104               ctx.setAttribute( "tmp.vnfInfo.vm[0].vnfc-type","test" );\r
105               ctx.setAttribute( " tmp.vnfInfo.vm[0].vnfc-count","1");\r
106              \r
107                 Whitebox.invokeMethod(f, "getInventoryInfo", ctx, vnfid);\r
108                 \r
109         }\r
110         @Ignore("Test is taking 60 seconds")\r
111         @Test(expected=Exception.class)\r
112         public void testprocessFlowSequence() throws Exception \r
113         {\r
114                 Map<String, String> inparams = new HashMap<String,String>();\r
115                 SvcLogicContext  ctx = new SvcLogicContext();\r
116               ctx.setAttribute( " SEQUENCE-TYPE","test");\r
117               ctx.setAttribute("flow-sequence", "1");\r
118               ctx.setAttribute( "DesignTime","test");\r
119               ctx.setAttribute( "vnf-type","test" );\r
120              \r
121                 Whitebox.invokeMethod(f, "processFlowSequence",inparams, ctx, ctx);\r
122                 \r
123         }\r
124         @Test\r
125         public void testexeuteAllTransaction() throws Exception \r
126         {\r
127                 Map<Integer, Transaction> transactionMap = new HashMap<Integer,Transaction>();\r
128                 SvcLogicContext  ctx = new SvcLogicContext();\r
129                 Whitebox.invokeMethod(f, "exeuteAllTransaction",transactionMap, ctx);\r
130                 \r
131         }\r
132         @Test\r
133         public void testexeutepreProcessor() throws Exception \r
134         {\r
135         Map<Integer, Transaction> transactionMap = new HashMap<Integer,Transaction>();\r
136         Transaction transaction = new Transaction();\r
137         Whitebox.invokeMethod(f, "preProcessor",transactionMap, transaction);\r
138         \r
139         }\r
140                 @Test(expected=Exception.class)\r
141         public void testcollectInputParams() throws Exception \r
142         {\r
143         SvcLogicContext  ctx = new SvcLogicContext();\r
144 \r
145         Transaction transaction = new Transaction();\r
146         Whitebox.invokeMethod(f, "collectInputParams",ctx, transaction);\r
147         \r
148         }\r
149         @Ignore("Test is taking 60 seconds")\r
150         @Test(expected=Exception.class)\r
151         public void testgetDependencyInfo() throws Exception\r
152         {\r
153                 SvcLogicContext  ctx = new SvcLogicContext();\r
154                 Whitebox.invokeMethod(f, "getDependencyInfo",ctx);\r
155                 \r
156         }\r
157         public void testgetCapabilitesDatass() throws Exception\r
158         {\r
159                 SvcLogicContext  ctx = new SvcLogicContext();\r
160                 Whitebox.invokeMethod(f, "getDependencyInfo",ctx);\r
161                 \r
162         }\r
163         \r
164         \r
165 }\r