Remove javax.annotation nullness annotations
[netconf.git] / netconf / mdsal-netconf-notification / src / test / java / org / opendaylight / netconf / mdsal / notification / impl / OperationalDatastoreListenerTest.java
1 /*
2  * Copyright (c) 2016 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.netconf.mdsal.notification.impl;
9
10 import static org.junit.Assert.assertEquals;
11 import static org.mockito.ArgumentMatchers.any;
12 import static org.mockito.Mockito.doReturn;
13 import static org.mockito.Mockito.verify;
14
15 import java.util.Collection;
16 import org.junit.Before;
17 import org.junit.Test;
18 import org.mockito.ArgumentCaptor;
19 import org.mockito.Mock;
20 import org.mockito.MockitoAnnotations;
21 import org.opendaylight.mdsal.binding.api.DataBroker;
22 import org.opendaylight.mdsal.binding.api.DataTreeIdentifier;
23 import org.opendaylight.mdsal.binding.api.DataTreeModification;
24 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
25 import org.opendaylight.yangtools.yang.binding.DataObject;
26 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
27
28 public class OperationalDatastoreListenerTest {
29
30     @Mock
31     private DataBroker dataBroker;
32
33     @Before
34     public void setUp() throws Exception {
35         MockitoAnnotations.initMocks(this);
36     }
37
38     @Test
39     public void testDataStoreListener() {
40         final InstanceIdentifier<DataObject> instanceIdentifier = InstanceIdentifier.create(DataObject.class);
41         final DataTreeIdentifier<DataObject> testId =
42                 DataTreeIdentifier.create(LogicalDatastoreType.OPERATIONAL, instanceIdentifier);
43
44         final OperationalDatastoreListener<DataObject> op =
45                 new OperationalDatastoreListener<DataObject>(instanceIdentifier) {
46             @Override
47             public void onDataTreeChanged(final Collection<DataTreeModification<DataObject>> collection) {
48             }
49         };
50         doReturn(null).when(dataBroker).registerDataTreeChangeListener(any(), any());
51
52         ArgumentCaptor<DataTreeIdentifier> argumentId = ArgumentCaptor.forClass(DataTreeIdentifier.class);
53         op.registerOnChanges(dataBroker);
54         verify(dataBroker).registerDataTreeChangeListener(argumentId.capture(), any());
55
56         assertEquals(testId, argumentId.getValue());
57
58     }
59 }