Search in sources :

Example 66 with TopLevelList

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelList in project mdsal by opendaylight.

the class Bug1418AugmentationTest method leafOnlyAugmentationUpdatedTest.

@Test
public void leafOnlyAugmentationUpdatedTest() {
    WriteTransaction writeTx = getDataBroker().newWriteOnlyTransaction();
    writeTx.put(CONFIGURATION, TOP, top());
    writeTx.put(CONFIGURATION, TOP_FOO, topLevelList(new TopLevelListKey(TOP_FOO_KEY)));
    TreeLeafOnlyUsesAugment leafOnlyUsesAugmentBefore = leafOnlyUsesAugment("test leaf");
    writeTx.put(CONFIGURATION, SIMPLE_AUGMENT, leafOnlyUsesAugmentBefore);
    assertCommit(writeTx.commit());
    TreeLeafOnlyUsesAugment leafOnlyUsesAugmentAfter = leafOnlyUsesAugment("test leaf changed");
    final TestListener<TreeLeafOnlyUsesAugment> listener = createListener(CONFIGURATION, SIMPLE_AUGMENT, added(path(TOP_FOO_KEY, TreeLeafOnlyUsesAugment.class), leafOnlyUsesAugmentBefore), replaced(path(TOP_FOO_KEY, TreeLeafOnlyUsesAugment.class), leafOnlyUsesAugmentBefore, leafOnlyUsesAugmentAfter));
    writeTx = getDataBroker().newWriteOnlyTransaction();
    writeTx.put(CONFIGURATION, SIMPLE_AUGMENT, leafOnlyUsesAugmentAfter);
    assertCommit(writeTx.commit());
    listener.verify();
}
Also used : WriteTransaction(org.opendaylight.mdsal.binding.api.WriteTransaction) TreeLeafOnlyUsesAugment(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.TreeLeafOnlyUsesAugment) TopLevelListKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelListKey) AbstractDataTreeChangeListenerTest(org.opendaylight.mdsal.binding.dom.adapter.test.AbstractDataTreeChangeListenerTest) Test(org.junit.Test)

Example 67 with TopLevelList

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelList in project mdsal by opendaylight.

the class Bug4494Test method testDelete.

@Test
public void testDelete() throws Exception {
    DataBroker dataBroker = getDataBroker();
    WriteTransaction writeTransaction = dataBroker.newWriteOnlyTransaction();
    TopLevelList list = new TopLevelListBuilder().setName("name").build();
    TopBuilder builder = new TopBuilder().setTopLevelList(Map.of(list.key(), list));
    writeTransaction.put(LogicalDatastoreType.OPERATIONAL, InstanceIdentifier.create(Top.class), builder.build());
    assertCommit(writeTransaction.commit());
    InstanceIdentifier<TopLevelList> id = InstanceIdentifier.builder(Top.class).child(TopLevelList.class, new TopLevelListKey("name")).build();
    ReadWriteTransaction writeTransaction1 = dataBroker.newReadWriteTransaction();
    writeTransaction1.delete(LogicalDatastoreType.OPERATIONAL, id);
    assertCommit(writeTransaction1.commit());
    ReadWriteTransaction writeTransaction2 = dataBroker.newReadWriteTransaction();
    writeTransaction2.delete(LogicalDatastoreType.OPERATIONAL, id);
    assertCommit(writeTransaction2.commit());
}
Also used : ReadWriteTransaction(org.opendaylight.mdsal.binding.api.ReadWriteTransaction) WriteTransaction(org.opendaylight.mdsal.binding.api.WriteTransaction) TopLevelListBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelListBuilder) TopBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.TopBuilder) Top(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.Top) TopLevelList(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelList) ReadWriteTransaction(org.opendaylight.mdsal.binding.api.ReadWriteTransaction) DataBroker(org.opendaylight.mdsal.binding.api.DataBroker) TopLevelListKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelListKey) Test(org.junit.Test) AbstractDataBrokerTest(org.opendaylight.mdsal.binding.dom.adapter.test.AbstractDataBrokerTest)

Example 68 with TopLevelList

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelList in project mdsal by opendaylight.

the class WriteTransactionTest method testPutCreateParentsSuccess.

