blob: 4c18f18b1cb575a06408dc81bea62f67b178fb7a [file] [log] [blame]
Frank Wang4e848042017-08-03 19:48:11 +08001/*
2 * Copyright 2017-present Open Networking Foundation
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 */
16
17package org.onosproject.net.pi.runtime;
18
19import com.google.common.testing.EqualsTester;
20import org.junit.Test;
21
22
23import static org.hamcrest.MatcherAssert.assertThat;
24import static org.hamcrest.Matchers.is;
25import static org.hamcrest.Matchers.notNullValue;
26import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
27
28/**
29 * Unit tests for PiActionGroupId class.
30 */
31public class PiActionGroupIdTest {
32
33 final PiActionGroupId piActionGroupId1 = PiActionGroupId.of(10);
34 final PiActionGroupId sameAsPiActionGroupId1 = PiActionGroupId.of(10);
35 final PiActionGroupId piActionGroupId2 = PiActionGroupId.of(20);
36
37 /**
38 * Checks that the PiActionGroupId class is immutable.
39 */
40 @Test
41 public void testImmutability() {
42
43 assertThatClassIsImmutable(PiActionGroupId.class);
44 }
45
46 /**
47 * Checks the operation of equals(), hashCode() and toString() methods.
48 */
49 @Test
50 public void testEquals() {
51
52 new EqualsTester()
53 .addEqualityGroup(piActionGroupId1, sameAsPiActionGroupId1)
54 .addEqualityGroup(piActionGroupId2)
55 .testEquals();
56 }
57
58 /**
59 * Checks the methods of PiActionGroupId.
60 */
61 @Test
62 public void testMethods() {
63
64 assertThat(piActionGroupId1, is(notNullValue()));
65 assertThat(piActionGroupId1.type(), is(PiTableAction.Type.ACTION_GROUP_ID));
66 assertThat(piActionGroupId1.id(), is(10));
67 }
68}