Search in sources :

Example 21 with NodeIdentifier

use of org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier in project bgpcep by opendaylight.

the class LinkstateNlriParserTest method testLinkNlri.

@Test
public void testLinkNlri() throws BGPParsingException {
    setUp(this.linkNlri);
    // test BA form
    assertNull(this.dest.getDistinguisher());
    assertEquals(ProtocolId.IsisLevel2, this.dest.getProtocolId());
    assertEquals(BigInteger.ONE, this.dest.getIdentifier().getValue());
    final LinkCase lCase = ((LinkCase) this.dest.getObjectType());
    final LocalNodeDescriptors local = lCase.getLocalNodeDescriptors();
    assertEquals(new AsNumber(72L), local.getAsNumber());
    assertEquals(new DomainIdentifier(0x28282828L), local.getDomainId());
    assertEquals(new IsisNodeCaseBuilder().setIsisNode(new IsisNodeBuilder().setIsoSystemId(new IsoSystemIdentifier(new byte[] { (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x42 })).build()).build(), local.getCRouterIdentifier());
    assertEquals("1.1.1.1", local.getBgpRouterId().getValue());
    assertEquals(new AsNumber(258L), local.getMemberAsn());
    final RemoteNodeDescriptors remote = lCase.getRemoteNodeDescriptors();
    assertEquals(new AsNumber(72L), remote.getAsNumber());
    assertEquals(new DomainIdentifier(0x28282828L), remote.getDomainId());
    assertEquals(new OspfNodeCaseBuilder().setOspfNode(new OspfNodeBuilder().setOspfRouterId(0x00000040L).build()).build(), remote.getCRouterIdentifier());
    assertEquals(new AsNumber(259L), remote.getMemberAsn());
    assertEquals("1.1.1.2", remote.getBgpRouterId().getValue());
    final LinkDescriptors ld = lCase.getLinkDescriptors();
    assertEquals("197.20.160.42", ld.getIpv4InterfaceAddress().getValue());
    assertEquals("197.20.160.40", ld.getIpv4NeighborAddress().getValue());
    final ByteBuf buffer = Unpooled.buffer();
    this.registry.serializeNlriType(this.dest, buffer);
    assertArrayEquals(this.linkNlri, ByteArray.readAllBytes(buffer));
    // test BI form
    final DataContainerNodeAttrBuilder<YangInstanceIdentifier.NodeIdentifier, UnkeyedListEntryNode> linkstateBI = ImmutableUnkeyedListEntryNodeBuilder.create();
    linkstateBI.withNodeIdentifier(C_LINKSTATE_NID);
    final ImmutableLeafNodeBuilder<String> protocolId = new ImmutableLeafNodeBuilder<>();
    protocolId.withNodeIdentifier(LinkstateNlriParser.PROTOCOL_ID_NID);
    protocolId.withValue("isis-level2");
    linkstateBI.addChild(protocolId.build());
    final ImmutableLeafNodeBuilder<BigInteger> identifier = new ImmutableLeafNodeBuilder<>();
    identifier.withNodeIdentifier(LinkstateNlriParser.IDENTIFIER_NID);
    identifier.withValue(BigInteger.ONE);
    linkstateBI.addChild(identifier.build());
    final DataContainerNodeBuilder<NodeIdentifier, ChoiceNode> objectType = Builders.choiceBuilder();
    objectType.withNodeIdentifier(LinkstateNlriParser.OBJECT_TYPE_NID);
    // local node descriptors
    final DataContainerNodeAttrBuilder<NodeIdentifier, ContainerNode> localNodeDescriptors = Builders.containerBuilder();
    localNodeDescriptors.withNodeIdentifier(LinkstateNlriParser.LOCAL_NODE_DESCRIPTORS_NID);
    final ImmutableLeafNodeBuilder<Long> asNumber = new ImmutableLeafNodeBuilder<>();
    asNumber.withNodeIdentifier(NodeNlriParser.AS_NUMBER_NID);
    asNumber.withValue(72L);
    localNodeDescriptors.addChild(asNumber.build());
    final ImmutableLeafNodeBuilder<Long> domainID = new ImmutableLeafNodeBuilder<>();
    domainID.withNodeIdentifier(NodeNlriParser.DOMAIN_NID);
    domainID.withValue(0x28282828L);
    localNodeDescriptors.addChild(domainID.build());
    final DataContainerNodeBuilder<NodeIdentifier, ChoiceNode> crouterId = Builders.choiceBuilder();
    crouterId.withNodeIdentifier(C_ROUTER_ID_NID);
    final DataContainerNodeAttrBuilder<NodeIdentifier, ContainerNode> isisNode = Builders.containerBuilder();
    isisNode.withNodeIdentifier(NodeNlriParser.ISIS_NODE_NID);
    final ImmutableLeafNodeBuilder<byte[]> isoSystemID = new ImmutableLeafNodeBuilder<>();
    isoSystemID.withNodeIdentifier(NodeNlriParser.ISO_SYSTEM_NID);
    isoSystemID.withValue(new byte[] { 0, 0, 0, 0, 0, (byte) 0x42 });
    isisNode.addChild(isoSystemID.build());
    crouterId.addChild(isisNode.build());
    localNodeDescriptors.addChild(crouterId.build());
    final ImmutableLeafNodeBuilder<String> bgpRouterId = new ImmutableLeafNodeBuilder<>();
    bgpRouterId.withNodeIdentifier(NodeNlriParser.BGP_ROUTER_NID);
    bgpRouterId.withValue("1.1.1.1");
    final ImmutableLeafNodeBuilder<Long> memberAsn = new ImmutableLeafNodeBuilder<>();
    memberAsn.withNodeIdentifier(NodeNlriParser.MEMBER_ASN_NID);
    memberAsn.withValue(258L);
    localNodeDescriptors.addChild(bgpRouterId.build());
    localNodeDescriptors.addChild(memberAsn.build());
    // remote descriptors
    final DataContainerNodeAttrBuilder<NodeIdentifier, ContainerNode> remoteNodeDescriptors = Builders.containerBuilder();
    remoteNodeDescriptors.withNodeIdentifier(LinkstateNlriParser.REMOTE_NODE_DESCRIPTORS_NID);
    remoteNodeDescriptors.addChild(asNumber.build());
    remoteNodeDescriptors.addChild(domainID.build());
    final DataContainerNodeBuilder<NodeIdentifier, ChoiceNode> crouterId2 = Builders.choiceBuilder();
    crouterId2.withNodeIdentifier(C_ROUTER_ID_NID);
    final DataContainerNodeAttrBuilder<NodeIdentifier, ContainerNode> ospfNode = Builders.containerBuilder();
    ospfNode.withNodeIdentifier(NodeNlriParser.OSPF_NODE_NID);
    final ImmutableLeafNodeBuilder<Long> ospfRouterId = new ImmutableLeafNodeBuilder<>();
    ospfRouterId.withNodeIdentifier(NodeNlriParser.OSPF_ROUTER_NID);
    ospfRouterId.withValue(0x00000040L);
    ospfNode.addChild(ospfRouterId.build());
    crouterId2.addChild(ospfNode.build());
    remoteNodeDescriptors.addChild(crouterId2.build());
    final ImmutableLeafNodeBuilder<String> bgpRouterIdRemote = new ImmutableLeafNodeBuilder<>();
    bgpRouterIdRemote.withNodeIdentifier(NodeNlriParser.BGP_ROUTER_NID);
    bgpRouterIdRemote.withValue("1.1.1.2");
    remoteNodeDescriptors.addChild(bgpRouterIdRemote.build());
    final ImmutableLeafNodeBuilder<Long> memberAsnRemote = new ImmutableLeafNodeBuilder<>();
    memberAsnRemote.withNodeIdentifier(NodeNlriParser.MEMBER_ASN_NID);
    memberAsnRemote.withValue(259L);
    remoteNodeDescriptors.addChild(memberAsnRemote.build());
    // link descritpors
    final DataContainerNodeAttrBuilder<NodeIdentifier, ContainerNode> linkDescriptors = Builders.containerBuilder();
    linkDescriptors.withNodeIdentifier(LinkstateNlriParser.LINK_DESCRIPTORS_NID);
    final ImmutableLeafNodeBuilder<Long> linkLocalIdentifier = new ImmutableLeafNodeBuilder<>();
    linkLocalIdentifier.withNodeIdentifier(LinkNlriParser.LINK_LOCAL_NID);
    linkLocalIdentifier.withValue(16909060L);
    final ImmutableLeafNodeBuilder<Long> linkRemoteIdentifier = new ImmutableLeafNodeBuilder<>();
    linkRemoteIdentifier.withNodeIdentifier(LinkNlriParser.LINK_REMOTE_NID);
    linkRemoteIdentifier.withValue(168496141L);
    final ImmutableLeafNodeBuilder<String> ipv4InterfaceAddress = new ImmutableLeafNodeBuilder<>();
    ipv4InterfaceAddress.withNodeIdentifier(LinkNlriParser.IPV4_IFACE_NID);
    ipv4InterfaceAddress.withValue("197.20.160.42");
    final ImmutableLeafNodeBuilder<String> ipv4NeighborAddress = new ImmutableLeafNodeBuilder<>();
    ipv4NeighborAddress.withNodeIdentifier(LinkNlriParser.IPV4_NEIGHBOR_NID);
    ipv4NeighborAddress.withValue("197.20.160.40");
    final ImmutableLeafNodeBuilder<Integer> multiTopologyId = new ImmutableLeafNodeBuilder<>();
    multiTopologyId.withNodeIdentifier(TlvUtil.MULTI_TOPOLOGY_NID);
    multiTopologyId.withValue(3);
    linkDescriptors.addChild(linkLocalIdentifier.build());
    linkDescriptors.addChild(linkRemoteIdentifier.build());
    linkDescriptors.addChild(ipv4InterfaceAddress.build());
    linkDescriptors.addChild(ipv4NeighborAddress.build());
    linkDescriptors.addChild(multiTopologyId.build());
    objectType.addChild(localNodeDescriptors.build());
    objectType.addChild(remoteNodeDescriptors.build());
    objectType.addChild(linkDescriptors.build());
    linkstateBI.addChild(objectType.build());
    assertEquals(this.dest, LinkstateNlriParser.extractLinkstateDestination(linkstateBI.build()));
}
Also used : UnkeyedListEntryNode(org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListEntryNode) ByteBuf(io.netty.buffer.ByteBuf) IsisNodeCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.node.identifier.c.router.identifier.IsisNodeCaseBuilder) LocalNodeDescriptors(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.linkstate.object.type.link._case.LocalNodeDescriptors) OspfNodeBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.node.identifier.c.router.identifier.ospf.node._case.OspfNodeBuilder) ChoiceNode(org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode) OspfNodeCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.node.identifier.c.router.identifier.OspfNodeCaseBuilder) ContainerNode(org.opendaylight.yangtools.yang.data.api.schema.ContainerNode) DomainIdentifier(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.DomainIdentifier) LinkCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.linkstate.object.type.LinkCase) IsoSystemIdentifier(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.network.concepts.rev131125.IsoSystemIdentifier) AsNumber(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.AsNumber) LinkDescriptors(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.linkstate.object.type.link._case.LinkDescriptors) RemoteNodeDescriptors(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.linkstate.object.type.link._case.RemoteNodeDescriptors) BigInteger(java.math.BigInteger) IsisNodeBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.node.identifier.c.router.identifier.isis.node._case.IsisNodeBuilder) NodeIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier) BigInteger(java.math.BigInteger) ImmutableLeafNodeBuilder(org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableLeafNodeBuilder) Test(org.junit.Test)

