Add model of graceful-restart capability
[bgpcep.git] / concepts / src / test / java / org / opendaylight / protocol / concepts / BandwidthTest.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.assertFalse;
15 import static org.junit.Assert.assertThat;
16
17 import java.util.HashSet;
18 import java.util.Set;
19
20 import org.junit.Before;
21 import org.junit.Ignore;
22 import org.junit.Test;
23 import org.opendaylight.protocol.util.ByteArray;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nps.concepts.rev130930.Bandwidth;
25
26 public class BandwidthTest {
27         private Bandwidth b1, b2, b3, b4;
28
29         @Before
30         public void setUp() {
31                 this.b1 = new Bandwidth(ByteArray.intToBytes(1000));
32                 this.b2 = new Bandwidth(ByteArray.intToBytes(2000));
33                 this.b3 = new Bandwidth(ByteArray.intToBytes(2000));
34                 this.b4 = new Bandwidth(ByteArray.intToBytes(100));
35         }
36
37         @Test
38         public void testBitsBytes() {
39                 assertEquals(1000.0, ByteArray.bytesToLong(this.b1.getValue()), 0.1);
40         }
41
42         @Test
43         public void testEquals() {
44                 assertFalse(this.b1.equals(null));
45                 assertThat(this.b1, not(equalTo(new Object())));
46                 assertThat(this.b1, equalTo(this.b1));
47                 assertThat(this.b1, not(equalTo(this.b2)));
48                 assertEquals(this.b2, this.b3);
49                 assertFalse(this.b1.equals(new Object()));
50         }
51
52         @Test
53         public void testHashCode() {
54                 final Set<Bandwidth> set = new HashSet<Bandwidth>();
55
56                 set.add(this.b1);
57                 assertEquals(1, set.size());
58
59                 set.add(this.b2);
60                 assertEquals(2, set.size());
61
62                 set.add(this.b3);
63                 assertEquals(2, set.size());
64
65                 set.add(this.b4);
66                 assertEquals(3, set.size());
67         }
68 }