Thomas Vachuska | 4f1a60c | 2014-10-28 13:39:07 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2014 Open Networking Laboratory |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
Brian O'Connor | f3d0616 | 2014-10-02 15:54:12 -0700 | [diff] [blame] | 16 | package org.onlab.onos.net.intent; |
| 17 | |
| 18 | import org.junit.Test; |
| 19 | |
| 20 | import static org.hamcrest.Matchers.is; |
| 21 | import static org.hamcrest.Matchers.not; |
| 22 | import static org.junit.Assert.assertEquals; |
| 23 | import static org.junit.Assert.assertThat; |
Pavlin Radoslavov | d26f57a | 2014-10-23 17:19:45 -0700 | [diff] [blame] | 24 | import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable; |
Brian O'Connor | f3d0616 | 2014-10-02 15:54:12 -0700 | [diff] [blame] | 25 | |
| 26 | /** |
| 27 | * This class tests the immutability, equality, and non-equality of |
| 28 | * {@link IntentId}. |
| 29 | */ |
| 30 | public class IntentIdTest { |
| 31 | /** |
| 32 | * Tests the immutability of {@link IntentId}. |
| 33 | */ |
| 34 | @Test |
| 35 | public void intentIdFollowsGuidelineForImmutableObject() { |
Pavlin Radoslavov | d26f57a | 2014-10-23 17:19:45 -0700 | [diff] [blame] | 36 | assertThatClassIsImmutable(IntentId.class); |
Brian O'Connor | f3d0616 | 2014-10-02 15:54:12 -0700 | [diff] [blame] | 37 | } |
| 38 | |
| 39 | /** |
| 40 | * Tests equality of {@link IntentId}. |
| 41 | */ |
| 42 | @Test |
| 43 | public void testEquality() { |
| 44 | IntentId id1 = new IntentId(1L); |
| 45 | IntentId id2 = new IntentId(1L); |
| 46 | |
| 47 | assertThat(id1, is(id2)); |
| 48 | } |
| 49 | |
| 50 | /** |
| 51 | * Tests non-equality of {@link IntentId}. |
| 52 | */ |
| 53 | @Test |
| 54 | public void testNonEquality() { |
| 55 | IntentId id1 = new IntentId(1L); |
| 56 | IntentId id2 = new IntentId(2L); |
| 57 | |
| 58 | assertThat(id1, is(not(id2))); |
| 59 | } |
| 60 | |
| 61 | @Test |
| 62 | public void valueOf() { |
Brian O'Connor | f3d0616 | 2014-10-02 15:54:12 -0700 | [diff] [blame] | 63 | IntentId id = new IntentId(0xdeadbeefL); |
Thomas Vachuska | c96058a | 2014-10-20 23:00:16 -0700 | [diff] [blame] | 64 | assertEquals("incorrect valueOf", id, IntentId.valueOf(0xdeadbeefL)); |
Brian O'Connor | f3d0616 | 2014-10-02 15:54:12 -0700 | [diff] [blame] | 65 | } |
| 66 | |
| 67 | } |