Fix mockito deprecation warnings
[mdsal.git] / binding / mdsal-binding-dom-adapter / src / test / java / org / opendaylight / mdsal / binding / dom / adapter / BindingDOMDataTreeListenerAdapterTest.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.mdsal.binding.dom.adapter;
9
10 import static org.mockito.ArgumentMatchers.any;
11 import static org.mockito.Mockito.verify;
12 import static org.mockito.MockitoAnnotations.initMocks;
13
14 import com.google.common.collect.ImmutableMap;
15 import com.google.common.collect.ImmutableSet;
16 import com.google.common.util.concurrent.MoreExecutors;
17 import org.junit.Before;
18 import org.junit.Test;
19 import org.mockito.Mock;
20 import org.opendaylight.mdsal.binding.api.DataTreeListener;
21 import org.opendaylight.mdsal.binding.dom.adapter.test.util.BindingBrokerTestFactory;
22 import org.opendaylight.mdsal.binding.dom.adapter.test.util.BindingTestContext;
23 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
24 import org.opendaylight.mdsal.dom.api.DOMDataTreeListeningException;
25
26 public class BindingDOMDataTreeListenerAdapterTest {
27
28     private BindingDOMDataTreeListenerAdapter bindingDOMDataTreeListenerAdapter;
29
30     @Mock
31     private DataTreeListener delegate;
32
33     @Before
34     public void setUp() throws Exception {
35         initMocks(this);
36         final BindingBrokerTestFactory testFactory = new BindingBrokerTestFactory();
37         testFactory.setExecutor(MoreExecutors.newDirectExecutorService());
38         final BindingTestContext testContext = testFactory.getTestContext();
39         testContext.start();
40
41         bindingDOMDataTreeListenerAdapter =
42             new BindingDOMDataTreeListenerAdapter(delegate, testContext.getCodec(), LogicalDatastoreType.OPERATIONAL);
43     }
44
45     @Test
46     public void onDataTreeChanged() throws Exception {
47         bindingDOMDataTreeListenerAdapter.onDataTreeChanged(ImmutableSet.of(), ImmutableMap.of());
48         verify(delegate).onDataTreeChanged(any(), any());
49     }
50
51     @Test
52     public void onDataTreeFailedTest() throws Exception {
53         bindingDOMDataTreeListenerAdapter.onDataTreeFailed(ImmutableSet.of(new DOMDataTreeListeningException("test")));
54         verify(delegate).onDataTreeFailed(any());
55     }
56 }