Example 22 with NodeIdentifier

use of org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier in project bgpcep by opendaylight.

the class LinkstateNlriParserTest method testTELspNlri.

@Test
public void testTELspNlri() throws BGPParsingException {
    setUp(this.teLspNlri);
    // test BA form
    assertNull(this.dest.getDistinguisher());
    assertEquals(ProtocolId.RsvpTe, this.dest.getProtocolId());
    assertEquals(BigInteger.ONE, this.dest.getIdentifier().getValue());
    final TeLspCase teCase = (TeLspCase) this.dest.getObjectType();
    assertEquals(new LspId(1L), teCase.getLspId());
    assertEquals(new TunnelId(1), teCase.getTunnelId());
    assertEquals(new Ipv4Address("1.2.3.4"), ((Ipv4Case) teCase.getAddressFamily()).getIpv4TunnelSenderAddress());
    assertEquals(new Ipv4Address("4.3.2.1"), ((Ipv4Case) teCase.getAddressFamily()).getIpv4TunnelEndpointAddress());
    // test BI form
    final DataContainerNodeAttrBuilder<YangInstanceIdentifier.NodeIdentifier, UnkeyedListEntryNode> linkstateBI = ImmutableUnkeyedListEntryNodeBuilder.create();
    linkstateBI.withNodeIdentifier(C_LINKSTATE_NID);
    final ImmutableLeafNodeBuilder<String> protocolId = new ImmutableLeafNodeBuilder<>();
    protocolId.withNodeIdentifier(LinkstateNlriParser.PROTOCOL_ID_NID);
    protocolId.withValue("rsvp-te");
    linkstateBI.addChild(protocolId.build());
    final ImmutableLeafNodeBuilder<BigInteger> identifier = new ImmutableLeafNodeBuilder<>();
    identifier.withNodeIdentifier(LinkstateNlriParser.IDENTIFIER_NID);
    identifier.withValue(BigInteger.ONE);
    linkstateBI.addChild(identifier.build());
    final DataContainerNodeBuilder<NodeIdentifier, ChoiceNode> objectType = Builders.choiceBuilder();
    objectType.withNodeIdentifier(LinkstateNlriParser.OBJECT_TYPE_NID);
    final ImmutableLeafNodeBuilder<Long> lspId = new ImmutableLeafNodeBuilder<>();
    lspId.withNodeIdentifier(AbstractTeLspNlriCodec.LSP_ID);
    lspId.withValue(1L);
    final ImmutableLeafNodeBuilder<Integer> tunnelId = new ImmutableLeafNodeBuilder<>();
    tunnelId.withNodeIdentifier(AbstractTeLspNlriCodec.TUNNEL_ID);
    tunnelId.withValue(1);
    final DataContainerNodeBuilder<NodeIdentifier, ChoiceNode> addressFamily = Builders.choiceBuilder();
    addressFamily.withNodeIdentifier(AbstractTeLspNlriCodec.ADDRESS_FAMILY);
    final ImmutableLeafNodeBuilder<String> ipv4TunnelSenderAddress = new ImmutableLeafNodeBuilder<>();
    ipv4TunnelSenderAddress.withNodeIdentifier(AbstractTeLspNlriCodec.IPV4_TUNNEL_SENDER_ADDRESS);
    ipv4TunnelSenderAddress.withValue("1.2.3.4");
    final ImmutableLeafNodeBuilder<String> ipv4TunnelEndPointAddress = new ImmutableLeafNodeBuilder<>();
    ipv4TunnelEndPointAddress.withNodeIdentifier(AbstractTeLspNlriCodec.IPV4_TUNNEL_ENDPOINT_ADDRESS);
    ipv4TunnelEndPointAddress.withValue("4.3.2.1");
    addressFamily.addChild(ipv4TunnelSenderAddress.build());
    addressFamily.addChild(ipv4TunnelEndPointAddress.build());
    objectType.addChild(lspId.build());
    objectType.addChild(tunnelId.build());
    objectType.addChild(addressFamily.build());
    linkstateBI.addChild(objectType.build());
    assertEquals(this.dest, LinkstateNlriParser.extractLinkstateDestination(linkstateBI.build()));
}
Also used : LspId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.LspId) TeLspCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.linkstate.object.type.TeLspCase) UnkeyedListEntryNode(org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListEntryNode) TunnelId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.TunnelId) BigInteger(java.math.BigInteger) NodeIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier) BigInteger(java.math.BigInteger) ChoiceNode(org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode) ImmutableLeafNodeBuilder(org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableLeafNodeBuilder) Ipv4Address(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address) Test(org.junit.Test)

