2 * Copyright (c) 2017 Pantheon Technologies s.r.o. 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.javav2.dom.adapter.impl.data.tree;
10 import static org.junit.Assert.assertNotNull;
11 import static org.mockito.ArgumentMatchers.any;
12 import static org.mockito.Mockito.doReturn;
13 import static org.mockito.Mockito.mock;
14 import static org.mockito.Mockito.verify;
15 import static org.mockito.MockitoAnnotations.initMocks;
17 import com.google.common.collect.ImmutableSet;
18 import com.google.common.util.concurrent.MoreExecutors;
19 import org.junit.Before;
20 import org.junit.Test;
21 import org.mockito.Mock;
22 import org.opendaylight.mdsal.binding.javav2.api.DataTreeListener;
23 import org.opendaylight.mdsal.binding.javav2.dom.adapter.test.BindingBrokerTestFactory;
24 import org.opendaylight.mdsal.binding.javav2.dom.adapter.test.BindingTestContext;
25 import org.opendaylight.mdsal.binding.javav2.dom.codec.impl.BindingToNormalizedNodeCodec;
26 import org.opendaylight.mdsal.dom.api.DOMDataTreeProducer;
27 import org.opendaylight.mdsal.dom.api.DOMDataTreeService;
29 public class BindingDOMDataTreeServiceAdapterTest {
31 private BindingDOMDataTreeServiceAdapter bindingDOMDataTreeServiceAdapter;
32 private BindingToNormalizedNodeCodec codec;
35 private DOMDataTreeService delegate;
38 public void setUp() throws Exception {
40 final BindingBrokerTestFactory testFactory = new BindingBrokerTestFactory();
41 testFactory.setExecutor(MoreExecutors.newDirectExecutorService());
42 final BindingTestContext testContext = testFactory.getTestContext();
44 codec = testContext.getCodec();
45 bindingDOMDataTreeServiceAdapter = BindingDOMDataTreeServiceAdapter.create(delegate, codec);
49 public void createProducerTest() throws Exception {
50 doReturn(mock(DOMDataTreeProducer.class)).when(delegate).createProducer(any());
51 assertNotNull(bindingDOMDataTreeServiceAdapter.createProducer(ImmutableSet.of()));
52 verify(delegate).createProducer(any());
55 @Test(expected = UnsupportedOperationException.class)
56 public void registerListenerTest() throws Exception {
57 bindingDOMDataTreeServiceAdapter.registerListener(mock(DataTreeListener.class), ImmutableSet.of(), false,