Fix most bgp-parser-spi checkstyle violations
[bgpcep.git] / bgp / parser-spi / src / test / java / org / opendaylight / protocol / bgp / parser / spi / pojo / MultiPathSupportImplTest.java
1 /*
2  * Copyright (c) 2016 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.protocol.bgp.parser.spi.pojo;
9
10 import com.google.common.collect.Lists;
11 import java.util.List;
12 import org.junit.Assert;
13 import org.junit.Test;
14 import org.opendaylight.protocol.bgp.parser.BgpTableTypeImpl;
15 import org.opendaylight.protocol.bgp.parser.spi.MultiPathSupport;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.BgpTableType;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.SendReceive;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.mp.capabilities.add.path.capability.AddressFamilies;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.mp.capabilities.add.path.capability.AddressFamiliesBuilder;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.Ipv4AddressFamily;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.Ipv6AddressFamily;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.MplsLabeledVpnSubsequentAddressFamily;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.UnicastSubsequentAddressFamily;
24
25 public class MultiPathSupportImplTest {
26
27     @Test(expected = NullPointerException.class)
28     public void testcreateParserMultiPathSupportNull() {
29         MultiPathSupportImpl.createParserMultiPathSupport(null);
30     }
31
32     @Test
33     public void testIsTableTypeSupported() {
34         final List<AddressFamilies> supportedTables = Lists.newArrayList();
35         final BgpTableType ipv4Unicast = new BgpTableTypeImpl(Ipv4AddressFamily.class,
36             UnicastSubsequentAddressFamily.class);
37         final BgpTableType ipv4L3vpn = new BgpTableTypeImpl(Ipv4AddressFamily.class,
38             MplsLabeledVpnSubsequentAddressFamily.class);
39         final BgpTableType ipv6Unicast = new BgpTableTypeImpl(Ipv6AddressFamily.class,
40             UnicastSubsequentAddressFamily.class);
41         final BgpTableType ipv6L3vpn = new BgpTableTypeImpl(Ipv6AddressFamily.class,
42             MplsLabeledVpnSubsequentAddressFamily.class);
43         supportedTables.add(createAddPathCapability(ipv4Unicast, SendReceive.Send));
44         supportedTables.add(createAddPathCapability(ipv4L3vpn, SendReceive.Receive));
45         supportedTables.add(createAddPathCapability(ipv6Unicast, SendReceive.Both));
46         final MultiPathSupport multiPathSupport = MultiPathSupportImpl.createParserMultiPathSupport(supportedTables);
47
48         Assert.assertTrue(multiPathSupport.isTableTypeSupported(ipv4Unicast));
49         Assert.assertTrue(multiPathSupport.isTableTypeSupported(ipv6Unicast));
50         Assert.assertFalse(multiPathSupport.isTableTypeSupported(ipv4L3vpn));
51         Assert.assertFalse(multiPathSupport.isTableTypeSupported(ipv6L3vpn));
52     }
53
54     private static AddressFamilies createAddPathCapability(final BgpTableType afisafi, final SendReceive mode) {
55         return new AddressFamiliesBuilder().setAfi(afisafi.getAfi()).setSafi(afisafi.getSafi()).setSendReceive(mode)
56                 .build();
57     }
58
59 }