Improve coverage FlowControlNode #6
[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   @Ignore("Test is taking 60 seconds")
95   @Test(expected=Exception.class)
96   public void testprocessFlowSequence() throws Exception
97   {
98     Map<String, String> inparams = new HashMap<String,String>();
99     SvcLogicContext  ctx = new SvcLogicContext();
100     ctx.setAttribute( " SEQUENCE-TYPE","test");
101     ctx.setAttribute("flow-sequence", "1");
102     ctx.setAttribute( "DesignTime","test");
103     ctx.setAttribute( "vnf-type","test" );
104
105     Whitebox.invokeMethod(f, "processFlowSequence",inparams, ctx, ctx);
106
107   }
108   @Test
109   public void testexeuteAllTransaction() throws Exception
110   {
111     Map<Integer, Transaction> transactionMap = new HashMap<Integer,Transaction>();
112     SvcLogicContext  ctx = new SvcLogicContext();
113     Whitebox.invokeMethod(f, "executeAllTransaction",transactionMap, ctx);
114
115   }
116   @Test
117   public void testexeutepreProcessor() throws Exception
118   {
119     Map<Integer, Transaction> transactionMap = new HashMap<Integer,Transaction>();
120     Transaction transaction = new Transaction();
121     Whitebox.invokeMethod(f, "preProcessor",transactionMap, transaction);
122
123   }
124   @Test(expected=Exception.class)
125   public void testcollectInputParams() throws Exception
126   {
127     SvcLogicContext  ctx = new SvcLogicContext();
128
129     Transaction transaction = new Transaction();
130     Whitebox.invokeMethod(f, "collectInputParams",ctx, transaction);
131
132   }
133   @Ignore("Test is taking 60 seconds")
134   @Test(expected=Exception.class)
135   public void testgetDependencyInfo() throws Exception
136   {
137     SvcLogicContext  ctx = new SvcLogicContext();
138     Whitebox.invokeMethod(f, "getDependencyInfo",ctx);
139
140   }
141   public void testgetCapabilitesDatass() throws Exception
142   {
143     SvcLogicContext  ctx = new SvcLogicContext();
144     Whitebox.invokeMethod(f, "getDependencyInfo",ctx);
145
146   }
147
148
149 }