blob: 3e21187fe61cfcf2da832078ccd4c663d81e0bdf [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;
Pavlin Radoslavovd26f57a2014-10-23 17:19:45 -07009import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
Brian O'Connorf3d06162014-10-02 15:54:12 -070010
11/**
12 * This class tests the immutability, equality, and non-equality of
13 * {@link IntentId}.
14 */
15public class IntentIdTest {
16 /**
17 * Tests the immutability of {@link IntentId}.
18 */
19 @Test
20 public void intentIdFollowsGuidelineForImmutableObject() {
Pavlin Radoslavovd26f57a2014-10-23 17:19:45 -070021 assertThatClassIsImmutable(IntentId.class);
Brian O'Connorf3d06162014-10-02 15:54:12 -070022 }
23
24 /**
25 * Tests equality of {@link 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 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() {
Brian O'Connorf3d06162014-10-02 15:54:12 -070048 IntentId id = new IntentId(0xdeadbeefL);
Thomas Vachuskac96058a2014-10-20 23:00:16 -070049 assertEquals("incorrect valueOf", id, IntentId.valueOf(0xdeadbeefL));
Brian O'Connorf3d06162014-10-02 15:54:12 -070050 }
51
52}