2 * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
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
8 package org.opendaylight.mdsal.binding.dom.adapter;
10 import static org.mockito.ArgumentMatchers.any;
11 import static org.mockito.Mockito.verify;
13 import com.google.common.collect.ImmutableMap;
14 import com.google.common.collect.ImmutableSet;
15 import com.google.common.util.concurrent.MoreExecutors;
16 import org.junit.Before;
17 import org.junit.Test;
18 import org.junit.runner.RunWith;
19 import org.mockito.Mock;
20 import org.mockito.junit.MockitoJUnitRunner;
21 import org.opendaylight.mdsal.binding.api.DataTreeListener;
22 import org.opendaylight.mdsal.binding.dom.adapter.test.util.BindingBrokerTestFactory;
23 import org.opendaylight.mdsal.binding.dom.adapter.test.util.BindingTestContext;
24 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
25 import org.opendaylight.mdsal.dom.api.DOMDataTreeListeningException;
27 @RunWith(MockitoJUnitRunner.StrictStubs.class)
28 public class BindingDOMDataTreeListenerAdapterTest {
30 private BindingDOMDataTreeListenerAdapter bindingDOMDataTreeListenerAdapter;
33 private DataTreeListener delegate;
36 public void setUp() throws Exception {
37 final BindingBrokerTestFactory testFactory = new BindingBrokerTestFactory();
38 testFactory.setExecutor(MoreExecutors.newDirectExecutorService());
39 final BindingTestContext testContext = testFactory.getTestContext();
42 bindingDOMDataTreeListenerAdapter =
43 new BindingDOMDataTreeListenerAdapter(delegate, testContext.getCodec(), LogicalDatastoreType.OPERATIONAL);
47 public void onDataTreeChanged() throws Exception {
48 bindingDOMDataTreeListenerAdapter.onDataTreeChanged(ImmutableSet.of(), ImmutableMap.of());
49 verify(delegate).onDataTreeChanged(any(), any());
53 public void onDataTreeFailedTest() throws Exception {
54 bindingDOMDataTreeListenerAdapter.onDataTreeFailed(ImmutableSet.of(new DOMDataTreeListeningException("test")));
55 verify(delegate).onDataTreeFailed(any());