blob: 430ce9e181faa4e58f89cbb8de1f0c95bf7c62de [file] [log] [blame]
Carmelo Casconecb4327a2018-09-11 15:17:23 -07001/*
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
22import 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/**
28 * Unit tests for PiActionProfileMemberId class.
29 */
30public class PiActionProfileMemberIdTest {
31
32 final PiActionProfileMemberId piActionProfileMemberId1 = PiActionProfileMemberId.of(10);
33 final PiActionProfileMemberId sameAsPiActionProfileMemberId1 = PiActionProfileMemberId.of(10);
34 final PiActionProfileMemberId piActionProfileMemberId2 = PiActionProfileMemberId.of(20);
35
36 /**
37 * Checks that the PiActionProfileMemberId class is immutable.
38 */
39 @Test
40 public void testImmutability() {
41
42 assertThatClassIsImmutable(PiActionProfileMemberId.class);
43 }
44
45 /**
46 * Checks the operation of equals(), hashCode() and toString() methods.
47 */
48 @Test
49 public void testEquals() {
50
51 new EqualsTester()
52 .addEqualityGroup(piActionProfileMemberId1, sameAsPiActionProfileMemberId1)
53 .addEqualityGroup(piActionProfileMemberId2)
54 .testEquals();
55 }
56
57 /**
58 * Checks the methods of PiActionProfileMemberId.
59 */
60 @Test
61 public void testMethods() {
62
63 assertThat(piActionProfileMemberId1, is(notNullValue()));
64 assertThat(piActionProfileMemberId1.type(), is(PiTableAction.Type.ACTION_PROFILE_MEMBER_ID));
65 assertThat(piActionProfileMemberId1.id(), is(10));
66 }
67}