Example 23 with NodeIdentifier

use of org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier in project bgpcep by opendaylight.

the class BmpRouterPeerImpl method createPeerEntry.

private MapEntryNode createPeerEntry(final PeerUpNotification peerUp) {
    final PeerHeader peerHeader = peerUp.getPeerHeader();
    final DataContainerNodeAttrBuilder<NodeIdentifierWithPredicates, MapEntryNode> mapEntryBuilder = Builders.mapEntryBuilder().withNodeIdentifier(new NodeIdentifierWithPredicates(Peer.QNAME, PEER_ID_QNAME, this.peerId.getValue())).withChild(ImmutableNodes.leafNode(PEER_ID_QNAME, this.peerId.getValue())).withChild(ImmutableNodes.leafNode(PEER_TYPE_QNAME, peerHeader.getType().name().toLowerCase(Locale.ENGLISH))).withChild(ImmutableNodes.leafNode(PEER_ADDRESS_QNAME, getStringIpAddress(peerHeader.getAddress()))).withChild(ImmutableNodes.leafNode(PEER_AS_QNAME, peerHeader.getAs().getValue())).withChild(ImmutableNodes.leafNode(PEER_BGP_ID_QNAME, peerHeader.getBgpId().getValue())).withChild(createPeerSessionUp(peerUp, peerHeader.getTimestampSec())).withChild(Builders.containerBuilder().withNodeIdentifier(new NodeIdentifier(PrePolicyRib.QNAME)).withChild(ImmutableNodes.mapNodeBuilder(BMP_TABLES_QNAME).build()).build()).withChild(Builders.containerBuilder().withNodeIdentifier(new NodeIdentifier(PostPolicyRib.QNAME)).withChild(ImmutableNodes.mapNodeBuilder(BMP_TABLES_QNAME).build()).build());
    final PeerDistinguisher pd = peerHeader.getPeerDistinguisher();
    if (pd != null) {
        mapEntryBuilder.withChild(ImmutableNodes.leafNode(PEER_DISTINGUISHER_QNAME, pd.getRouteDistinguisher()));
    }
    return mapEntryBuilder.build();
}
Also used : PeerHeader(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev171207.peer.header.PeerHeader) NodeIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier) NodeIdentifierWithPredicates(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates) MapEntryNode(org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode) PeerDistinguisher(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev171207.Peer.PeerDistinguisher)

