blob: 008a74e45a6ed01f5a40e727187a34b5fe4bff29 [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
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 PiActionGroupMemberId class.
29 */
30public class PiActionGroupMemberIdTest {
31
32 final PiActionGroupMemberId piActionGroupMemberId1 = PiActionGroupMemberId.of(10);
33 final PiActionGroupMemberId sameAsPiActionGroupMemberId1 = PiActionGroupMemberId.of(10);
34 final PiActionGroupMemberId piActionGroupMemberId2 = PiActionGroupMemberId.of(20);
35
36 /**
37 * Checks that the PiActionGroupMemberId class is immutable.
38 */
39 @Test
40 public void testImmutability() {
41
42 assertThatClassIsImmutable(PiActionGroupMemberId.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(piActionGroupMemberId1, sameAsPiActionGroupMemberId1)
53 .addEqualityGroup(piActionGroupMemberId2)
54 .testEquals();
55 }
56
57 /**
58 * Checks the methods of PiActionGroupMemberId.
59 */
60 @Test
61 public void testMethods() {
62
63 assertThat(piActionGroupMemberId1, is(notNullValue()));
64 assertThat(piActionGroupMemberId1.type(), is(PiTableAction.Type.GROUP_MEMBER_ID));
65 assertThat(piActionGroupMemberId1.id(), is(10));
66 }
67}