88a7f5bf0faa6bacc968a83899b6b9613e048388
[ccsdk/sli.git] /
1 package org.onap.sdnc.northbound.dataChange;
2
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;
9 import org.junit.Test;
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;
14
15 public class DataChangeClientTest {
16
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();
23
24         @Before
25         public void setUp() throws Exception {
26                 mockSvcLogicService = mock(SvcLogicService.class);
27                 when(mockSvcLogicService.hasGraph(module, rpc, version, mode)).thenReturn(true);
28         }
29
30         @Test
31         public void testDataChangeClientConstructor() {
32                 DataChangeClient dataChangeClient = new DataChangeClient(mockSvcLogicService);
33                 assertNotNull(dataChangeClient);
34         }
35
36         @Test
37         public void testHasGraph() throws SvcLogicException {
38                 DataChangeClient dataChangeClient = new DataChangeClient(mockSvcLogicService);
39                 boolean result = dataChangeClient.hasGraph(module, rpc, version, mode);
40                 assertTrue(result);
41         }
42
43         @Test
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);
54         }
55 }