2 * Copyright (c) 2016 Red Hat, 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.test.tests;
10 import static org.junit.Assert.assertFalse;
11 import static org.junit.Assert.assertNotNull;
12 import static org.junit.Assert.assertTrue;
13 import static org.opendaylight.mdsal.binding.test.model.util.ListsBindingUtils.TOP_FOO_KEY;
14 import static org.opendaylight.mdsal.binding.test.model.util.ListsBindingUtils.path;
15 import static org.opendaylight.mdsal.binding.test.model.util.ListsBindingUtils.topLevelList;
17 import java.util.concurrent.ExecutionException;
18 import org.junit.FixMethodOrder;
19 import org.junit.Test;
20 import org.junit.runners.MethodSorters;
21 import org.opendaylight.mdsal.binding.api.ReadTransaction;
22 import org.opendaylight.mdsal.binding.api.WriteTransaction;
23 import org.opendaylight.mdsal.binding.dom.adapter.test.AbstractDataBrokerTest;
24 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
25 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.TreeComplexUsesAugment;
26 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.TreeComplexUsesAugmentBuilder;
27 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.complex.from.grouping.ContainerWithUsesBuilder;
28 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.Top;
29 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.TopBuilder;
30 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
33 * Integration tests the AbstractDataBrokerTest.
35 * @author Michael Vorburger
37 @FixMethodOrder(MethodSorters.NAME_ASCENDING)
38 public class AbstractDataBrokerTestTest extends AbstractDataBrokerTest {
39 private static final InstanceIdentifier<Top> TOP_PATH = InstanceIdentifier.create(Top.class);
42 public void aEnsureDataBrokerIsNotNull() {
43 assertNotNull(getDataBroker());
47 public void bPutSomethingIntoDataStore() throws Exception {
49 assertTrue(isTopInDataStore());
53 public void cEnsureDataStoreIsEmptyAgainInNewTest() throws Exception {
54 assertFalse(isTopInDataStore());
57 // copy/pasted from Bug1125RegressionTest.writeInitialState()
58 private void writeInitialState() throws InterruptedException, ExecutionException {
59 WriteTransaction initialTx = getDataBroker().newWriteOnlyTransaction();
60 initialTx.put(LogicalDatastoreType.OPERATIONAL, TOP_PATH, new TopBuilder().build());
61 TreeComplexUsesAugment fooAugment = new TreeComplexUsesAugmentBuilder()
62 .setContainerWithUses(new ContainerWithUsesBuilder().setLeafFromGrouping("foo").build()).build();
63 initialTx.put(LogicalDatastoreType.OPERATIONAL, path(TOP_FOO_KEY), topLevelList(TOP_FOO_KEY, fooAugment));
64 initialTx.commit().get();
67 private boolean isTopInDataStore() throws InterruptedException, ExecutionException {
68 try (ReadTransaction readTx = getDataBroker().newReadOnlyTransaction()) {
69 return readTx.exists(LogicalDatastoreType.OPERATIONAL, TOP_PATH).get();