Mehmed Mustafa | 3e269df | 2017-11-24 17:19:49 +0300 | [diff] [blame] | 1 | /* |
steven30801 | 7632e15 | 2018-10-20 00:51:08 +0800 | [diff] [blame] | 2 | * Copyright 2018-present Open Networking Foundation |
Mehmed Mustafa | 3e269df | 2017-11-24 17:19:49 +0300 | [diff] [blame] | 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 | |
| 19 | import com.google.common.testing.EqualsTester; |
| 20 | import org.junit.Test; |
Mehmed Mustafa | 3e269df | 2017-11-24 17:19:49 +0300 | [diff] [blame] | 21 | |
| 22 | import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable; |
Mehmed Mustafa | 3e269df | 2017-11-24 17:19:49 +0300 | [diff] [blame] | 23 | |
| 24 | /** |
steven30801 | 7632e15 | 2018-10-20 00:51:08 +0800 | [diff] [blame] | 25 | * Unit tests for PiCounterData class. |
Mehmed Mustafa | 3e269df | 2017-11-24 17:19:49 +0300 | [diff] [blame] | 26 | */ |
| 27 | public class PiCounterCellDataTest { |
| 28 | |
Mehmed Mustafa | 3e269df | 2017-11-24 17:19:49 +0300 | [diff] [blame] | 29 | private static final long PACKETS_1 = 10; |
| 30 | private static final long PACKETS_2 = 20; |
| 31 | private static final long BYTES_1 = 100; |
| 32 | private static final long BYTES_2 = 200; |
| 33 | |
steven30801 | 7632e15 | 2018-10-20 00:51:08 +0800 | [diff] [blame] | 34 | private static final PiCounterCellData PI_COUNTER_DATA_1 = |
| 35 | new PiCounterCellData(PACKETS_1, BYTES_1); |
| 36 | private static final PiCounterCellData SAME_AS_PI_COUNTER_DATA_1 = |
| 37 | new PiCounterCellData(PACKETS_1, BYTES_1); |
| 38 | private static final PiCounterCellData PI_COUNTER_DATA_2 = |
| 39 | new PiCounterCellData(PACKETS_2, BYTES_2); |
Mehmed Mustafa | 3e269df | 2017-11-24 17:19:49 +0300 | [diff] [blame] | 40 | |
| 41 | /** |
| 42 | * Checks that the PiCounterCellData class is immutable. |
| 43 | */ |
| 44 | @Test |
| 45 | public void testImmutability() { |
| 46 | assertThatClassIsImmutable(PiCounterCellData.class); |
| 47 | } |
| 48 | |
| 49 | /** |
| 50 | * Checks the operation of equals(), hashCode() and toString() methods. |
| 51 | */ |
| 52 | @Test |
| 53 | public void testEquals() { |
| 54 | new EqualsTester() |
steven30801 | 7632e15 | 2018-10-20 00:51:08 +0800 | [diff] [blame] | 55 | .addEqualityGroup(PI_COUNTER_DATA_1, SAME_AS_PI_COUNTER_DATA_1) |
| 56 | .addEqualityGroup(PI_COUNTER_DATA_2) |
Mehmed Mustafa | 3e269df | 2017-11-24 17:19:49 +0300 | [diff] [blame] | 57 | .testEquals(); |
| 58 | } |
Carmelo Cascone | 81929aa | 2018-04-07 01:38:55 -0700 | [diff] [blame] | 59 | } |