Sho SHIMIZU | 15ed4fd | 2014-08-05 14:40:42 -0700 | [diff] [blame] | 1 | package net.onrc.onos.api.newintent; |
| 2 | |
| 3 | import org.junit.Test; |
| 4 | |
| 5 | import static net.onrc.onos.core.util.ImmutableClassChecker.assertThatClassIsImmutable; |
| 6 | import static org.hamcrest.Matchers.is; |
| 7 | import static org.hamcrest.Matchers.not; |
| 8 | import static org.junit.Assert.assertEquals; |
| 9 | import static org.junit.Assert.assertThat; |
| 10 | |
| 11 | /** |
| 12 | * This class tests the immutability, equality, and non-equality of |
Sho SHIMIZU | 228140c | 2014-08-11 19:15:43 -0700 | [diff] [blame] | 13 | * {@link IntentId}. |
Sho SHIMIZU | 15ed4fd | 2014-08-05 14:40:42 -0700 | [diff] [blame] | 14 | */ |
| 15 | public class IntentIdTest { |
| 16 | /** |
Sho SHIMIZU | 228140c | 2014-08-11 19:15:43 -0700 | [diff] [blame] | 17 | * Tests the immutability of {@link IntentId}. |
Sho SHIMIZU | 15ed4fd | 2014-08-05 14:40:42 -0700 | [diff] [blame] | 18 | */ |
| 19 | @Test |
| 20 | public void intentIdFollowsGuidelineForImmutableObject() { |
| 21 | assertThatClassIsImmutable(IntentId.class); |
| 22 | } |
| 23 | |
| 24 | /** |
Sho SHIMIZU | 228140c | 2014-08-11 19:15:43 -0700 | [diff] [blame] | 25 | * Tests equality of {@link IntentId}. |
Sho SHIMIZU | 15ed4fd | 2014-08-05 14:40:42 -0700 | [diff] [blame] | 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 | /** |
Sho SHIMIZU | 228140c | 2014-08-11 19:15:43 -0700 | [diff] [blame] | 36 | * Tests non-equality of {@link IntentId}. |
Sho SHIMIZU | 15ed4fd | 2014-08-05 14:40:42 -0700 | [diff] [blame] | 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 | } |