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