Code clean up
[bgpcep.git] / bgp / parser-api / src / test / java / org / opendaylight / protocol / bgp / parser / TableTypeTest.java
1 /*
2  * Copyright (c) 2013 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;
9
10 import static org.junit.Assert.assertEquals;
11 import static org.junit.Assert.assertNotEquals;
12 import static org.junit.Assert.assertNotSame;
13 import static org.junit.Assert.fail;
14
15 import org.junit.Test;
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.types.rev180329.Ipv4AddressFamily;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.Ipv6AddressFamily;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.MplsLabeledVpnSubsequentAddressFamily;
20
21 public class TableTypeTest {
22
23     @Test
24     public void testTableTypes() {
25         final BgpTableType tt1 = new BgpTableTypeImpl(Ipv4AddressFamily.class,
26                 MplsLabeledVpnSubsequentAddressFamily.class);
27         final BgpTableType tt2 = new BgpTableTypeImpl(Ipv6AddressFamily.class,
28                 MplsLabeledVpnSubsequentAddressFamily.class);
29
30         try {
31             new BgpTableTypeImpl(null, MplsLabeledVpnSubsequentAddressFamily.class);
32             fail("Null AFI!");
33         } catch (final NullPointerException e) {
34             assertEquals("Address family may not be null", e.getMessage());
35         }
36
37         try {
38             new BgpTableTypeImpl(Ipv6AddressFamily.class, null);
39             fail("Null SAFI!");
40         } catch (final NullPointerException e) {
41             assertEquals("Subsequent address family may not be null", e.getMessage());
42         }
43
44         assertNotEquals(tt1, tt2);
45         assertNotSame(tt1.hashCode(), tt2.hashCode());
46         assertEquals(tt1.toString(), tt1.toString());
47         assertNotSame(tt1.getAfi(), tt2.getAfi());
48         assertEquals(tt1.getSafi(), tt2.getSafi());
49     }
50 }