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 =
35 new EndpointManagerListener(dataProvider, endpointManager);
36 tester = new DataChangeListenerTester(endpointManagerListener);
37 tester.setRemovedPath(endpointId);
41 public void testOnDataChangeEndpoint() {
42 DataObject endpoint = mock(Endpoint.class);
43 tester.setDataObject(endpointId, endpoint);
45 tester.callOnDataChanged();
47 verify(endpointManager, times(3)).processEndpoint(any(Endpoint.class), any(Endpoint.class));
48 verify(endpointManager, never()).processL3Endpoint(any(EndpointL3.class),
49 any(EndpointL3.class));
53 public void testOnDataChangeEndpointL3() {
54 DataObject endpoint = mock(EndpointL3.class);
55 tester.setDataObject(endpointId, endpoint);
57 tester.callOnDataChanged();
59 verify(endpointManager, never()).processEndpoint(any(Endpoint.class), any(Endpoint.class));
60 verify(endpointManager, times(3)).processL3Endpoint(any(EndpointL3.class),
61 any(EndpointL3.class));
65 public void testOnDataChangeEndpointL3Prefix() {
66 DataObject endpoint = mock(EndpointL3Prefix.class);
67 tester.setDataObject(endpointId, endpoint);
69 tester.callOnDataChanged();
71 verify(endpointManager, never()).processEndpoint(any(Endpoint.class), any(Endpoint.class));
72 verify(endpointManager, never()).processL3Endpoint(any(EndpointL3.class),
73 any(EndpointL3.class));