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.Matchers.any;
28 import static org.mockito.Matchers.anyBoolean;
29 import static org.mockito.Matchers.anyString;
33 import org.junit.Assert;
34 import org.junit.Before;
35 import org.junit.Ignore;
36 import org.junit.Test;
37 import org.junit.runner.RunWith;
38 import org.mockito.Mock;
39 import org.onap.appc.flow.controller.data.Transaction;
40 import org.onap.appc.flow.controller.dbervices.FlowControlDBService;
41 import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
42 import org.onap.ccsdk.sli.core.sli.SvcLogicException;
43 import org.onap.ccsdk.sli.core.sli.SvcLogicResource;
44 import org.onap.ccsdk.sli.core.sli.SvcLogicResource.QueryStatus;
45 import org.onap.ccsdk.sli.core.dblib.DbLibService;
46 import org.onap.ccsdk.sli.adaptors.resource.sql.SqlResource;
47 import org.powermock.api.mockito.PowerMockito;
48 import org.powermock.core.classloader.annotations.PrepareForTest;
49 import org.powermock.modules.junit4.PowerMockRunner;
50 import org.powermock.reflect.Whitebox;
51 import org.powermock.modules.junit4.PowerMockRunner;
53 @PrepareForTest({ SqlResource.class, SvcLogicResource.class })
54 @RunWith(PowerMockRunner.class)
55 public class FlowControlDBServiceTest {
58 SvcLogicResource serviceLogic;
62 QueryStatus dblibSvc ;
64 private static FlowControlDBService dgGeneralDBService = FlowControlDBService.initialise();
66 private Transaction transaction;;
69 public void setUp() throws Exception {
70 serviceLogic = new SqlResource();
74 /*public final void testGetFlowReferenceData() throws Exception {
76 SvcLogicContext localContext = new SvcLogicContext();
77 FlowControlDBService dgGeneralDBService = FlowControlDBService.initialise();
78 PowerMockito.spy(SqlResource.class);
80 Map<String, String> inParams = null;
81 //PowerMockito.doReturn(dblibSvc).when(SqlResource.class, "query");
82 Whitebox.invokeMethod(SqlResource.class, "query",anyString(), anyBoolean(), anyString(), anyString(), anyString(), anyString(), any(SvcLogicContext.class));
84 dgGeneralDBService.getFlowReferenceData(localContext, inParams, localContext);
85 //Assert.assertEquals("SUCCESS", status);
86 //Assert.assertNotEquals("Error - while getting FlowReferenceData", "FAILURE", status);
90 @Test(expected=Exception.class)
91 public final void testGetFlowReferenceData() throws Exception {
93 SvcLogicContext localContext = new SvcLogicContext();
94 FlowControlDBService dgGeneralDBService = FlowControlDBService.initialise();
95 PowerMockito.spy(FlowControlDBService.class);
98 PowerMockito.doReturn(dgGeneralDBService).when(SqlResource.class, "query");
99 String status = dgGeneralDBService.getDesignTimeFlowModel(localContext);
100 Assert.assertEquals("SUCCESS", status);
101 Assert.assertNotEquals("Error - while getting FlowReferenceData", "FAILURE", status);
106 @Ignore("Test is taking 60 seconds")
107 @Test(expected=Exception.class)
108 public final void testGetDesignTimeFlowModel() throws Exception {
109 SvcLogicContext localContext = new SvcLogicContext();
110 String status = dgGeneralDBService.getDesignTimeFlowModel(localContext) ;
111 Assert.assertEquals("SUCCESS", status);
112 Assert.assertNotEquals("Error - while getting FlowReferenceData", "FAILURE", status);
119 @Ignore("Test is taking 60 seconds")
120 @Test(expected=Exception.class)
121 public final void testLoadSequenceIntoDB() throws SvcLogicException {
124 SvcLogicContext localContext = new SvcLogicContext();
125 QueryStatus status = dgGeneralDBService.loadSequenceIntoDB(localContext) ;
126 Assert.assertEquals("SUCCESS", status);
127 Assert.assertNotEquals("Error - while getting FlowReferenceData", "FAILURE", status);
128 /*SvcLogicContext ctx = new SvcLogicContext();
130 if (serviceLogic != null && localContext != null) {
131 String queryString = "INSERT INTO " + FlowControllerConstants.DB_REQUEST_ARTIFACTS
132 + " set request_id = ' kusuma_test' , action = 'Configure', action_level = 'VNF' , vnf_type = 'vComp' , category = 'config_Template' , artifact_content = '', updated_date = sysdate() ";
133 Mockito.when(serviceLogic.save("SQL", false, false, queryString, null, null, localContext))
135 Assert.assertEquals("SUCCESS", status);
136 Assert.assertNotEquals("Error - while getting FlowReferenceData", "FAILURE", status);*/
143 @Test(expected=Exception.class)
144 public final void testPopulateModuleAndRPC() throws Exception {
145 SvcLogicContext localContext = new SvcLogicContext();
146 SvcLogicContext ctx = new SvcLogicContext();
147 String vnf_type = "test";
148 dgGeneralDBService.populateModuleAndRPC(transaction, vnf_type);;
153 @Ignore("Test is taking 60 seconds")
154 @Test(expected=Exception.class)
155 public final void testGetDependencyInfo() throws SvcLogicException {
156 SvcLogicContext localContext = new SvcLogicContext();
157 String status = dgGeneralDBService.getDependencyInfo(localContext);
158 Assert.assertEquals("SUCCESS", status);
159 Assert.assertNotEquals("Error - while getting FlowReferenceData", "FAILURE", status);
163 @Ignore("Test is taking 60 seconds")
164 @Test(expected=Exception.class)
165 public final void testGetCapabilitiesData() throws SvcLogicException {
166 SvcLogicContext localContext = new SvcLogicContext();
167 String status = dgGeneralDBService.getCapabilitiesData(localContext);
168 Assert.assertEquals("SUCCESS", status);
169 Assert.assertNotEquals("Error - while getting FlowReferenceData", "FAILURE", status);