Example 24 with NodeIdentifier

use of org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier in project bgpcep by opendaylight.

the class MultiPathAbstractRIBSupportTest method setUp.

@Before
public void setUp() {
    this.routesMap = new HashMap<>();
    MockitoAnnotations.initMocks(this);
    this.emptyTree = Mockito.mock(DataTreeCandidateNode.class);
    this.emptySubTree = Mockito.mock(DataTreeCandidateNode.class);
    this.subTree = Mockito.mock(DataTreeCandidateNode.class);
    final DataTreeCandidateNode emptyNode = Mockito.mock(DataTreeCandidateNode.class);
    final DataTreeCandidateNode node = Mockito.mock(DataTreeCandidateNode.class);
    doReturn(null).when(this.emptyTree).getModifiedChild(IPV4_ROUTES_IDENTIFIER);
    doReturn(emptyNode).when(this.emptySubTree).getModifiedChild(IPV4_ROUTES_IDENTIFIER);
    doReturn(null).when(emptyNode).getModifiedChild(new NodeIdentifier(Ipv4Route.QNAME));
    doReturn(node).when(this.subTree).getModifiedChild(IPV4_ROUTES_IDENTIFIER);
    doReturn(node).when(node).getModifiedChild(new NodeIdentifier(Ipv4Route.QNAME));
    final Collection<DataTreeCandidateNode> emptyCollection = new HashSet<>();
    doReturn(emptyCollection).when(node).getChildNodes();
    this.tx = Mockito.mock(DOMDataWriteTransaction.class);
    this.nlri = Mockito.mock(ContainerNode.class);
    this.attributes = ImmutableContainerNodeBuilder.create().withNodeIdentifier(new NodeIdentifier(QName.create(Ipv4Routes.QNAME, Attributes.QNAME.getLocalName().intern()))).build();
    final ContainerNode destination = Mockito.mock(ContainerNode.class);
    final ChoiceNode destinations = Mockito.mock(ChoiceNode.class);
    final ContainerNode route = Mockito.mock(ContainerNode.class);
    final Optional<?> optional = Optional.of(destination);
    final Optional<?> destinationOptional = Optional.of(destinations);
    final Optional<?> destinationsOptional = Optional.of(route);
    doReturn(optional).when(this.nlri).getChild(new NodeIdentifier(WithdrawnRoutes.QNAME));
    doReturn(optional).when(this.nlri).getChild(new NodeIdentifier(AdvertizedRoutes.QNAME));
    doReturn(destinationOptional).when(destination).getChild(new NodeIdentifier(DestinationType.QNAME));
    doReturn(destinationsOptional).when(destinations).getChild(new NodeIdentifier(Ipv4Prefixes.QNAME));
    doReturn(emptyCollection).when(route).getValue();
    doAnswer(invocation -> {
        final Object[] args = invocation.getArguments();
        MultiPathAbstractRIBSupportTest.this.routesMap.remove(args[1]);
        return args[1];
    }).when(this.tx).delete(Mockito.eq(LogicalDatastoreType.OPERATIONAL), any(YangInstanceIdentifier.class));
    doAnswer(invocation -> {
        final Object[] args = invocation.getArguments();
        final NormalizedNode<?, ?> node1 = (NormalizedNode<?, ?>) args[2];
        MultiPathAbstractRIBSupportTest.this.routesMap.put((YangInstanceIdentifier) args[1], node1);
        return args[1];
    }).when(this.tx).put(Mockito.eq(LogicalDatastoreType.OPERATIONAL), any(YangInstanceIdentifier.class), any(NormalizedNode.class));
    this.mapEntryNode = Mockito.mock(MapEntryNode.class);
}
Also used : MapEntryNode(org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode) YangInstanceIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier) DataTreeCandidateNode(org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidateNode) NodeIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier) ChoiceNode(org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode) ContainerNode(org.opendaylight.yangtools.yang.data.api.schema.ContainerNode) NormalizedNode(org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode) DOMDataWriteTransaction(org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction) HashSet(java.util.HashSet) Before(org.junit.Before)

