Merge "Unify YANG->DTO generation plugin definition"
[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.assertFalse;
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.rev130919.BgpTableType;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.Ipv4AddressFamily;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.Ipv6AddressFamily;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.MplsLabeledVpnSubsequentAddressFamily;
20
21 public class TableTypeTest {
22
23         @Test
24         public void testTableTypes() {
25                 final BgpTableType tt1 = new BgpTableTypeImpl(Ipv4AddressFamily.class, MplsLabeledVpnSubsequentAddressFamily.class);
26                 final BgpTableType tt2 = new BgpTableTypeImpl(Ipv6AddressFamily.class, MplsLabeledVpnSubsequentAddressFamily.class);
27
28                 try {
29                         new BgpTableTypeImpl(null, MplsLabeledVpnSubsequentAddressFamily.class);
30                         fail("Null AFI!");
31                 } catch (final NullPointerException e) {
32                         assertEquals("Address family may not be null", e.getMessage());
33                 }
34
35                 try {
36                         new BgpTableTypeImpl(Ipv6AddressFamily.class, null);
37                         fail("Null SAFI!");
38                 } catch (final NullPointerException e) {
39                         assertEquals("Subsequent address family may not be null", e.getMessage());
40                 }
41
42                 assertFalse(tt1.equals(tt2));
43                 assertNotSame(tt1.hashCode(), tt2.hashCode());
44                 assertEquals(tt1.toString(), tt1.toString());
45                 assertNotSame(tt1.getAfi(), tt2.getAfi());
46                 assertEquals(tt1.getSafi(), tt2.getSafi());
47         }
48 }