2 * Copyright (c) 2015 Cisco Systems, 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.protocol.bgp.rib.impl;
10 import static org.junit.Assert.assertEquals;
11 import static org.junit.Assert.assertFalse;
12 import static org.junit.Assert.assertTrue;
14 import com.google.common.collect.ImmutableMap;
16 import org.junit.Test;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.bgp.rib.rib.peer.SupportedTables;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.Tables;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.TablesKey;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.Ipv4AddressFamily;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.UnicastSubsequentAddressFamily;
22 import org.opendaylight.yangtools.yang.common.QName;
23 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
25 public class RibSupportUtilsTest {
26 private static final NodeIdentifierWithPredicates NII;
27 private static final NodeIdentifierWithPredicates NII_PATH;
28 private static final TablesKey TABLE_KEY = new TablesKey(Ipv4AddressFamily.VALUE,
29 UnicastSubsequentAddressFamily.VALUE);
32 final QName afi = QName.create("urn:opendaylight:params:xml:ns:yang:bgp-rib?revision=2018-03-29", "afi");
33 final QName safi = QName.create("urn:opendaylight:params:xml:ns:yang:bgp-rib?revision=2018-03-29", "safi");
34 NII = NodeIdentifierWithPredicates.of(SupportedTables.QNAME, ImmutableMap.of(afi, Ipv4AddressFamily.QNAME,
35 safi, UnicastSubsequentAddressFamily.QNAME));
36 NII_PATH = NodeIdentifierWithPredicates.of(SupportedTables.QNAME, ImmutableMap.of(
37 QName.create("urn:opendaylight:params:xml:ns:yang:bgp-multiprotocol?revision=2018-03-29", "afi"),
38 Ipv4AddressFamily.QNAME,
39 QName.create("urn:opendaylight:params:xml:ns:yang:bgp-multiprotocol?revision=2018-03-29", "safi"),
40 UnicastSubsequentAddressFamily.QNAME));
44 public void testYangTablesKey() {
45 final NodeIdentifierWithPredicates p = RibSupportUtils.toYangTablesKey(TABLE_KEY);
46 final Map<QName, Object> m = p.asMap();
47 assertFalse(m.isEmpty());
48 assertEquals(Tables.QNAME, p.getNodeType());
49 assertTrue(m.containsValue(Ipv4AddressFamily.QNAME));
50 assertTrue(m.containsValue(UnicastSubsequentAddressFamily.QNAME));
54 public void testYangKey() {
55 final NodeIdentifierWithPredicates p = RibSupportUtils.toYangKey(SupportedTables.QNAME, TABLE_KEY);
56 final Map<QName, Object> m = p.asMap();
57 assertFalse(m.isEmpty());
58 assertEquals(SupportedTables.QNAME, p.getNodeType());
59 assertTrue(m.containsValue(Ipv4AddressFamily.QNAME));
60 assertTrue(m.containsValue(UnicastSubsequentAddressFamily.QNAME));
64 public void toYangPathKey() {
65 final NodeIdentifierWithPredicates result = RibSupportUtils.toYangPathKey(SupportedTables.QNAME,
66 Ipv4AddressFamily.VALUE, UnicastSubsequentAddressFamily.VALUE);
67 assertEquals(NII_PATH.toString(), result.toString());
71 public void toYangKey() {
72 final NodeIdentifierWithPredicates result = RibSupportUtils.toYangKey(SupportedTables.QNAME, TABLE_KEY);
73 assertEquals(NII.toString(), result.toString());