Brian O'Connor | f3d0616 | 2014-10-02 15:54:12 -0700 | [diff] [blame] | 1 | package org.onlab.onos.net.intent; |
| 2 | |
| 3 | import org.junit.Test; |
| 4 | |
| 5 | import static org.hamcrest.Matchers.is; |
| 6 | import static org.hamcrest.Matchers.not; |
| 7 | import static org.junit.Assert.assertEquals; |
| 8 | import static org.junit.Assert.assertThat; |
| 9 | |
| 10 | /** |
| 11 | * This class tests the immutability, equality, and non-equality of |
| 12 | * {@link IntentId}. |
| 13 | */ |
| 14 | public 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() { |
Brian O'Connor | f3d0616 | 2014-10-02 15:54:12 -0700 | [diff] [blame] | 47 | IntentId id = new IntentId(0xdeadbeefL); |
Thomas Vachuska | c96058a | 2014-10-20 23:00:16 -0700 | [diff] [blame] | 48 | assertEquals("incorrect valueOf", id, IntentId.valueOf(0xdeadbeefL)); |
Brian O'Connor | f3d0616 | 2014-10-02 15:54:12 -0700 | [diff] [blame] | 49 | } |
| 50 | |
| 51 | } |