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