summaryrefslogtreecommitdiffstats
path: root/appc-config/appc-flow-controller/provider/src/test
diff options
context:
space:
mode:
authorPatrick Brady <patrick.brady@att.com>2019-07-23 11:54:01 -0700
committerPatrick Brady <patrick.brady@att.com>2019-07-24 21:55:12 +0000
commitb14db107c5dd7eadbfecde037ad68633775502de (patch)
treec77ca884a2710af459ca90e295d812ee5630c7d6 /appc-config/appc-flow-controller/provider/src/test
parente0bdc35d8428a574c6decc6075b8d8ef98f05d5f (diff)
Prepared statements for DG services
Convert sql queries to prepared statements in other parts of appc. Change-Id: If29225394de2ab286e4f2f7bdd17f6af6b286576 Signed-off-by: Patrick Brady <patrick.brady@att.com> Issue-ID: OJSI-25
Diffstat (limited to 'appc-config/appc-flow-controller/provider/src/test')
-rw-r--r--appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/controller/dbervices/FlowControlDBServiceTest.java113
-rw-r--r--appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/executor/node/FlowControlDBServiceTest.java221
-rw-r--r--appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/executor/node/MockDBService.java4
-rw-r--r--appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/executor/node/MockDbLibServiceQueries.java (renamed from appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/executor/node/MockSvcLogicResource.java)44
4 files changed, 89 insertions, 293 deletions
diff --git a/appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/controller/dbervices/FlowControlDBServiceTest.java b/appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/controller/dbervices/FlowControlDBServiceTest.java
index 25c8ee500..093af6e91 100644
--- a/appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/controller/dbervices/FlowControlDBServiceTest.java
+++ b/appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/controller/dbervices/FlowControlDBServiceTest.java
@@ -22,6 +22,9 @@
package org.onap.appc.flow.controller.dbervices;
import static org.junit.Assert.assertNull;
+
+import java.util.ArrayList;
+
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
@@ -29,13 +32,15 @@ import org.mockito.Mockito;
import org.onap.appc.flow.controller.data.Transaction;
import org.onap.appc.flow.controller.utils.FlowControllerConstants;
import org.onap.ccsdk.sli.adaptors.resource.sql.SqlResource;
+import org.onap.ccsdk.sli.core.dblib.DbLibService;
import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
import org.onap.ccsdk.sli.core.sli.SvcLogicException;
import org.onap.ccsdk.sli.core.sli.SvcLogicResource.QueryStatus;
public class FlowControlDBServiceTest {
- private SqlResource sqlResource = Mockito.mock(SqlResource.class);
+ //private DbLibService dbLibService = Mockito.mock(DbLibService.class);
+ private DbLibServiceQueries dblib = Mockito.mock(DbLibServiceQueries.class);
private FlowControlDBService dbService;
@Rule
@@ -43,12 +48,11 @@ public class FlowControlDBServiceTest {
@Test
public void testGetFlowReferenceData() throws SvcLogicException {
- dbService = new FlowControlDBService(sqlResource);
+ dbService = new FlowControlDBService(dblib);
SvcLogicContext ctx = new SvcLogicContext();
ctx.setAttribute(FlowControllerConstants.ACTION_LEVEL, "action_level");
- Mockito.when(sqlResource.query(Mockito.anyString(), Mockito.anyBoolean(), Mockito.anyString(),
- Mockito.anyString(), Mockito.anyString(), Mockito.anyString(),
- Mockito.any(SvcLogicContext.class))).thenReturn(QueryStatus.FAILURE);
+ Mockito.when(dblib.query(Mockito.anyString(), Mockito.any(SvcLogicContext.class)))
+ .thenReturn(QueryStatus.FAILURE);
expectedEx.expect(SvcLogicException.class);
expectedEx.expectMessage(FlowControlDBService.GET_FLOW_REF_DATA_ERROR);
dbService.getFlowReferenceData(ctx, null, new SvcLogicContext());
@@ -56,18 +60,17 @@ public class FlowControlDBServiceTest {
@Test
public void testGetEndpointByAction() {
- dbService = new FlowControlDBService(sqlResource);
+ dbService = new FlowControlDBService(dblib);
assertNull(dbService.getEndPointByAction(null));
}
@Test
public void testGetDesignTimeFlowModelFirstQueryException() throws SvcLogicException {
- dbService = new FlowControlDBService(sqlResource);
+ dbService = new FlowControlDBService(dblib);
SvcLogicContext ctx = new SvcLogicContext();
ctx.setAttribute(FlowControllerConstants.ACTION_LEVEL, "action_level");
- Mockito.when(sqlResource.query(Mockito.anyString(), Mockito.anyBoolean(), Mockito.anyString(),
- Mockito.anyString(), Mockito.anyString(), Mockito.anyString(),
- Mockito.any(SvcLogicContext.class))).thenReturn(QueryStatus.FAILURE);
+ Mockito.when(dblib.query(Mockito.anyString(), Mockito.any(SvcLogicContext.class)))
+ .thenReturn(QueryStatus.FAILURE);
expectedEx.expect(SvcLogicException.class);
expectedEx.expectMessage(FlowControlDBService.GET_FLOW_REF_DATA_ERROR);
dbService.getDesignTimeFlowModel(ctx);
@@ -75,12 +78,11 @@ public class FlowControlDBServiceTest {
@Test
public void testGetDesignTimeFlowModelSecondQueryException() throws SvcLogicException {
- dbService = new FlowControlDBService(sqlResource);
+ dbService = new FlowControlDBService(dblib);
SvcLogicContext ctx = new SvcLogicContext();
ctx.setAttribute(FlowControllerConstants.ACTION_LEVEL, "action_level");
- Mockito.when(sqlResource.query(Mockito.anyString(), Mockito.anyBoolean(), Mockito.anyString(),
- Mockito.anyString(), Mockito.anyString(), Mockito.anyString(),
- Mockito.any(SvcLogicContext.class))).thenReturn(QueryStatus.SUCCESS).thenReturn(QueryStatus.FAILURE);
+ Mockito.when(dblib.query(Mockito.anyString(), Mockito.any(SvcLogicContext.class)))
+ .thenReturn(QueryStatus.SUCCESS).thenReturn(QueryStatus.FAILURE);
expectedEx.expect(SvcLogicException.class);
expectedEx.expectMessage(FlowControlDBService.GET_FLOW_REF_DATA_ERROR);
dbService.getDesignTimeFlowModel(ctx);
@@ -88,17 +90,16 @@ public class FlowControlDBServiceTest {
@Test
public void testGetDesignTimeFlowModelNullLocalContext() throws SvcLogicException {
- dbService = new FlowControlDBService(sqlResource);
+ dbService = new FlowControlDBService(dblib);
assertNull(dbService.getDesignTimeFlowModel(null));
}
@Test
public void testLoadSequenceIntoDb() throws SvcLogicException {
- dbService = new FlowControlDBService(sqlResource);
+ dbService = new FlowControlDBService(dblib);
SvcLogicContext ctx = new SvcLogicContext();
ctx.setAttribute(FlowControllerConstants.ACTION_LEVEL, "action_level");
- Mockito.when(sqlResource.save(Mockito.anyString(), Mockito.anyBoolean(), Mockito.anyBoolean(), Mockito.anyString(),
- Mockito.any(), Mockito.anyString(), Mockito.any(SvcLogicContext.class)))
+ Mockito.when(dblib.save(Mockito.anyString(), Mockito.any(SvcLogicContext.class)))
.thenReturn(QueryStatus.FAILURE);
expectedEx.expect(SvcLogicException.class);
expectedEx.expectMessage("Error While processing storing Artifact: ");
@@ -107,12 +108,12 @@ public class FlowControlDBServiceTest {
@Test
public void testGetProtocolTypeFirstException() throws SvcLogicException {
- dbService = new FlowControlDBService(sqlResource);
+ dbService = new FlowControlDBService(dblib);
SvcLogicContext ctx = new SvcLogicContext();
ctx.setAttribute(FlowControllerConstants.ACTION_LEVEL, "action_level");
- Mockito.when(sqlResource.query(Mockito.anyString(), Mockito.anyBoolean(), Mockito.anyString(),
- Mockito.anyString(), Mockito.anyString(), Mockito.anyString(),
- Mockito.any(SvcLogicContext.class))).thenReturn(QueryStatus.FAILURE);
+ Mockito.when(dblib.query(Mockito.anyString(), Mockito.any(SvcLogicContext.class),
+ Mockito.any(ArrayList.class)))
+ .thenReturn(QueryStatus.FAILURE);
expectedEx.expect(SvcLogicException.class);
expectedEx.expectMessage(FlowControlDBService.GET_FLOW_REF_DATA_ERROR);
dbService.populateModuleAndRPC(new Transaction(), "vnf_type");
@@ -120,12 +121,12 @@ public class FlowControlDBServiceTest {
@Test
public void testGetProtocolTypeSecondException() throws SvcLogicException {
- dbService = Mockito.spy(new FlowControlDBService(sqlResource));
+ dbService = Mockito.spy(new FlowControlDBService(dblib));
SvcLogicContext ctx = new SvcLogicContext();
ctx.setAttribute(FlowControlDBService.COUNT_PROTOCOL_PARAM, "1");
- Mockito.when(sqlResource.query(Mockito.anyString(), Mockito.anyBoolean(), Mockito.anyString(),
- Mockito.anyString(), Mockito.anyString(), Mockito.anyString(),
- Mockito.any(SvcLogicContext.class))).thenReturn(QueryStatus.SUCCESS).thenReturn(QueryStatus.FAILURE);
+ Mockito.when(dblib.query(Mockito.anyString(), Mockito.any(SvcLogicContext.class),
+ Mockito.any(ArrayList.class)))
+ .thenReturn(QueryStatus.SUCCESS).thenReturn(QueryStatus.FAILURE);
Mockito.when(dbService.getSvcLogicContext()).thenReturn(ctx);
expectedEx.expect(SvcLogicException.class);
expectedEx.expectMessage(FlowControlDBService.GET_FLOW_REF_DATA_ERROR);
@@ -134,12 +135,12 @@ public class FlowControlDBServiceTest {
@Test
public void testHasSingleProtocolFirstException() throws SvcLogicException {
- dbService = Mockito.spy(new FlowControlDBService(sqlResource));
+ dbService = Mockito.spy(new FlowControlDBService(dblib));
SvcLogicContext ctx = new SvcLogicContext();
ctx.setAttribute(FlowControlDBService.COUNT_PROTOCOL_PARAM, "2");
- Mockito.when(sqlResource.query(Mockito.anyString(), Mockito.anyBoolean(), Mockito.anyString(),
- Mockito.anyString(), Mockito.anyString(), Mockito.anyString(),
- Mockito.any(SvcLogicContext.class))).thenReturn(QueryStatus.SUCCESS).thenReturn(QueryStatus.FAILURE);
+ Mockito.when(dblib.query(Mockito.anyString(), Mockito.any(SvcLogicContext.class),
+ Mockito.any(ArrayList.class)))
+ .thenReturn(QueryStatus.SUCCESS).thenReturn(QueryStatus.FAILURE);
Mockito.when(dbService.getSvcLogicContext()).thenReturn(ctx);
expectedEx.expect(SvcLogicException.class);
expectedEx.expectMessage(FlowControlDBService.GET_FLOW_REF_DATA_ERROR);
@@ -149,12 +150,12 @@ public class FlowControlDBServiceTest {
@Test
public void testHasSingleProtocolSecondException() throws SvcLogicException {
- dbService = Mockito.spy(new FlowControlDBService(sqlResource));
+ dbService = Mockito.spy(new FlowControlDBService(dblib));
SvcLogicContext ctx = new SvcLogicContext();
ctx.setAttribute(FlowControlDBService.COUNT_PROTOCOL_PARAM, "2");
- Mockito.when(sqlResource.query(Mockito.anyString(), Mockito.anyBoolean(), Mockito.anyString(),
- Mockito.anyString(), Mockito.anyString(), Mockito.anyString(),
- Mockito.any(SvcLogicContext.class))).thenReturn(QueryStatus.SUCCESS).thenReturn(QueryStatus.SUCCESS)
+ Mockito.when(dblib.query(Mockito.anyString(), Mockito.any(SvcLogicContext.class),
+ Mockito.any(ArrayList.class)))
+ .thenReturn(QueryStatus.SUCCESS).thenReturn(QueryStatus.SUCCESS)
.thenReturn(QueryStatus.FAILURE);
Mockito.when(dbService.getSvcLogicContext()).thenReturn(ctx);
expectedEx.expect(SvcLogicException.class);
@@ -165,12 +166,12 @@ public class FlowControlDBServiceTest {
@Test
public void testHasSingleProtocolThirdException() throws SvcLogicException {
- dbService = Mockito.spy(new FlowControlDBService(sqlResource));
+ dbService = Mockito.spy(new FlowControlDBService(dblib));
SvcLogicContext ctx = Mockito.spy(new SvcLogicContext());
Mockito.when(ctx.getAttribute(FlowControlDBService.COUNT_PROTOCOL_PARAM)).thenReturn("2").thenReturn("1");
- Mockito.when(sqlResource.query(Mockito.anyString(), Mockito.anyBoolean(), Mockito.anyString(),
- Mockito.anyString(), Mockito.anyString(), Mockito.anyString(),
- Mockito.any(SvcLogicContext.class))).thenReturn(QueryStatus.SUCCESS).thenReturn(QueryStatus.SUCCESS)
+ Mockito.when(dblib.query(Mockito.anyString(), Mockito.any(SvcLogicContext.class),
+ Mockito.any(ArrayList.class)))
+ .thenReturn(QueryStatus.SUCCESS).thenReturn(QueryStatus.SUCCESS)
.thenReturn(QueryStatus.FAILURE);
Mockito.when(dbService.getSvcLogicContext()).thenReturn(ctx);
expectedEx.expect(SvcLogicException.class);
@@ -181,12 +182,12 @@ public class FlowControlDBServiceTest {
@Test
public void testHasSingleProtocolSuccessFlow() throws SvcLogicException {
- dbService = Mockito.spy(new FlowControlDBService(sqlResource));
+ dbService = Mockito.spy(new FlowControlDBService(dblib));
SvcLogicContext ctx = Mockito.spy(new SvcLogicContext());
Mockito.when(ctx.getAttribute(FlowControlDBService.COUNT_PROTOCOL_PARAM)).thenReturn("2").thenReturn("1");
- Mockito.when(sqlResource.query(Mockito.anyString(), Mockito.anyBoolean(), Mockito.anyString(),
- Mockito.anyString(), Mockito.anyString(), Mockito.anyString(),
- Mockito.any(SvcLogicContext.class))).thenReturn(QueryStatus.SUCCESS).thenReturn(QueryStatus.SUCCESS)
+ Mockito.when(dblib.query(Mockito.anyString(), Mockito.any(SvcLogicContext.class),
+ Mockito.any(ArrayList.class)))
+ .thenReturn(QueryStatus.SUCCESS).thenReturn(QueryStatus.SUCCESS)
.thenReturn(QueryStatus.SUCCESS);
Mockito.when(dbService.getSvcLogicContext()).thenReturn(ctx);
Transaction transaction = Mockito.spy(new Transaction());
@@ -196,12 +197,11 @@ public class FlowControlDBServiceTest {
@Test
public void testGetDependencyInfoFirstException() throws SvcLogicException {
- dbService = new FlowControlDBService(sqlResource);
+ dbService = new FlowControlDBService(dblib);
SvcLogicContext ctx = new SvcLogicContext();
ctx.setAttribute(FlowControllerConstants.ACTION_LEVEL, "action_level");
- Mockito.when(sqlResource.query(Mockito.anyString(), Mockito.anyBoolean(), Mockito.anyString(),
- Mockito.anyString(), Mockito.anyString(), Mockito.anyString(),
- Mockito.any(SvcLogicContext.class))).thenReturn(QueryStatus.FAILURE);
+ Mockito.when(dblib.query(Mockito.anyString(), Mockito.any(SvcLogicContext.class)))
+ .thenReturn(QueryStatus.FAILURE);
expectedEx.expect(SvcLogicException.class);
expectedEx.expectMessage("Error - while getting dependencydata ");
dbService.getDependencyInfo(ctx);
@@ -209,12 +209,11 @@ public class FlowControlDBServiceTest {
@Test
public void testGetDependencyInfoSecondException() throws SvcLogicException {
- dbService = new FlowControlDBService(sqlResource);
+ dbService = new FlowControlDBService(dblib);
SvcLogicContext ctx = new SvcLogicContext();
ctx.setAttribute(FlowControllerConstants.ACTION_LEVEL, "action_level");
- Mockito.when(sqlResource.query(Mockito.anyString(), Mockito.anyBoolean(), Mockito.anyString(),
- Mockito.anyString(), Mockito.anyString(), Mockito.anyString(),
- Mockito.any(SvcLogicContext.class))).thenReturn(QueryStatus.SUCCESS).thenReturn(QueryStatus.FAILURE);
+ Mockito.when(dblib.query(Mockito.anyString(), Mockito.any(SvcLogicContext.class)))
+ .thenReturn(QueryStatus.SUCCESS).thenReturn(QueryStatus.FAILURE);
expectedEx.expect(SvcLogicException.class);
expectedEx.expectMessage("Error - while getting dependencyData ");
dbService.getDependencyInfo(ctx);
@@ -222,12 +221,11 @@ public class FlowControlDBServiceTest {
@Test
public void testGetCapabilitiesDataFirstException() throws SvcLogicException {
- dbService = new FlowControlDBService(sqlResource);
+ dbService = new FlowControlDBService(dblib);
SvcLogicContext ctx = new SvcLogicContext();
ctx.setAttribute(FlowControllerConstants.ACTION_LEVEL, "action_level");
- Mockito.when(sqlResource.query(Mockito.anyString(), Mockito.anyBoolean(), Mockito.anyString(),
- Mockito.anyString(), Mockito.anyString(), Mockito.anyString(),
- Mockito.any(SvcLogicContext.class))).thenReturn(QueryStatus.FAILURE);
+ Mockito.when(dblib.query(Mockito.anyString(), Mockito.any(SvcLogicContext.class)))
+ .thenReturn(QueryStatus.FAILURE);
expectedEx.expect(SvcLogicException.class);
expectedEx.expectMessage("Error - while getting capabilitiesData ");
dbService.getCapabilitiesData(ctx);
@@ -235,12 +233,11 @@ public class FlowControlDBServiceTest {
@Test
public void testGetCapabilitiesDataSecondException() throws SvcLogicException {
- dbService = new FlowControlDBService(sqlResource);
+ dbService = new FlowControlDBService(dblib);
SvcLogicContext ctx = new SvcLogicContext();
ctx.setAttribute(FlowControllerConstants.ACTION_LEVEL, "action_level");
- Mockito.when(sqlResource.query(Mockito.anyString(), Mockito.anyBoolean(), Mockito.anyString(),
- Mockito.anyString(), Mockito.anyString(), Mockito.anyString(),
- Mockito.any(SvcLogicContext.class))).thenReturn(QueryStatus.SUCCESS).thenReturn(QueryStatus.FAILURE);
+ Mockito.when(dblib.query(Mockito.anyString(), Mockito.any(SvcLogicContext.class)))
+ .thenReturn(QueryStatus.SUCCESS).thenReturn(QueryStatus.FAILURE);
expectedEx.expect(SvcLogicException.class);
expectedEx.expectMessage("Error - while getting capabilitiesData ");
dbService.getCapabilitiesData(ctx);
diff --git a/appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/executor/node/FlowControlDBServiceTest.java b/appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/executor/node/FlowControlDBServiceTest.java
deleted file mode 100644
index d1edf544b..000000000
--- a/appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/executor/node/FlowControlDBServiceTest.java
+++ /dev/null
@@ -1,221 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP : APPC
- * ================================================================================
- * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Copyright (C) 2017 Amdocs
- * =============================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.appc.flow.executor.node;
-
-import static org.junit.Assert.*;
-
-import java.util.Map;
-
-import org.junit.Test;
-import org.onap.appc.flow.controller.data.Transaction;
-import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
-import org.onap.ccsdk.sli.core.sli.SvcLogicResource.QueryStatus;
-
-import org.powermock.reflect.Whitebox;
-
-
-//@PrepareForTest({ SqlResource.class, SvcLogicResource.class })
-//@RunWith(PowerMockRunner.class)
-public class FlowControlDBServiceTest {
-
-// @Mock
-// SvcLogicResource serviceLogic;
-//@Mock
-//SqlResource sqlrs;
-//@Mock
-//QueryStatus dblibSvc ;
-//
-// private static FlowControlDBService dgGeneralDBService = FlowControlDBService.initialise();
-//
-// private Transaction transaction;;
-//
-// @Before
-// public void setUp() throws Exception {
-// serviceLogic = new SqlResource();
-// }
-//
-//
-// /*public final void testGetFlowReferenceData() throws Exception {
-//
-// SvcLogicContext localContext = new SvcLogicContext();
-// FlowControlDBService dgGeneralDBService = FlowControlDBService.initialise();
-// PowerMockito.spy(SqlResource.class);
-//
-// Map<String, String> inParams = null;
-// //PowerMockito.doReturn(dblibSvc).when(SqlResource.class, "query");
-// Whitebox.invokeMethod(SqlResource.class, "query",anyString(), anyBoolean(), anyString(), anyString(), anyString(), anyString(), any(SvcLogicContext.class));
-//
-// dgGeneralDBService.getFlowReferenceData(localContext, inParams, localContext);
-// //Assert.assertEquals("SUCCESS", status);
-// //Assert.assertNotEquals("Error - while getting FlowReferenceData", "FAILURE", status);
-//
-// }*/
-//
-// @Test(expected=Exception.class)
-// public final void testGetFlowReferenceData() throws Exception {
-//
-// SvcLogicContext localContext = new SvcLogicContext();
-// FlowControlDBService dgGeneralDBService = FlowControlDBService.initialise();
-// PowerMockito.spy(FlowControlDBService.class);
-//
-//
-// PowerMockito.doReturn(dgGeneralDBService).when(SqlResource.class, "query");
-// String status = dgGeneralDBService.getDesignTimeFlowModel(localContext);
-// Assert.assertEquals("SUCCESS", status);
-// Assert.assertNotEquals("Error - while getting FlowReferenceData", "FAILURE", status);
-//
-// }
-//
-//
-// @Ignore("Test is taking 60 seconds")
-// @Test(expected=Exception.class)
-// public final void testGetDesignTimeFlowModel() throws Exception {
-// SvcLogicContext localContext = new SvcLogicContext();
-// String status = dgGeneralDBService.getDesignTimeFlowModel(localContext) ;
-// Assert.assertEquals("SUCCESS", status);
-// Assert.assertNotEquals("Error - while getting FlowReferenceData", "FAILURE", status);
-//
-//
-//
-//
-// }
-//
-// @Ignore("Test is taking 60 seconds")
-// @Test(expected=Exception.class)
-// public final void testLoadSequenceIntoDB() throws SvcLogicException {
-//
-//
-// SvcLogicContext localContext = new SvcLogicContext();
-// QueryStatus status = dgGeneralDBService.loadSequenceIntoDB(localContext) ;
-// Assert.assertEquals("SUCCESS", status);
-// Assert.assertNotEquals("Error - while getting FlowReferenceData", "FAILURE", status);
-// /*SvcLogicContext ctx = new SvcLogicContext();
-//
-// if (serviceLogic != null && localContext != null) {
-// String queryString = "INSERT INTO " + FlowControllerConstants.DB_REQUEST_ARTIFACTS
-// + " set request_id = ' kusuma_test' , action = 'Configure', action_level = 'VNF' , vnf_type = 'vComp' , category = 'config_Template' , artifact_content = '', updated_date = sysdate() ";
-// Mockito.when(serviceLogic.save("SQL", false, false, queryString, null, null, localContext))
-// .thenReturn(status);
-// Assert.assertEquals("SUCCESS", status);
-// Assert.assertNotEquals("Error - while getting FlowReferenceData", "FAILURE", status);*/
-//
-//
-//
-// }
-//
-// @Ignore
-// @Test(expected=Exception.class)
-// public final void testPopulateModuleAndRPC() throws Exception {
-// SvcLogicContext localContext = new SvcLogicContext();
-// SvcLogicContext ctx = new SvcLogicContext();
-// String vnf_type = "test";
-// dgGeneralDBService.populateModuleAndRPC(transaction, vnf_type);;
-//
-//
-// }
-//
-// @Ignore("Test is taking 60 seconds")
-// @Test(expected=Exception.class)
-// public final void testGetDependencyInfo() throws SvcLogicException {
-// SvcLogicContext localContext = new SvcLogicContext();
-// String status = dgGeneralDBService.getDependencyInfo(localContext);
-// Assert.assertEquals("SUCCESS", status);
-// Assert.assertNotEquals("Error - while getting FlowReferenceData", "FAILURE", status);
-//
-// }
-//
-// @Ignore("Test is taking 60 seconds")
-// @Test(expected=Exception.class)
-// public final void testGetCapabilitiesData() throws SvcLogicException {
-// SvcLogicContext localContext = new SvcLogicContext();
-// String status = dgGeneralDBService.getCapabilitiesData(localContext);
-// Assert.assertEquals("SUCCESS", status);
-// Assert.assertNotEquals("Error - while getting FlowReferenceData", "FAILURE", status);
-//
-// }
-
-
- @Test
- public final void testGetCapabilitiesData1() throws Exception {
- MockDBService dbService = MockDBService.initialise();
- SvcLogicContext ctx = new SvcLogicContext();
- ctx.setAttribute("test", "test");
- String status = dbService.getCapabilitiesData(ctx);
- assertEquals("TestArtifactContent", status);
-
- }
-
- @Test
- public final void testGetDependencyInfo() throws Exception {
- MockDBService dbService = MockDBService.initialise();
- SvcLogicContext ctx = new SvcLogicContext();
- String status = dbService.getDependencyInfo(ctx);
- assertEquals("TestArtifactContent", status);
- }
-
- @Test
- public final void testGetDesignTimeFlowModel() throws Exception {
- MockDBService dbService = MockDBService.initialise();
- SvcLogicContext ctx = new SvcLogicContext();
- String status = dbService.getDesignTimeFlowModel(ctx);
- assertEquals("TestArtifactContent", status);
- }
-
- @Test
- public final void testGetFlowReferenceData() throws Exception {
- MockDBService dbService = MockDBService.initialise();
- SvcLogicContext ctx = new SvcLogicContext();
- Map<String, String> inParams = null;
- dbService.getFlowReferenceData(ctx, inParams, ctx);
- assertEquals("TestSequence", ctx.getAttribute("SEQUENCE_TYPE"));
- }
-
- @Test
- public final void testLoadSequenceIntoDB1() throws Exception {
- MockDBService dbService = MockDBService.initialise();
- SvcLogicContext ctx = new SvcLogicContext();
- QueryStatus result = dbService.loadSequenceIntoDB(ctx);
- assertEquals("SUCCESS", result.toString());
- }
-
- @Test
- public final void testPopulateModuleAndRPC() throws Exception {
- MockDBService dbService = MockDBService.initialise();
- Transaction transaction = new Transaction();
- String vnfType = "TestVNF";
- dbService.populateModuleAndRPC(transaction, vnfType);
- assertEquals("TestModule", transaction.getExecutionModule());
- }
-
- @Test
- public void testHasSingleProtocol() throws Exception {
- MockDBService dbService = MockDBService.initialise();
- SvcLogicContext ctx = new SvcLogicContext();
- String vnfTType = "TestVNF";
- String fn = "test";
- Transaction transaction = new Transaction();
- boolean result = Whitebox.invokeMethod(dbService, "hasSingleProtocol", transaction, vnfTType, fn, ctx);
- assertEquals(true, result);
- }
-}
diff --git a/appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/executor/node/MockDBService.java b/appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/executor/node/MockDBService.java
index cd11dbf68..b83c78cc4 100644
--- a/appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/executor/node/MockDBService.java
+++ b/appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/executor/node/MockDBService.java
@@ -26,7 +26,7 @@ import org.onap.appc.flow.controller.dbervices.FlowControlDBService;
public class MockDBService extends FlowControlDBService {
private static MockDBService mockDgGeneralDBService = null;
- private static MockSvcLogicResource serviceLogic = new MockSvcLogicResource();
+ private static MockDbLibServiceQueries serviceLogic = new MockDbLibServiceQueries();
public MockDBService() {
super(serviceLogic);
@@ -36,7 +36,7 @@ public class MockDBService extends FlowControlDBService {
}
- public MockDBService(MockSvcLogicResource serviceLogic2) {
+ public MockDBService(MockDbLibServiceQueries serviceLogic2) {
super(serviceLogic);
}
diff --git a/appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/executor/node/MockSvcLogicResource.java b/appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/executor/node/MockDbLibServiceQueries.java
index 15dcd2b0a..cfceb6ce5 100644
--- a/appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/executor/node/MockSvcLogicResource.java
+++ b/appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/executor/node/MockDbLibServiceQueries.java
@@ -21,33 +21,53 @@
package org.onap.appc.flow.executor.node;
+import java.util.ArrayList;
import java.util.Map;
+import org.onap.appc.flow.controller.dbervices.DbLibServiceQueries;
import org.onap.appc.flow.controller.utils.FlowControllerConstants;
import org.onap.ccsdk.sli.adaptors.resource.sql.SqlResource;
import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
import org.onap.ccsdk.sli.core.sli.SvcLogicException;
import org.onap.ccsdk.sli.core.sli.SvcLogicResource.QueryStatus;
-public class MockSvcLogicResource extends SqlResource {
+public class MockDbLibServiceQueries extends DbLibServiceQueries {
+
+ public MockDbLibServiceQueries() {
+ super(null,true);
+ }
@Override
- public QueryStatus query(String resource, boolean localOnly, String select, String key, String prefix,
- String orderBy, SvcLogicContext ctx) throws SvcLogicException {
- ctx.setAttribute("artifact-content", "TestArtifactContent");
- ctx.setAttribute(FlowControllerConstants.EXECUTION_TYPE,"TestRPC");
- ctx.setAttribute(FlowControllerConstants.EXECUTTION_MODULE,"TestModule");
- ctx.setAttribute(FlowControllerConstants.EXECUTION_RPC,"TestRPC");
- ctx.setAttribute("count(protocol)", "1");
- ctx.setAttribute("protocol", "TestProtocol");
- ctx.setAttribute("SEQUENCE_TYPE", "TestSequence");
+ public QueryStatus query(String query, SvcLogicContext ctx, String prefix, ArrayList<String> arguments) {
+
return QueryStatus.SUCCESS;
}
+ @Override
+ public QueryStatus query(String query, SvcLogicContext ctx, ArrayList<String> arguments) {
+ return QueryStatus.SUCCESS;
+ }
+ @Override
+ public QueryStatus query(String query, String prefix, SvcLogicContext ctx) {
+ return QueryStatus.SUCCESS;
+ }
@Override
- public QueryStatus save(String resource, boolean force, boolean localOnly, String key, Map<String, String> parms,
- String prefix, SvcLogicContext ctx) throws SvcLogicException {
+ public QueryStatus query(String query, SvcLogicContext ctx) {
+
return QueryStatus.SUCCESS;
}
+
+ @Override
+ public QueryStatus save(String query, SvcLogicContext ctx, ArrayList<String> arguments) {
+
+ return QueryStatus.SUCCESS;
+ }
+ @Override
+ public QueryStatus save(String query, SvcLogicContext ctx) {
+
+ return QueryStatus.SUCCESS;
+ }
+
+
}