Example 25 with NodeIdentifier

use of org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier in project controller by opendaylight.

the class AbstractNormalizedNodeDataOutput method writePathArgument.

@SuppressFBWarnings(value = "BC_UNCONFIRMED_CAST", justification = "The casts in the switch clauses are indirectly confirmed via the determination of 'type'.")
@Override
public void writePathArgument(final PathArgument pathArgument) throws IOException {
    byte type = PathArgumentTypes.getSerializablePathArgumentType(pathArgument);
    output.writeByte(type);
    switch(type) {
        case PathArgumentTypes.NODE_IDENTIFIER:
            NodeIdentifier nodeIdentifier = (NodeIdentifier) pathArgument;
            writeQName(nodeIdentifier.getNodeType());
            break;
        case PathArgumentTypes.NODE_IDENTIFIER_WITH_PREDICATES:
            NodeIdentifierWithPredicates nodeIdentifierWithPredicates = (NodeIdentifierWithPredicates) pathArgument;
            writeQName(nodeIdentifierWithPredicates.getNodeType());
            writeKeyValueMap(nodeIdentifierWithPredicates.getKeyValues());
            break;
        case PathArgumentTypes.NODE_IDENTIFIER_WITH_VALUE:
            NodeWithValue<?> nodeWithValue = (NodeWithValue<?>) pathArgument;
            writeQName(nodeWithValue.getNodeType());
            writeObject(nodeWithValue.getValue());
            break;
        case PathArgumentTypes.AUGMENTATION_IDENTIFIER:
            AugmentationIdentifier augmentationIdentifier = (AugmentationIdentifier) pathArgument;
            // No Qname in augmentation identifier
            writeQNameSet(augmentationIdentifier.getPossibleChildNames());
            break;
        default:
            throw new IllegalStateException("Unknown node identifier type is found : " + pathArgument.getClass().toString());
    }
}
Also used : AugmentationIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.AugmentationIdentifier) NodeIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier) NodeWithValue(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeWithValue) NodeIdentifierWithPredicates(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates) SuppressFBWarnings(edu.umd.cs.findbugs.annotations.SuppressFBWarnings)

