Search in sources :

Example 21 with ChoiceNode

use of org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode in project bgpcep by opendaylight.

the class MultiPathAbstractRIBSupportTest method emptyRoutes.

@Test
public void emptyRoutes() {
    final ChoiceNode emptyRoutes = Builders.choiceBuilder().withNodeIdentifier(ROUTES_IDENTIFIER).addChild(Builders.containerBuilder().withNodeIdentifier(IPV4_ROUTES_IDENTIFIER).withChild(ImmutableNodes.mapNodeBuilder(MULTI_PATH_ABSTRACT_TEST.routeQName()).build()).build()).build();
    assertEquals(emptyRoutes, MULTI_PATH_ABSTRACT_TEST.emptyRoutes());
}
Also used : ChoiceNode(org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode) MultiPathAbstractTest(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev171207.ipv4.routes.ipv4.routes.MultiPathAbstractTest) Test(org.junit.Test)

Example 22 with ChoiceNode

use of org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode in project controller by opendaylight.

the class SerializationUtilsTest method createNormalizedNode.

private static NormalizedNode<?, ?> createNormalizedNode() {
    final LeafSetNode<Object> leafSetNode = Builders.leafSetBuilder().withNodeIdentifier(id("leafSetNode")).withChild(createLeafSetEntry("leafSetNode", "leafSetValue1")).withChild(createLeafSetEntry("leafSetNode", "leafSetValue2")).build();
    final LeafSetNode<Object> orderedLeafSetNode = Builders.orderedLeafSetBuilder().withNodeIdentifier(id("orderedLeafSetNode")).withChild(createLeafSetEntry("orderedLeafSetNode", "value1")).withChild(createLeafSetEntry("orderedLeafSetNode", "value2")).build();
    final LeafNode<Boolean> booleanLeaf = createLeaf("booleanLeaf", true);
    final LeafNode<Byte> byteLeaf = createLeaf("byteLeaf", (byte) 0);
    final LeafNode<Short> shortLeaf = createLeaf("shortLeaf", (short) 55);
    final LeafNode<Integer> intLeaf = createLeaf("intLeaf", 11);
    final LeafNode<Long> longLeaf = createLeaf("longLeaf", 151515L);
    final LeafNode<String> stringLeaf = createLeaf("stringLeaf", "stringValue");
    final LeafNode<String> longStringLeaf = createLeaf("longStringLeaf", getLongString());
    final LeafNode<QName> qNameLeaf = createLeaf("stringLeaf", QName.create("base", "qName"));
    final LeafNode<YangInstanceIdentifier> idLeaf = createLeaf("stringLeaf", YangInstanceIdentifier.EMPTY);
    final MapEntryNode entry1 = Builders.mapEntryBuilder().withNodeIdentifier(listId("mapNode", "key", "key1")).withChild(stringLeaf).build();
    final MapEntryNode entry2 = Builders.mapEntryBuilder().withNodeIdentifier(listId("mapNode", "key", "key2")).withChild(stringLeaf).build();
    final MapNode mapNode = Builders.mapBuilder().withNodeIdentifier(id("mapNode")).withChild(entry1).withChild(entry2).build();
    final OrderedMapNode orderedMapNode = Builders.orderedMapBuilder().withNodeIdentifier(id("orderedMapNode")).withChild(entry2).withChild(entry1).build();
    final UnkeyedListEntryNode unkeyedListEntry1 = Builders.unkeyedListEntryBuilder().withNodeIdentifier(id("unkeyedList")).withChild(stringLeaf).build();
    final UnkeyedListEntryNode unkeyedListEntry2 = Builders.unkeyedListEntryBuilder().withNodeIdentifier(id("unkeyedList")).withChild(stringLeaf).build();
    final UnkeyedListNode unkeyedListNode = Builders.unkeyedListBuilder().withNodeIdentifier(id("unkeyedList")).withChild(unkeyedListEntry1).withChild(unkeyedListEntry2).build();
    final ImmutableSet<QName> childNames = ImmutableSet.of(QName.create(CONTAINER_Q_NAME, "aug1"), QName.create(CONTAINER_Q_NAME, "aug1"));
    final AugmentationNode augmentationNode = Builders.augmentationBuilder().withNodeIdentifier(new YangInstanceIdentifier.AugmentationIdentifier(childNames)).withChild(createLeaf("aug1", "aug1Value")).withChild(createLeaf("aug2", "aug2Value")).build();
    final ChoiceNode choiceNode = Builders.choiceBuilder().withNodeIdentifier(id("choiceNode")).withChild(createLeaf("choiceLeaf", 12)).build();
    return Builders.containerBuilder().withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(CONTAINER_Q_NAME)).withChild(booleanLeaf).withChild(byteLeaf).withChild(shortLeaf).withChild(intLeaf).withChild(longLeaf).withChild(stringLeaf).withChild(longStringLeaf).withChild(qNameLeaf).withChild(idLeaf).withChild(mapNode).withChild(orderedMapNode).withChild(unkeyedListNode).withChild(leafSetNode).withChild(orderedLeafSetNode).withChild(augmentationNode).withChild(choiceNode).build();
}
Also used : UnkeyedListEntryNode(org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListEntryNode) OrderedMapNode(org.opendaylight.yangtools.yang.data.api.schema.OrderedMapNode) MapNode(org.opendaylight.yangtools.yang.data.api.schema.MapNode) OrderedMapNode(org.opendaylight.yangtools.yang.data.api.schema.OrderedMapNode) ChoiceNode(org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) UnkeyedListNode(org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListNode) QName(org.opendaylight.yangtools.yang.common.QName) MapEntryNode(org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode) YangInstanceIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier) AugmentationNode(org.opendaylight.yangtools.yang.data.api.schema.AugmentationNode)

