Code clean up
[bgpcep.git] / bgp / mvpn / src / test / java / org / opendaylight / protocol / bgp / mvpn / impl / TableTypeActivatorTest.java
1 /*
2  * Copyright (c) 2018 AT&T Intellectual Property. 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
9 package org.opendaylight.protocol.bgp.mvpn.impl;
10
11 import java.util.Optional;
12 import org.junit.Assert;
13 import org.junit.Test;
14 import org.opendaylight.protocol.bgp.openconfig.spi.SimpleBGPTableTypeRegistryProvider;
15 import org.opendaylight.protocol.bgp.parser.BgpTableTypeImpl;
16 import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009.AfiSafiType;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.BgpTableType;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.mvpn.rev180417.McastVpnSubsequentAddressFamily;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180329.IPV4MCASTVPN;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180329.IPV6MCASTVPN;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.Ipv4AddressFamily;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.Ipv6AddressFamily;
23
24 public final class TableTypeActivatorTest {
25
26     private static final BgpTableType MVPN_IPV4 = new BgpTableTypeImpl(
27             Ipv4AddressFamily.class, McastVpnSubsequentAddressFamily.class);
28     private static final BgpTableType MVPN_IPV6 = new BgpTableTypeImpl(
29             Ipv6AddressFamily.class, McastVpnSubsequentAddressFamily.class);
30
31     @Test
32     public void testActivator() {
33         final TableTypeActivator tableTypeActivator = new TableTypeActivator();
34         final SimpleBGPTableTypeRegistryProvider registry = new SimpleBGPTableTypeRegistryProvider();
35         tableTypeActivator.startBGPTableTypeRegistryProvider(registry);
36
37         final Optional<Class<? extends AfiSafiType>> afiSafiType4 = registry.getAfiSafiType(MVPN_IPV4);
38         Assert.assertEquals(IPV4MCASTVPN.class, afiSafiType4.get());
39         final Optional<Class<? extends AfiSafiType>> afiSafiType6 = registry.getAfiSafiType(MVPN_IPV6);
40         Assert.assertEquals(IPV6MCASTVPN.class, afiSafiType6.get());
41
42         final Optional<BgpTableType> tableType4 = registry.getTableType(IPV4MCASTVPN.class);
43         Assert.assertEquals(MVPN_IPV4, tableType4.get());
44         final Optional<BgpTableType> tableType6 = registry.getTableType(IPV6MCASTVPN.class);
45         Assert.assertEquals(MVPN_IPV6, tableType6.get());
46
47         tableTypeActivator.stopBGPTableTypeRegistryProvider();
48         tableTypeActivator.close();
49     }
50 }