Aggregations

NodeIdentifier (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier)58 Test (org.junit.Test)34 ContainerNode (org.opendaylight.yangtools.yang.data.api.schema.ContainerNode)29 YangInstanceIdentifier (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier)12 ChoiceNode (org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode)11 MapEntryNode (org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode)11 NodeIdentifierWithPredicates (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates)10 DOMDataTreeWriteCursor (org.opendaylight.mdsal.dom.api.DOMDataTreeWriteCursor)8 ByteBuf (io.netty.buffer.ByteBuf)7 MapNode (org.opendaylight.yangtools.yang.data.api.schema.MapNode)7 NormalizedNode (org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode)7 UnkeyedListEntryNode (org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListEntryNode)7 DOMDataTreeCursorAwareTransaction (org.opendaylight.mdsal.dom.api.DOMDataTreeCursorAwareTransaction)6 DOMDataTreeProducer (org.opendaylight.mdsal.dom.api.DOMDataTreeProducer)6 AbstractTest (org.opendaylight.controller.cluster.datastore.AbstractTest)5 NodeWithValue (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeWithValue)5 BigInteger (java.math.BigInteger)4 ClientTransaction (org.opendaylight.controller.cluster.databroker.actors.dds.ClientTransaction)4 DistributedShardRegistration (org.opendaylight.controller.cluster.sharding.DistributedShardFactory.DistributedShardRegistration)4 DOMDataWriteTransaction (org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction)4