1 package org.onap.sdnc.northbound.dataChange;
3 import static org.junit.Assert.*;
4 import static org.mockito.Mockito.*;
6 import java.util.Properties;
8 import org.junit.Before;
10 import org.onap.ccsdk.sli.core.sli.SvcLogicException;
11 import org.onap.ccsdk.sli.core.sli.provider.MdsalHelper;
12 import org.onap.ccsdk.sli.core.sli.provider.SvcLogicService;
13 import org.onap.ccsdk.sli.northbound.DataChangeClient;
14 import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.northbound.datachange.rev150519.DataChangeNotificationOutputBuilder;
16 public class DataChangeClientTest {
18 SvcLogicService mockSvcLogicService;
19 String module = "test-module";
20 String rpc = "test-rpc";
21 String version = "test-version";
22 String mode = "test-mode";
23 Properties localProp = new Properties();
26 public void setUp() throws Exception {
27 mockSvcLogicService = mock(SvcLogicService.class);
28 when(mockSvcLogicService.hasGraph(module, rpc, version, mode)).thenReturn(true);
32 public void testDataChangeClientConstructor() {
33 DataChangeClient dataChangeClient = new DataChangeClient(mockSvcLogicService);
34 assertNotNull(dataChangeClient);
38 public void testHasGraph() throws SvcLogicException {
39 DataChangeClient dataChangeClient = new DataChangeClient(mockSvcLogicService);
40 boolean result = dataChangeClient.hasGraph(module, rpc, version, mode);
45 public void testExecuteSvcLogicStatusFailure() throws SvcLogicException {
46 DataChangeNotificationOutputBuilder serviceData = mock(DataChangeNotificationOutputBuilder.class);
47 Properties parms = mock(Properties.class);
48 SvcLogicService svcLogicService = mock(SvcLogicService.class);
49 Properties properties = new Properties();
50 properties.setProperty("SvcLogic.status", "failure");
51 when(svcLogicService.execute(module, rpc, version, mode, properties)).thenReturn(properties);
52 DataChangeClient sliClient = new DataChangeClient(svcLogicService);
53 Properties prop = sliClient.execute(module, rpc, version, mode, serviceData, properties);
54 assertTrue(prop != null);