Example 23 with ChoiceNode

use of org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode in project bgpcep by opendaylight.

the class TableContext method createTable.

void createTable(final DOMDataWriteTransaction tx) {
    final DataContainerNodeBuilder<NodeIdentifierWithPredicates, MapEntryNode> tb = ImmutableNodes.mapEntryBuilder();
    tb.withNodeIdentifier((NodeIdentifierWithPredicates) this.tableId.getLastPathArgument());
    tb.withChild(EMPTY_TABLE_ATTRIBUTES);
    // tableId is keyed, but that fact is not directly visible from YangInstanceIdentifier, see BUG-2796
    final NodeIdentifierWithPredicates tableKey = (NodeIdentifierWithPredicates) this.tableId.getLastPathArgument();
    for (final Map.Entry<QName, Object> e : tableKey.getKeyValues().entrySet()) {
        tb.withChild(ImmutableNodes.leafNode(e.getKey(), e.getValue()));
    }
    final ChoiceNode routes = this.tableSupport.emptyRoutes();
    Verify.verifyNotNull(routes, "Null empty routes in %s", this.tableSupport);
    tx.put(LogicalDatastoreType.OPERATIONAL, this.tableId, tb.withChild(ImmutableChoiceNodeBuilder.create(routes).withNodeIdentifier(new NodeIdentifier(TablesUtil.BMP_ROUTES_QNAME)).build()).build());
}
Also used : QName(org.opendaylight.yangtools.yang.common.QName) NodeIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier) ChoiceNode(org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode) NodeIdentifierWithPredicates(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates) MapEntryNode(org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode) Map(java.util.Map)

Example 24 with ChoiceNode

use of org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode in project bgpcep by opendaylight.

the class EthSegRParserTest method parserTest.

@Test
public void parserTest() {
    final EsRouteCase expected = new EsRouteCaseBuilder().setEsRoute(new EsRouteBuilder().setEsi(LAN_AUT_GEN_CASE).setOrigRouteIp(IP).build()).build();
    assertArrayEquals(RESULT, ByteArray.getAllBytes(this.parser.serializeEvpn(expected, Unpooled.wrappedBuffer(ROUDE_DISTIN))));
    final EvpnChoice result = this.parser.parseEvpn(Unpooled.wrappedBuffer(VALUE));
    assertEquals(expected, result);
    final DataContainerNodeBuilder<YangInstanceIdentifier.NodeIdentifier, ChoiceNode> choice = Builders.choiceBuilder();
    choice.withNodeIdentifier(EthSegRParser.ES_ROUTE_NID);
    final ContainerNode arbitraryC = createContBuilder(EthSegRParser.ES_ROUTE_NID).addChild(LanParserTest.createLanChoice()).addChild(createValueBuilder(IP_MODEL, ORI_NID).build()).build();
    final EvpnChoice modelResult = this.parser.serializeEvpnModel(arbitraryC);
    assertEquals(expected, modelResult);
    final EvpnChoice keyResult = this.parser.createRouteKey(arbitraryC);
    assertEquals(expected, keyResult);
}
Also used : EsRouteCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev171213.evpn.evpn.choice.EsRouteCase) EsRouteBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev171213.es.route.EsRouteBuilder) ChoiceNode(org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode) EvpnChoice(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev171213.evpn.EvpnChoice) ContainerNode(org.opendaylight.yangtools.yang.data.api.schema.ContainerNode) EsRouteCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev171213.evpn.evpn.choice.EsRouteCaseBuilder) LanParserTest(org.opendaylight.protocol.bgp.evpn.impl.esi.types.LanParserTest) Test(org.junit.Test)

Example 25 with ChoiceNode

use of org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode in project bgpcep by opendaylight.

the class SimpleEsiTypeRegistryTest method registryNullModelTest.

@Test(expected = IllegalArgumentException.class)
public void registryNullModelTest() {
    final DataContainerNodeBuilder<NodeIdentifier, ChoiceNode> noRegister = Builders.choiceBuilder();
    noRegister.withNodeIdentifier(new NodeIdentifier(QName.create(EvpnRoute.QNAME, "no-register").intern()));
    assertNull(SimpleEsiTypeRegistry.getInstance().parseEsiModel(noRegister.build()));
}
Also used : NodeIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier) ChoiceNode(org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode) RouterIdParserTest(org.opendaylight.protocol.bgp.evpn.impl.esi.types.RouterIdParserTest) Test(org.junit.Test)

Aggregations

ChoiceNode (org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode)34 Test (org.junit.Test)22 AbstractRIBSupportTest (org.opendaylight.protocol.bgp.rib.spi.AbstractRIBSupportTest)12 Routes (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.rib.tables.Routes)12 NodeIdentifier (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier)11 ContainerNode (org.opendaylight.yangtools.yang.data.api.schema.ContainerNode)9 UnkeyedListEntryNode (org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListEntryNode)6 EvpnChoice (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev171213.evpn.EvpnChoice)5 MapEntryNode (org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode)5 BigInteger (java.math.BigInteger)4 ImmutableLeafNodeBuilder (org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableLeafNodeBuilder)4 ByteBuf (io.netty.buffer.ByteBuf)3 LanParserTest (org.opendaylight.protocol.bgp.evpn.impl.esi.types.LanParserTest)3 AsNumber (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.AsNumber)3 QName (org.opendaylight.yangtools.yang.common.QName)3 Before (org.junit.Before)2 DOMDataWriteTransaction (org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction)2 EsRouteBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev171213.es.route.EsRouteBuilder)2 EsRouteCase (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev171213.evpn.evpn.choice.EsRouteCase)2 EsRouteCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev171213.evpn.evpn.choice.EsRouteCaseBuilder)2