blob: cffb9e996a8f060ad698b055300150b14ae50f36 [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
Frank Wang4e848042017-08-03 19:48:11 +080022import static org.hamcrest.MatcherAssert.assertThat;
23import static org.hamcrest.Matchers.is;
24import static org.hamcrest.Matchers.notNullValue;
25import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
26
27/**
Carmelo Casconecb4327a2018-09-11 15:17:23 -070028 * Unit tests for PiActionProfileGroupId class.
Frank Wang4e848042017-08-03 19:48:11 +080029 */
Carmelo Casconecb4327a2018-09-11 15:17:23 -070030public class PiActionProfileGroupIdTest {
Frank Wang4e848042017-08-03 19:48:11 +080031
Carmelo Casconecb4327a2018-09-11 15:17:23 -070032 final PiActionProfileGroupId piActionGroupId1 = PiActionProfileGroupId.of(10);
33 final PiActionProfileGroupId sameAsPiActionProfileGroupId1 = PiActionProfileGroupId.of(10);
34 final PiActionProfileGroupId piActionGroupId2 = PiActionProfileGroupId.of(20);
Frank Wang4e848042017-08-03 19:48:11 +080035
36 /**
Carmelo Casconecb4327a2018-09-11 15:17:23 -070037 * Checks that the PiActionProfileGroupId class is immutable.
Frank Wang4e848042017-08-03 19:48:11 +080038 */
39 @Test
40 public void testImmutability() {
41
Carmelo Casconecb4327a2018-09-11 15:17:23 -070042 assertThatClassIsImmutable(PiActionProfileGroupId.class);
Frank Wang4e848042017-08-03 19:48:11 +080043 }
44
45 /**
46 * Checks the operation of equals(), hashCode() and toString() methods.
47 */
48 @Test
49 public void testEquals() {
50
51 new EqualsTester()
Carmelo Casconecb4327a2018-09-11 15:17:23 -070052 .addEqualityGroup(piActionGroupId1, sameAsPiActionProfileGroupId1)
Frank Wang4e848042017-08-03 19:48:11 +080053 .addEqualityGroup(piActionGroupId2)
54 .testEquals();
55 }
56
57 /**
Carmelo Casconecb4327a2018-09-11 15:17:23 -070058 * Checks the methods of PiActionProfileGroupId.
Frank Wang4e848042017-08-03 19:48:11 +080059 */
60 @Test
61 public void testMethods() {
62
63 assertThat(piActionGroupId1, is(notNullValue()));
Carmelo Casconecb4327a2018-09-11 15:17:23 -070064 assertThat(piActionGroupId1.type(), is(PiTableAction.Type.ACTION_PROFILE_GROUP_ID));
Frank Wang4e848042017-08-03 19:48:11 +080065 assertThat(piActionGroupId1.id(), is(10));
66 }
67}