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