blob: 01b65c07d43caff8aefe480ad3684125d2127b27 [file] [log] [blame]
Sho SHIMIZU15ed4fd2014-08-05 14:40:42 -07001package net.onrc.onos.api.newintent;
2
3import org.junit.Test;
4
5import static net.onrc.onos.core.util.ImmutableClassChecker.assertThatClassIsImmutable;
6import static org.hamcrest.Matchers.is;
7import static org.hamcrest.Matchers.not;
8import static org.junit.Assert.assertEquals;
9import static org.junit.Assert.assertThat;
10
11/**
12 * This class tests the immutability, equality, and non-equality of
13 * {@link net.onrc.onos.api.intent.IntentId}.
14 */
15public class IntentIdTest {
16 /**
17 * Tests the immutability of {@link net.onrc.onos.api.intent.IntentId}.
18 */
19 @Test
20 public void intentIdFollowsGuidelineForImmutableObject() {
21 assertThatClassIsImmutable(IntentId.class);
22 }
23
24 /**
25 * Tests equality of {@link net.onrc.onos.api.intent.IntentId}.
26 */
27 @Test
28 public void testEquality() {
29 IntentId id1 = new IntentId(1L);
30 IntentId id2 = new IntentId(1L);
31
32 assertThat(id1, is(id2));
33 }
34
35 /**
36 * Tests non-equality of {@link net.onrc.onos.api.intent.IntentId}.
37 */
38 @Test
39 public void testNonEquality() {
40 IntentId id1 = new IntentId(1L);
41 IntentId id2 = new IntentId(2L);
42
43 assertThat(id1, is(not(id2)));
44 }
45
46 @Test
47 public void valueOf() {
48 IntentId id = new IntentId(12345);
49 assertEquals("incorrect valueOf", id, IntentId.valueOf("12345"));
50 }
51
52 @Test
53 public void valueOfHex() {
54 IntentId id = new IntentId(0xdeadbeefL);
55 assertEquals("incorrect valueOf", id, IntentId.valueOf(id.toString()));
56 }
57
58}