Search in sources :

Example 1 with BooleanContainerBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns._default.value.test.norev.BooleanContainerBuilder in project mdsal by opendaylight.

the class Bug5845booleanKeyTest method testBug5845.

@Test
public void testBug5845() throws Exception {
    final BooleanListKey blk = new BooleanListKey(true, true);
    final BooleanContainer booleanContainer = new BooleanContainerBuilder().setBooleanList(Collections.singletonMap(blk, new BooleanListBuilder().withKey(blk).setBooleanLeaf1(true).setBooleanLeaf2(true).build())).build();
    final BooleanListIntKey blik = new BooleanListIntKey((byte) 1);
    final BooleanContainer booleanContainerInt = new BooleanContainerBuilder().setBooleanListInt(Collections.singletonMap(blik, new BooleanListIntBuilder().withKey(blik).setBooleanLeafInt((byte) 1).build())).build();
    final BindingDataObjectCodecTreeNode<BooleanContainer> subtreeCodec = codecContext.getSubtreeCodec(InstanceIdentifier.create(BooleanContainer.class));
    final NormalizedNode serializedInt = subtreeCodec.serialize(booleanContainerInt);
    assertNotNull(serializedInt);
    final NormalizedNode serialized = subtreeCodec.serialize(booleanContainer);
    assertNotNull(serialized);
}
Also used : BooleanListKey(org.opendaylight.yang.gen.v1.urn.yang.foo.rev160101._boolean.container.BooleanListKey) BooleanListBuilder(org.opendaylight.yang.gen.v1.urn.yang.foo.rev160101._boolean.container.BooleanListBuilder) BooleanListIntKey(org.opendaylight.yang.gen.v1.urn.yang.foo.rev160101._boolean.container.BooleanListIntKey) BooleanContainer(org.opendaylight.yang.gen.v1.urn.yang.foo.rev160101.BooleanContainer) BooleanContainerBuilder(org.opendaylight.yang.gen.v1.urn.yang.foo.rev160101.BooleanContainerBuilder) BooleanListIntBuilder(org.opendaylight.yang.gen.v1.urn.yang.foo.rev160101._boolean.container.BooleanListIntBuilder) NormalizedNode(org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode) Test(org.junit.Test)

Example 2 with BooleanContainerBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns._default.value.test.norev.BooleanContainerBuilder in project mdsal by opendaylight.

the class LeafDefaultValueTest method testBooleanDefaultValue.

@Test
public void testBooleanDefaultValue() throws ExecutionException, InterruptedException {
    final WriteTransaction writeTx = getDataBroker().newWriteOnlyTransaction();
    writeTx.put(LogicalDatastoreType.OPERATIONAL, BOOLEAN_NODE_PATH, new BooleanContainerBuilder().build());
    writeTx.commit().get();
    final ReadTransaction readTx = getDataBroker().newReadOnlyTransaction();
    final Optional<BooleanContainer> booleanContainerNode = readTx.read(LogicalDatastoreType.OPERATIONAL, BOOLEAN_NODE_PATH).get();
    assertTrue(booleanContainerNode.isPresent());
    BooleanContainer boolCont = booleanContainerNode.get();
    assertTrue(boolCont.getBooleanLeaf());
    assertNull(boolCont.getBooleanLeaf2());
}
Also used : WriteTransaction(org.opendaylight.mdsal.binding.api.WriteTransaction) ReadTransaction(org.opendaylight.mdsal.binding.api.ReadTransaction) BooleanContainerBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns._default.value.test.norev.BooleanContainerBuilder) BooleanContainer(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns._default.value.test.norev.BooleanContainer) AbstractDataBrokerTest(org.opendaylight.mdsal.binding.dom.adapter.test.AbstractDataBrokerTest) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)2 ReadTransaction (org.opendaylight.mdsal.binding.api.ReadTransaction)1 WriteTransaction (org.opendaylight.mdsal.binding.api.WriteTransaction)1 AbstractDataBrokerTest (org.opendaylight.mdsal.binding.dom.adapter.test.AbstractDataBrokerTest)1 BooleanContainer (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns._default.value.test.norev.BooleanContainer)1 BooleanContainerBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns._default.value.test.norev.BooleanContainerBuilder)1 BooleanContainer (org.opendaylight.yang.gen.v1.urn.yang.foo.rev160101.BooleanContainer)1 BooleanContainerBuilder (org.opendaylight.yang.gen.v1.urn.yang.foo.rev160101.BooleanContainerBuilder)1 BooleanListBuilder (org.opendaylight.yang.gen.v1.urn.yang.foo.rev160101._boolean.container.BooleanListBuilder)1 BooleanListIntBuilder (org.opendaylight.yang.gen.v1.urn.yang.foo.rev160101._boolean.container.BooleanListIntBuilder)1 BooleanListIntKey (org.opendaylight.yang.gen.v1.urn.yang.foo.rev160101._boolean.container.BooleanListIntKey)1 BooleanListKey (org.opendaylight.yang.gen.v1.urn.yang.foo.rev160101._boolean.container.BooleanListKey)1 NormalizedNode (org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode)1