2 * ============LICENSE_START=======================================================
\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
13 * http://www.apache.org/licenses/LICENSE-2.0
\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
21 * ECOMP is a trademark and service mark of AT&T Intellectual Property.
\r
22 * ============LICENSE_END=========================================================
\r
25 package org.onap.appc.flow.executor.node;
\r
27 import static org.mockito.Mockito.doReturn;
\r
28 import static org.mockito.Mockito.verify;
\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
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
54 public class FlowControlNodeTest {
\r
56 FlowControlDBService dbservice = FlowControlDBService.initialise();
\r
58 FlowControlNode f = new FlowControlNode();
\r
60 Properties props = new Properties();
\r
61 private static final String SDNC_CONFIG_DIR_VAR = "SDNC_CONFIG_DIR";
\r
63 public void setUp() throws Exception
\r
66 FlowControlDBService dbservice = FlowControlDBService.initialise();
\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
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
79 Map<String, String> inParams = new HashMap<String, String>();
\r
80 inParams.put("responsePrefix", "responsePrefix");
\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
95 public void testgetInventoryInfo() throws Exception
\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
107 Whitebox.invokeMethod(f, "getInventoryInfo", ctx, vnfid);
\r
110 @Ignore("Test is taking 60 seconds")
\r
111 @Test(expected=Exception.class)
\r
112 public void testprocessFlowSequence() throws Exception
\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
121 Whitebox.invokeMethod(f, "processFlowSequence",inparams, ctx, ctx);
\r
125 public void testexeuteAllTransaction() throws Exception
\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
133 public void testexeutepreProcessor() throws Exception
\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
140 @Test(expected=Exception.class)
\r
141 public void testcollectInputParams() throws Exception
\r
143 SvcLogicContext ctx = new SvcLogicContext();
\r
145 Transaction transaction = new Transaction();
\r
146 Whitebox.invokeMethod(f, "collectInputParams",ctx, transaction);
\r
149 @Ignore("Test is taking 60 seconds")
\r
150 @Test(expected=Exception.class)
\r
151 public void testgetDependencyInfo() throws Exception
\r
153 SvcLogicContext ctx = new SvcLogicContext();
\r
154 Whitebox.invokeMethod(f, "getDependencyInfo",ctx);
\r
157 public void testgetCapabilitesDatass() throws Exception
\r
159 SvcLogicContext ctx = new SvcLogicContext();
\r
160 Whitebox.invokeMethod(f, "getDependencyInfo",ctx);
\r