1 package org.openecomp.appc.flow.executor.node;
\r
3 import static org.mockito.Matchers.any;
\r
4 import static org.mockito.Matchers.anyBoolean;
\r
5 import static org.mockito.Matchers.anyString;
\r
7 import java.util.Map;
\r
9 import org.junit.Assert;
\r
10 import org.junit.Before;
\r
11 import org.junit.Test;
\r
12 import org.junit.runner.RunWith;
\r
13 import org.mockito.Mock;
\r
14 import org.openecomp.appc.flow.controller.data.Transaction;
\r
15 import org.openecomp.appc.flow.controller.dbervices.FlowControlDBService;
\r
16 import org.openecomp.sdnc.sli.SvcLogicContext;
\r
17 import org.openecomp.sdnc.sli.SvcLogicException;
\r
18 import org.openecomp.sdnc.sli.SvcLogicResource;
\r
19 import org.openecomp.sdnc.sli.SvcLogicResource.QueryStatus;
\r
20 import org.openecomp.sdnc.sli.resource.dblib.DbLibService;
\r
21 import org.openecomp.sdnc.sli.resource.sql.SqlResource;
\r
22 import org.powermock.api.mockito.PowerMockito;
\r
23 import org.powermock.core.classloader.annotations.PrepareForTest;
\r
24 import org.powermock.modules.junit4.PowerMockRunner;
\r
25 import org.powermock.reflect.Whitebox;
\r
26 import org.powermock.modules.junit4.PowerMockRunner;
\r
28 @PrepareForTest({ SqlResource.class, SvcLogicResource.class })
\r
29 @RunWith(PowerMockRunner.class)
\r
30 public class FlowControlDBServiceTest {
\r
33 SvcLogicResource serviceLogic;
\r
37 QueryStatus dblibSvc ;
\r
39 private static FlowControlDBService dgGeneralDBService = FlowControlDBService.initialise();
\r
41 private Transaction transaction;;
\r
44 public void setUp() throws Exception {
\r
45 serviceLogic = new SqlResource();
\r
49 /*public final void testGetFlowReferenceData() throws Exception {
\r
51 SvcLogicContext localContext = new SvcLogicContext();
\r
52 FlowControlDBService dgGeneralDBService = FlowControlDBService.initialise();
\r
53 PowerMockito.spy(SqlResource.class);
\r
55 Map<String, String> inParams = null;
\r
56 //PowerMockito.doReturn(dblibSvc).when(SqlResource.class, "query");
\r
57 Whitebox.invokeMethod(SqlResource.class, "query",anyString(), anyBoolean(), anyString(), anyString(), anyString(), anyString(), any(SvcLogicContext.class));
\r
59 dgGeneralDBService.getFlowReferenceData(localContext, inParams, localContext);
\r
60 //Assert.assertEquals("SUCCESS", status);
\r
61 //Assert.assertNotEquals("Error - while getting FlowReferenceData", "FAILURE", status);
\r
65 @Test(expected=Exception.class)
\r
66 public final void testGetFlowReferenceData() throws Exception {
\r
68 SvcLogicContext localContext = new SvcLogicContext();
\r
69 FlowControlDBService dgGeneralDBService = FlowControlDBService.initialise();
\r
70 PowerMockito.spy(FlowControlDBService.class);
\r
73 PowerMockito.doReturn(dgGeneralDBService).when(SqlResource.class, "query");
\r
74 String status = dgGeneralDBService.getDesignTimeFlowModel(localContext);
\r
75 Assert.assertEquals("SUCCESS", status);
\r
76 Assert.assertNotEquals("Error - while getting FlowReferenceData", "FAILURE", status);
\r
81 @Test(expected=Exception.class)
\r
82 public final void testGetDesignTimeFlowModel() throws Exception {
\r
83 SvcLogicContext localContext = new SvcLogicContext();
\r
84 String status = dgGeneralDBService.getDesignTimeFlowModel(localContext) ;
\r
85 Assert.assertEquals("SUCCESS", status);
\r
86 Assert.assertNotEquals("Error - while getting FlowReferenceData", "FAILURE", status);
\r
93 @Test(expected=Exception.class)
\r
94 public final void testLoadSequenceIntoDB() throws SvcLogicException {
\r
97 SvcLogicContext localContext = new SvcLogicContext();
\r
98 QueryStatus status = dgGeneralDBService.loadSequenceIntoDB(localContext) ;
\r
99 Assert.assertEquals("SUCCESS", status);
\r
100 Assert.assertNotEquals("Error - while getting FlowReferenceData", "FAILURE", status);
\r
101 /*SvcLogicContext ctx = new SvcLogicContext();
\r
103 if (serviceLogic != null && localContext != null) {
\r
104 String queryString = "INSERT INTO " + FlowControllerConstants.DB_REQUEST_ARTIFACTS
\r
105 + " set request_id = ' kusuma_test' , action = 'Configure', action_level = 'VNF' , vnf_type = 'vComp' , category = 'config_Template' , artifact_content = '', updated_date = sysdate() ";
\r
106 Mockito.when(serviceLogic.save("SQL", false, false, queryString, null, null, localContext))
\r
107 .thenReturn(status);
\r
108 Assert.assertEquals("SUCCESS", status);
\r
109 Assert.assertNotEquals("Error - while getting FlowReferenceData", "FAILURE", status);*/
\r
115 @Test(expected=Exception.class)
\r
116 public final void testPopulateModuleAndRPC() throws SvcLogicException {
\r
117 SvcLogicContext localContext = new SvcLogicContext();
\r
118 SvcLogicContext ctx = new SvcLogicContext();
\r
119 String vnf_type = "test";
\r
120 dgGeneralDBService.populateModuleAndRPC(transaction, vnf_type);;
\r
125 @Test(expected=Exception.class)
\r
126 public final void testGetDependencyInfo() throws SvcLogicException {
\r
127 SvcLogicContext localContext = new SvcLogicContext();
\r
128 String status = dgGeneralDBService.getDependencyInfo(localContext);
\r
129 Assert.assertEquals("SUCCESS", status);
\r
130 Assert.assertNotEquals("Error - while getting FlowReferenceData", "FAILURE", status);
\r
134 @Test(expected=Exception.class)
\r
135 public final void testGetCapabilitiesData() throws SvcLogicException {
\r
136 SvcLogicContext localContext = new SvcLogicContext();
\r
137 String status = dgGeneralDBService.getCapabilitiesData(localContext);
\r
138 Assert.assertEquals("SUCCESS", status);
\r
139 Assert.assertNotEquals("Error - while getting FlowReferenceData", "FAILURE", status);
\r