blob: 973a5f2f674bb1fc8fc02017063dedecfb5aa658 [file] [log] [blame]
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07001/*
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'Connorf3d06162014-10-02 15:54:12 -070016package org.onlab.onos.net.intent;
17
18import org.junit.Test;
19
20import static org.hamcrest.Matchers.is;
21import static org.hamcrest.Matchers.not;
22import static org.junit.Assert.assertEquals;
23import static org.junit.Assert.assertThat;
Pavlin Radoslavovd26f57a2014-10-23 17:19:45 -070024import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
Brian O'Connorf3d06162014-10-02 15:54:12 -070025
26/**
27 * This class tests the immutability, equality, and non-equality of
28 * {@link IntentId}.
29 */
30public class IntentIdTest {
31 /**
32 * Tests the immutability of {@link IntentId}.
33 */
34 @Test
35 public void intentIdFollowsGuidelineForImmutableObject() {
Pavlin Radoslavovd26f57a2014-10-23 17:19:45 -070036 assertThatClassIsImmutable(IntentId.class);
Brian O'Connorf3d06162014-10-02 15:54:12 -070037 }
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'Connorf3d06162014-10-02 15:54:12 -070063 IntentId id = new IntentId(0xdeadbeefL);
Thomas Vachuskac96058a2014-10-20 23:00:16 -070064 assertEquals("incorrect valueOf", id, IntentId.valueOf(0xdeadbeefL));
Brian O'Connorf3d06162014-10-02 15:54:12 -070065 }
66
67}