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.doNothing;
12 import static org.mockito.Mockito.doReturn;
14 import com.google.common.util.concurrent.MoreExecutors;
15 import org.junit.jupiter.api.Test;
16 import org.junit.jupiter.api.extension.ExtendWith;
17 import org.mockito.Mock;
18 import org.mockito.junit.jupiter.MockitoExtension;
19 import org.opendaylight.mdsal.binding.api.DataTreeCommitCohort;
20 import org.opendaylight.mdsal.binding.api.DataTreeIdentifier;
21 import org.opendaylight.mdsal.binding.dom.adapter.test.util.BindingBrokerTestFactory;
22 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
23 import org.opendaylight.mdsal.dom.api.DOMDataBroker.CommitCohortExtension;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.Top;
25 import org.opendaylight.yangtools.concepts.Registration;
26 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
28 @ExtendWith(MockitoExtension.class)
29 public class BindingDOMDataTreeCommitCohortRegistryAdapterTest {
31 private CommitCohortExtension cohortExtension;
33 private Registration cohortRegistration;
35 private DataTreeCommitCohort<Top> dataTreeCommitCohort;
39 final var bindingBrokerTestFactory = new BindingBrokerTestFactory();
40 bindingBrokerTestFactory.setExecutor(MoreExecutors.newDirectExecutorService());
41 final var bindingTestContext = bindingBrokerTestFactory.getTestContext();
42 bindingTestContext.start();
44 doReturn(cohortRegistration).when(cohortExtension).registerCommitCohort(any(), any());
45 doNothing().when(cohortRegistration).close();
46 final var registryAdapter = new BindingDOMDataTreeCommitCohortRegistryAdapter(bindingTestContext.getCodec(),
49 final var dataTreeIdentifier = DataTreeIdentifier.of(LogicalDatastoreType.CONFIGURATION,
50 InstanceIdentifier.create(Top.class));
51 try (var reg = registryAdapter.registerCommitCohort(dataTreeIdentifier, dataTreeCommitCohort)) {