Remove unused BGP OpenConfig provider implementation
[bgpcep.git] / bgp / openconfig-impl / src / test / java / org / opendaylight / protocol / bgp / openconfig / impl / util / OpenConfigUtilTest.java
1 /*
2  * Copyright (c) 2015 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.openconfig.impl.util;
10
11 import static org.junit.Assert.assertEquals;
12 import static org.opendaylight.protocol.bgp.openconfig.impl.util.OpenConfigUtil.toAfiSafi;
13
14 import com.google.common.base.Optional;
15 import com.google.common.collect.Lists;
16 import java.lang.reflect.Constructor;
17 import java.lang.reflect.InvocationTargetException;
18 import java.util.Collections;
19 import java.util.List;
20 import org.junit.Assert;
21 import org.junit.Test;
22 import org.opendaylight.protocol.bgp.parser.BgpTableTypeImpl;
23 import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.multiprotocol.rev151009.bgp.common.afi.safi.list.AfiSafi;
24 import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.multiprotocol.rev151009.bgp.common.afi.safi.list.AfiSafiBuilder;
25 import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009.IPV4UNICAST;
26 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev130919.BgpTableType;
27 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.Ipv4AddressFamily;
28 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.UnicastSubsequentAddressFamily;
29
30 public class OpenConfigUtilTest {
31
32     private static final BgpTableType BGP_TABLE_TYPE_IPV4 = new BgpTableTypeImpl(Ipv4AddressFamily.class, UnicastSubsequentAddressFamily.class);
33     private static final AfiSafi AFISAFI_IPV4 = new AfiSafiBuilder().setAfiSafiName(IPV4UNICAST.class).build();
34
35     @Test
36     public void testToAfiSafi() {
37         assertEquals(toAfiSafi(BGP_TABLE_TYPE_IPV4).get(), AFISAFI_IPV4);
38     }
39
40     @Test
41     public void testToBgpTableType() {
42         final Optional<BgpTableType> bgpTableType = OpenConfigUtil.toBgpTableType(IPV4UNICAST.class);
43         assertEquals(BGP_TABLE_TYPE_IPV4, bgpTableType.get());
44     }
45
46     @Test
47     public void testToAfiSafis() {
48         final List<AfiSafi> afiSafis = OpenConfigUtil.toAfiSafis(Lists.newArrayList(BGP_TABLE_TYPE_IPV4), (afisafi, tableType) -> afisafi);
49         Assert.assertEquals(Collections.singletonList(AFISAFI_IPV4), afiSafis);
50     }
51
52     @Test(expected = UnsupportedOperationException.class)
53     public void testPrivateConstructor() throws Throwable {
54         final Constructor<OpenConfigUtil> c = OpenConfigUtil.class.getDeclaredConstructor();
55         c.setAccessible(true);
56         try {
57             c.newInstance();
58         } catch (final InvocationTargetException e) {
59             throw e.getCause();
60         }
61     }
62 }