From c50170bc44f192a7c8e7efdfc773342d8b5c0437 Mon Sep 17 00:00:00 2001 From: Jeremy Wolf Date: Wed, 28 Mar 2018 17:22:09 +0000 Subject: coverage sli-northbound adding junit test files for AsdcApiSliClient, AsdcApiUtil, DataChangeClient, SdncFlatJsonDmaapConsumer, SdncARModel, SdncNodeModel, SdncVFCModel, SdncVFModuleModel, SdncUebCallback Change-Id: Ia7fb307b84957292f9080654c7ae31992434317f Issue-ID: CCSDK-230 Signed-off-by: Jeremy Wolf --- .../dataChange/DataChangeClientTest.java | 56 ++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 dataChange/provider/src/test/java/org/onap/sdnc/northbound/dataChange/DataChangeClientTest.java (limited to 'dataChange') diff --git a/dataChange/provider/src/test/java/org/onap/sdnc/northbound/dataChange/DataChangeClientTest.java b/dataChange/provider/src/test/java/org/onap/sdnc/northbound/dataChange/DataChangeClientTest.java new file mode 100644 index 00000000..9ba6c874 --- /dev/null +++ b/dataChange/provider/src/test/java/org/onap/sdnc/northbound/dataChange/DataChangeClientTest.java @@ -0,0 +1,56 @@ +package org.onap.sdnc.northbound.dataChange; + +import static org.junit.Assert.*; +import static org.mockito.Mockito.*; + +import java.util.Properties; + +import org.junit.Before; +import org.junit.Test; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.onap.ccsdk.sli.core.sli.provider.MdsalHelper; +import org.onap.ccsdk.sli.core.sli.provider.SvcLogicService; +import org.onap.ccsdk.sli.northbound.DataChangeClient; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.northbound.datachange.rev150519.DataChangeNotificationOutputBuilder; + +public class DataChangeClientTest { + + SvcLogicService mockSvcLogicService; + String module = "test-module"; + String rpc = "test-rpc"; + String version = "test-version"; + String mode = "test-mode"; + Properties localProp = new Properties(); + + @Before + public void setUp() throws Exception { + mockSvcLogicService = mock(SvcLogicService.class); + when(mockSvcLogicService.hasGraph(module, rpc, version, mode)).thenReturn(true); + } + + @Test + public void testDataChangeClientConstructor() { + DataChangeClient dataChangeClient = new DataChangeClient(mockSvcLogicService); + assertNotNull(dataChangeClient); + } + + @Test + public void testHasGraph() throws SvcLogicException { + DataChangeClient dataChangeClient = new DataChangeClient(mockSvcLogicService); + boolean result = dataChangeClient.hasGraph(module, rpc, version, mode); + assertTrue(result); + } + + @Test + public void testExecuteSvcLogicStatusFailure() throws SvcLogicException { + DataChangeNotificationOutputBuilder serviceData = mock(DataChangeNotificationOutputBuilder.class); + Properties parms = mock(Properties.class); + SvcLogicService svcLogicService = mock(SvcLogicService.class); + Properties properties = new Properties(); + properties.setProperty("SvcLogic.status", "failure"); + when(svcLogicService.execute(module, rpc, version, mode, properties)).thenReturn(properties); + DataChangeClient sliClient = new DataChangeClient(svcLogicService); + Properties prop = sliClient.execute(module, rpc, version, mode, serviceData, properties); + assertTrue(prop != null); + } +} \ No newline at end of file -- cgit 1.2.3-korg