2 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
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
9 package org.opendaylight.protocol.concepts;
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;
17 import java.util.HashSet;
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;
23 public class ASNumberTest {
24 private AsNumber asn1;
25 private AsNumber asn3;
26 private AsNumber asn4;
30 this.asn1 = new AsNumber(4294967295L);
31 this.asn3 = new AsNumber((long) 200);
32 this.asn4 = new AsNumber(429496335L);
36 public void testHashCode() {
37 final Set<AsNumber> set = new HashSet<>();
40 assertEquals(1, set.size());
43 assertEquals(2, set.size());
47 public void testGetters() {
48 assertEquals(4294967295L, this.asn1.getValue().longValue());
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());
60 public void testToString() {
61 assertEquals("AsNumber{_value=4294967295}", this.asn1.toString());
62 assertEquals("AsNumber{_value=200}", this.asn3.toString());