blob: bfb8782ad73ea2b1b5e03125c1ce686063f2af09 [file] [log] [blame]
Mehmed Mustafa3e269df2017-11-24 17:19:49 +03001/*
steven308017632e152018-10-20 00:51:08 +08002 * Copyright 2018-present Open Networking Foundation
Mehmed Mustafa3e269df2017-11-24 17:19:49 +03003 *
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;
Mehmed Mustafa3e269df2017-11-24 17:19:49 +030021
22import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
Mehmed Mustafa3e269df2017-11-24 17:19:49 +030023
24/**
steven308017632e152018-10-20 00:51:08 +080025 * Unit tests for PiCounterData class.
Mehmed Mustafa3e269df2017-11-24 17:19:49 +030026 */
27public class PiCounterCellDataTest {
28
Mehmed Mustafa3e269df2017-11-24 17:19:49 +030029 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
steven308017632e152018-10-20 00:51:08 +080034 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 Mustafa3e269df2017-11-24 17:19:49 +030040
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()
steven308017632e152018-10-20 00:51:08 +080055 .addEqualityGroup(PI_COUNTER_DATA_1, SAME_AS_PI_COUNTER_DATA_1)
56 .addEqualityGroup(PI_COUNTER_DATA_2)
Mehmed Mustafa3e269df2017-11-24 17:19:49 +030057 .testEquals();
58 }
Carmelo Cascone81929aa2018-04-07 01:38:55 -070059}