1 package org.opendaylight.groupbasedpolicy.renderer.ofoverlay.endpoint;
3 import static org.mockito.Matchers.any;
4 import static org.mockito.Mockito.mock;
5 import static org.mockito.Mockito.never;
6 import static org.mockito.Mockito.times;
7 import static org.mockito.Mockito.verify;
9 import org.junit.Before;
10 import org.junit.Test;
11 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
12 import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent;
13 import org.opendaylight.groupbasedpolicy.renderer.ofoverlay.test.DataChangeListenerTester;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.endpoints.Endpoint;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.endpoints.EndpointL3;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.endpoints.EndpointL3Prefix;
17 import org.opendaylight.yangtools.yang.binding.DataObject;
18 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
20 public class EndpointManagerListenerTest {
22 private InstanceIdentifier<DataObject> endpointId;
23 private AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> change;
24 private EndpointManager endpointManager;
25 private DataChangeListenerTester tester;
27 @SuppressWarnings("unchecked")
30 endpointId = mock(InstanceIdentifier.class);
31 endpointManager = mock(EndpointManager.class);
32 DataBroker dataProvider = mock(DataBroker.class);
34 EndpointManagerListener endpointManagerListener = new EndpointManagerListener(dataProvider, endpointManager);
35 tester = new DataChangeListenerTester(endpointManagerListener);
36 tester.setRemovedPath(endpointId);
40 public void testOnDataChangeEndpoint() {
41 DataObject endpoint = mock(Endpoint.class);
42 tester.setDataObject(endpointId, endpoint);
44 tester.callOnDataChanged();
46 verify(endpointManager, times(3)).processEndpoint(any(Endpoint.class), any(Endpoint.class));
47 verify(endpointManager, never()).processL3Endpoint(any(EndpointL3.class), any(EndpointL3.class));
51 public void testOnDataChangeEndpointL3() {
52 DataObject endpoint = mock(EndpointL3.class);
53 tester.setDataObject(endpointId, endpoint);
55 tester.callOnDataChanged();
57 verify(endpointManager, never()).processEndpoint(any(Endpoint.class), any(Endpoint.class));
58 verify(endpointManager, times(3)).processL3Endpoint(any(EndpointL3.class), any(EndpointL3.class));
62 public void testOnDataChangeEndpointL3Prefix() {
63 DataObject endpoint = mock(EndpointL3Prefix.class);
64 tester.setDataObject(endpointId, endpoint);
66 tester.callOnDataChanged();
68 verify(endpointManager, never()).processEndpoint(any(Endpoint.class), any(Endpoint.class));
69 verify(endpointManager, never()).processL3Endpoint(any(EndpointL3.class), any(EndpointL3.class));