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; |
Pavlin Radoslavov | d26f57a | 2014-10-23 17:19:45 -0700 | [diff] [blame^] | 9 | import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable; |
Brian O'Connor | f3d0616 | 2014-10-02 15:54:12 -0700 | [diff] [blame] | 10 | |
| 11 | /** |
| 12 | * This class tests the immutability, equality, and non-equality of |
| 13 | * {@link IntentId}. |
| 14 | */ |
| 15 | public class IntentIdTest { |
| 16 | /** |
| 17 | * Tests the immutability of {@link IntentId}. |
| 18 | */ |
| 19 | @Test |
| 20 | public void intentIdFollowsGuidelineForImmutableObject() { |
Pavlin Radoslavov | d26f57a | 2014-10-23 17:19:45 -0700 | [diff] [blame^] | 21 | assertThatClassIsImmutable(IntentId.class); |
Brian O'Connor | f3d0616 | 2014-10-02 15:54:12 -0700 | [diff] [blame] | 22 | } |
| 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'Connor | f3d0616 | 2014-10-02 15:54:12 -0700 | [diff] [blame] | 48 | IntentId id = new IntentId(0xdeadbeefL); |
Thomas Vachuska | c96058a | 2014-10-20 23:00:16 -0700 | [diff] [blame] | 49 | assertEquals("incorrect valueOf", id, IntentId.valueOf(0xdeadbeefL)); |
Brian O'Connor | f3d0616 | 2014-10-02 15:54:12 -0700 | [diff] [blame] | 50 | } |
| 51 | |
| 52 | } |