summaryrefslogtreecommitdiffstats
path: root/dataChange/provider/src/test/java/org/onap/sdnc/northbound/dataChange/DataChangeClientTest.java
blob: 9ba6c87427b9f5a5b280f17c1856657ae267de36 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
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); 
	} 
}