@Test
public void testPutCreateParentsSuccess() throws InterruptedException, ExecutionException {
    final WriteTransaction writeTx = getDataBroker().newWriteOnlyTransaction();
    writeTx.mergeParentStructurePut(LogicalDatastoreType.OPERATIONAL, NODE_PATH, NODE);
    writeTx.commit().get();
    final ReadTransaction readTx = getDataBroker().newReadOnlyTransaction();
    final Optional<Top> topNode = readTx.read(LogicalDatastoreType.OPERATIONAL, TOP_PATH).get();
    assertTrue("Top node must exists after commit", topNode.isPresent());
    final Optional<TopLevelList> listNode = readTx.read(LogicalDatastoreType.OPERATIONAL, NODE_PATH).get();
    assertTrue("List node must exists after commit", listNode.isPresent());
}
Also used : WriteTransaction(org.opendaylight.mdsal.binding.api.WriteTransaction) Top(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.Top) ReadTransaction(org.opendaylight.mdsal.binding.api.ReadTransaction) TopLevelList(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelList) Test(org.junit.Test) AbstractDataBrokerTest(org.opendaylight.mdsal.binding.dom.adapter.test.AbstractDataBrokerTest)

Example 69 with TopLevelList

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelList in project mdsal by opendaylight.

the class QueryBuilderTest method bar.

@Test
public void bar() {
    final Stopwatch sw = Stopwatch.createStarted();
    final QueryExpression<TopLevelList> query = factory.querySubtree(InstanceIdentifier.create(Top.class)).extractChild(TopLevelList.class).matching().childObject(NestedList.class).leaf(NestedList::getName).contains("foo").and().leaf(TopLevelList::getName).valueEquals("bar").build();
    LOG.info("Query built in {}", sw);
    assertEquals(0, execute(query).getItems().size());
}
Also used : TopLevelList(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelList) Stopwatch(com.google.common.base.Stopwatch) Test(org.junit.Test)

Example 70 with TopLevelList

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelList in project mdsal by opendaylight.

the class RetryingManagedNewTransactionRunnerTest method testCallWithNewTypedReadWriteTransactionReadFailedException.

@Test
public void testCallWithNewTypedReadWriteTransactionReadFailedException() throws Exception {
    testableDataBroker.failReads(2, new ReadFailedException("bada boum bam!"));
    TopLevelList data = newTestDataObject();
    managedNewTransactionRunner.callWithNewReadWriteTransactionAndSubmit(OPERATIONAL, tx -> {
        tx.put(TEST_PATH, data);
        assertEquals(data, tx.read(TEST_PATH).get().get());
    }).get();
    assertEquals(data, syncRead(LogicalDatastoreType.OPERATIONAL, TEST_PATH));
}
Also used : ReadFailedException(org.opendaylight.mdsal.common.api.ReadFailedException) OptimisticLockFailedException(org.opendaylight.mdsal.common.api.OptimisticLockFailedException) TopLevelList(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelList) LogicalDatastoreType(org.opendaylight.mdsal.common.api.LogicalDatastoreType) Test(org.junit.Test) Assert.assertEquals(org.junit.Assert.assertEquals) OPERATIONAL(org.opendaylight.mdsal.binding.util.Datastore.OPERATIONAL) DataBroker(org.opendaylight.mdsal.binding.api.DataBroker) ReadFailedException(org.opendaylight.mdsal.common.api.ReadFailedException) TopLevelList(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelList) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)61 TopLevelList (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelList)32 DataBroker (org.opendaylight.mdsal.binding.api.DataBroker)26 Assert.assertEquals (org.junit.Assert.assertEquals)23 LogicalDatastoreType (org.opendaylight.mdsal.common.api.LogicalDatastoreType)23 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)22 OptimisticLockFailedException (org.opendaylight.mdsal.common.api.OptimisticLockFailedException)21 TopLevelList (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelList)20 WriteTransaction (org.opendaylight.mdsal.binding.api.WriteTransaction)18 DataObject (org.opendaylight.yangtools.yang.binding.DataObject)14 ManagedNewTransactionRunner (org.opendaylight.genius.infra.ManagedNewTransactionRunner)13 ExecutionException (java.util.concurrent.ExecutionException)12 Assert.assertThrows (org.junit.Assert.assertThrows)12 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)12 Before (org.junit.Before)11 AbstractDataTreeChangeListenerTest (org.opendaylight.mdsal.binding.dom.adapter.test.AbstractDataTreeChangeListenerTest)11 TopLevelListKey (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelListKey)11 IOException (java.io.IOException)10 OPERATIONAL (org.opendaylight.mdsal.binding.util.Datastore.OPERATIONAL)10 TreeComplexUsesAugmentBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.TreeComplexUsesAugmentBuilder)10