Mehmed Mustafa | 3e269df | 2017-11-24 17:19:49 +0300 | [diff] [blame] | 1 | /* |
| 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 | |
| 17 | package org.onosproject.net.pi.runtime; |
| 18 | import com.google.common.testing.EqualsTester; |
| 19 | import org.junit.Test; |
| 20 | import org.onosproject.net.pi.model.PiCounterId; |
| 21 | |
| 22 | import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable; |
| 23 | |
| 24 | /** |
| 25 | * Unit tests for PiCounterId class. |
| 26 | */ |
| 27 | public class PiCounterIdTest { |
| 28 | |
| 29 | private static final PiCounterId PI_COUNTER_ID_1 = PiCounterId.of("Name1"); |
| 30 | private static final PiCounterId SAME_AS_PI_COUNTER_ID_1 = PiCounterId.of("Name1"); |
| 31 | private static final PiCounterId PI_COUNTER_ID_2 = PiCounterId.of("Name2"); |
| 32 | |
| 33 | /** |
| 34 | * Checks that the PiCounterId class is immutable. |
| 35 | */ |
| 36 | @Test |
| 37 | public void testImmutability() { |
| 38 | assertThatClassIsImmutable(PiCounterId.class); |
| 39 | } |
| 40 | |
| 41 | /** |
| 42 | * Checks the operation of equals(), hashCode() and toString() methods. |
| 43 | */ |
| 44 | @Test |
| 45 | public void testEquals() { |
| 46 | new EqualsTester() |
| 47 | .addEqualityGroup(PI_COUNTER_ID_1, SAME_AS_PI_COUNTER_ID_1) |
| 48 | .addEqualityGroup(PI_COUNTER_ID_2) |
| 49 | .testEquals(); |
| 50 | } |
| 51 | |
| 52 | } |
| 53 | |