Code clean up
[bgpcep.git] / bgp / inet / src / test / java / org / opendaylight / protocol / bgp / inet / TableTypeActivatorTest.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
9 package org.opendaylight.protocol.bgp.inet;
10
11 import static org.junit.Assert.assertEquals;
12
13 import java.util.Optional;
14 import org.junit.Test;
15 import org.opendaylight.protocol.bgp.openconfig.spi.SimpleBGPTableTypeRegistryProvider;
16 import org.opendaylight.protocol.bgp.parser.BgpTableTypeImpl;
17 import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009.AfiSafiType;
18 import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009.IPV4UNICAST;
19 import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009.IPV6UNICAST;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.BgpTableType;
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 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.UnicastSubsequentAddressFamily;
24
25 public class TableTypeActivatorTest {
26
27     private static final BgpTableType IPV4 = new BgpTableTypeImpl(Ipv4AddressFamily.class,
28             UnicastSubsequentAddressFamily.class);
29     private static final BgpTableType IPV6 = new BgpTableTypeImpl(Ipv6AddressFamily.class,
30             UnicastSubsequentAddressFamily.class);
31
32     @Test
33     public void testActivator() {
34         final TableTypeActivator tableTypeActivator = new TableTypeActivator();
35         final SimpleBGPTableTypeRegistryProvider registry = new SimpleBGPTableTypeRegistryProvider();
36         tableTypeActivator.startBGPTableTypeRegistryProvider(registry);
37
38         final Optional<Class<? extends AfiSafiType>> afiSafiType = registry.getAfiSafiType(IPV4);
39         assertEquals(IPV4UNICAST.class, afiSafiType.get());
40         final Optional<Class<? extends AfiSafiType>> afiSafiType2 = registry.getAfiSafiType(IPV6);
41         assertEquals(IPV6UNICAST.class, afiSafiType2.get());
42
43         final Optional<BgpTableType> tableType = registry.getTableType(IPV4UNICAST.class);
44         assertEquals(IPV4, tableType.get());
45         final Optional<BgpTableType> tableType2 = registry.getTableType(IPV6UNICAST.class);
46         assertEquals(IPV6, tableType2.get());
47
48         tableTypeActivator.stopBGPTableTypeRegistryProvider();
49         tableTypeActivator.close();
50     }
51
52 }