blob: cfde79ee84b6b6f30d1635b32ea390373a74e22e [file] [log] [blame]
Toshio Koidea7827bb2014-08-29 11:36:06 -07001package net.onrc.onos.api.flowmanager;
2
3import static net.onrc.onos.core.util.ImmutableClassChecker.assertThatClassIsImmutable;
4import static org.junit.Assert.assertEquals;
5import net.onrc.onos.core.util.TestUtils;
6
7import org.junit.Before;
8import org.junit.Test;
9
10import com.google.common.testing.EqualsTester;
11
12/**
13 * Unit tests for {@link FlowBatchId} class.
14 */
15public class FlowBatchIdTest {
16 private FlowBatchId flowBatchId1;
17 private FlowBatchId flowBatchId2;
18 private FlowBatchId flowBatchId3;
19 private FlowBatchId flowBatchId4;
20 private FlowBatchId flowBatchId5;
21
22 @Before
23 public void setUp() {
24 flowBatchId1 = new FlowBatchId(0L);
25 flowBatchId2 = new FlowBatchId(1L);
26 flowBatchId3 = new FlowBatchId(2L);
27 flowBatchId4 = new FlowBatchId(1L);
28 flowBatchId5 = new FlowBatchId(0xABCDEFL);
29 }
30
31 /**
32 * Tests {@link FlowBatchId#FlowBatchId(long)} constructor.
33 */
34 @Test
35 public void testConstructor() {
36 assertEquals(0xABCDEFL, TestUtils.getField(flowBatchId5, "id"));
37 }
38
39 /**
40 * Tests the equality of {@link FlowBatchId} objects.
41 */
42 @Test
43 public void testEqualsAndHashCode() {
44 new EqualsTester()
45 .addEqualityGroup(flowBatchId1)
46 .addEqualityGroup(flowBatchId2, flowBatchId4)
47 .addEqualityGroup(flowBatchId3)
48 .addEqualityGroup(flowBatchId5)
49 .testEquals();
50 }
51
52 /**
53 * Tests {@link FlowBatchId#toString()} method.
54 */
55 @Test
56 public void testToString() {
57 assertEquals("0x0", flowBatchId1.toString());
58 assertEquals("0xabcdef", flowBatchId5.toString());
59 }
60
61 /**
62 * Tests if {@link FlowBatchId} is immutable.
63 */
64 @Test
65 public void testImmutable() {
66 assertThatClassIsImmutable(FlowBatchId.class);
67 }
68}