db967c6a2969c57f8a96f492ddc13a39ac09c906
[bgpcep.git] / bgp / evpn / src / test / java / org / opendaylight / protocol / bgp / evpn / impl / 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.evpn.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.http.openconfig.net.yang.bgp.types.rev151009.L2VPNEVPN;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev171213.EvpnSubsequentAddressFamily;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev171213.L2vpnAddressFamily;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.BgpTableType;
21
22 public class TableTypeActivatorTest {
23
24     private static final BgpTableType EVPN = new BgpTableTypeImpl(L2vpnAddressFamily.class, EvpnSubsequentAddressFamily.class);
25
26     @Test
27     public void testActivator() {
28         final TableTypeActivator tableTypeActivator = new TableTypeActivator();
29         final SimpleBGPTableTypeRegistryProvider registry = new SimpleBGPTableTypeRegistryProvider();
30         tableTypeActivator.startBGPTableTypeRegistryProvider(registry);
31
32         final Optional<Class<? extends AfiSafiType>> afiSafiType = registry.getAfiSafiType(EVPN);
33         Assert.assertEquals(L2VPNEVPN.class, afiSafiType.get());
34
35         final Optional<BgpTableType> tableType = registry.getTableType(L2VPNEVPN.class);
36         Assert.assertEquals(EVPN, tableType.get());
37
38         tableTypeActivator.stopBGPTableTypeRegistryProvider();
39         tableTypeActivator.close();
40     }
41
42 }