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