1 package org.onap.sdnc.northbound.dataChange;
3 import static org.junit.Assert.assertNotNull;
4 import static org.junit.Assert.assertTrue;
5 import static org.mockito.Mockito.mock;
6 import static org.mockito.Mockito.when;
7 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.SvcLogicService;
12 import org.onap.ccsdk.sli.northbound.DataChangeClient;
13 import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.northbound.datachange.rev150519.DataChangeNotificationOutputBuilder;
15 public class DataChangeClientTest {
17 SvcLogicService mockSvcLogicService;
18 String module = "test-module";
19 String rpc = "test-rpc";
20 String version = "test-version";
21 String mode = "test-mode";
22 Properties localProp = new Properties();
25 public void setUp() throws Exception {
26 mockSvcLogicService = mock(SvcLogicService.class);
27 when(mockSvcLogicService.hasGraph(module, rpc, version, mode)).thenReturn(true);
31 public void testDataChangeClientConstructor() {
32 DataChangeClient dataChangeClient = new DataChangeClient(mockSvcLogicService);
33 assertNotNull(dataChangeClient);
37 public void testHasGraph() throws SvcLogicException {
38 DataChangeClient dataChangeClient = new DataChangeClient(mockSvcLogicService);
39 boolean result = dataChangeClient.hasGraph(module, rpc, version, mode);
44 public void testExecuteSvcLogicStatusFailure() throws SvcLogicException {
45 DataChangeNotificationOutputBuilder serviceData = mock(DataChangeNotificationOutputBuilder.class);
46 Properties parms = mock(Properties.class);
47 SvcLogicService svcLogicService = mock(SvcLogicService.class);
48 Properties properties = new Properties();
49 properties.setProperty("SvcLogic.status", "failure");
50 when(svcLogicService.execute(module, rpc, version, mode, properties)).thenReturn(properties);
51 DataChangeClient sliClient = new DataChangeClient(svcLogicService);
52 Properties prop = sliClient.execute(module, rpc, version, mode, serviceData, properties);
53 assertTrue(prop != null);