Code clean up
[bgpcep.git] / concepts / src / test / java / org / opendaylight / protocol / concepts / ASNumberTest.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
9 package org.opendaylight.protocol.concepts;
10
11 import static org.hamcrest.CoreMatchers.equalTo;
12 import static org.hamcrest.CoreMatchers.not;
13 import static org.junit.Assert.assertEquals;
14 import static org.junit.Assert.assertNotEquals;
15 import static org.junit.Assert.assertThat;
16
17 import java.util.HashSet;
18 import java.util.Set;
19 import org.junit.Before;
20 import org.junit.Test;
21 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.AsNumber;
22
23 public class ASNumberTest {
24     private AsNumber asn1;
25     private AsNumber asn3;
26     private AsNumber asn4;
27
28     @Before
29     public void setUp() {
30         this.asn1 = new AsNumber(4294967295L);
31         this.asn3 = new AsNumber((long) 200);
32         this.asn4 = new AsNumber(429496335L);
33     }
34
35     @Test
36     public void testHashCode() {
37         final Set<AsNumber> set = new HashSet<>();
38
39         set.add(this.asn1);
40         assertEquals(1, set.size());
41
42         set.add(this.asn3);
43         assertEquals(2, set.size());
44     }
45
46     @Test
47     public void testGetters() {
48         assertEquals(4294967295L, this.asn1.getValue().longValue());
49     }
50
51     @Test
52     public void testEquals() {
53         assertThat(this.asn1, not(equalTo(this.asn3)));
54         assertThat(this.asn1, not(equalTo(this.asn4)));
55         assertThat(this.asn1, not(equalTo(new Object())));
56         assertNotEquals(this.asn1, new Object());
57     }
58
59     @Test
60     public void testToString() {
61         assertEquals("AsNumber{_value=4294967295}", this.asn1.toString());
62         assertEquals("AsNumber{_value=200}", this.asn3.toString());
63     }
64 }