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
8 package org.opendaylight.protocol.concepts;
10 import static org.hamcrest.CoreMatchers.equalTo;
11 import static org.hamcrest.CoreMatchers.not;
12 import static org.hamcrest.MatcherAssert.assertThat;
13 import static org.junit.jupiter.api.Assertions.assertEquals;
14 import static org.junit.jupiter.api.Assertions.assertFalse;
15 import static org.junit.jupiter.api.Assertions.assertNotEquals;
17 import io.netty.buffer.Unpooled;
18 import java.util.HashSet;
19 import org.junit.jupiter.api.Test;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.network.concepts.rev131125.Bandwidth;
23 private static final Bandwidth B1 = new Bandwidth(Unpooled.copyInt(1000).array());
24 private static final Bandwidth B2 = new Bandwidth(Unpooled.copyInt(2000).array());
25 private static final Bandwidth B3 = new Bandwidth(Unpooled.copyInt(2000).array());
26 private static final Bandwidth B4 = new Bandwidth(Unpooled.copyInt(100).array());
29 void testBitsBytes() {
30 assertEquals(1000.0, Unpooled.wrappedBuffer(B1.getValue()).readInt(), 0.1);
35 assertFalse(B1.equals(null));
36 assertThat(B1, not(equalTo(new Object())));
37 assertThat(B1, equalTo(B1));
38 assertThat(B1, not(equalTo(B2)));
40 assertNotEquals(B1, new Object());
45 final var set = new HashSet<Bandwidth>();
48 assertEquals(1, set.size());
51 assertEquals(2, set.size());
54 assertEquals(2, set.size());
57 assertEquals(3, set.size());