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