blob: c43c5c7100a42df9a2c0aef54619d7c75786a7c9 [file] [log] [blame]
alshabibe1248b62015-08-20 17:21:55 -07001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2015-present Open Networking Foundation
alshabibe1248b62015-08-20 17:21:55 -07003 *
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 */
16package org.onosproject.net.meter;
17
18import com.google.common.testing.EqualsTester;
19import org.junit.Test;
20import org.onosproject.core.ApplicationId;
Andrea Campanella5bdbe432021-05-03 15:59:19 +020021import org.onosproject.net.AbstractAnnotated;
alshabibe1248b62015-08-20 17:21:55 -070022import org.onosproject.net.DeviceId;
23
24import java.util.Collection;
25
26import static org.hamcrest.MatcherAssert.assertThat;
27import static org.hamcrest.Matchers.is;
28import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutableBaseClass;
29
30/**
31 * Unit tests for the MeterOperationTest object.
32 */
33public class MeterOperationTest {
34
35
36
37 /**
38 * Checks that the MeterOperation class is immutable.
39 */
40 @Test
41 public void testImmutability() {
42 assertThatClassIsImmutableBaseClass(MeterOperation.class);
43 }
44
45 @Test
46 public void testEquality() {
47 final Meter m1 = new TestMeter();
48 final Meter m2 = new TestMeter();
49 final MeterOperation op1 = new MeterOperation(m1,
50 MeterOperation.Type.ADD);
51 final MeterOperation sameAsOp1 = new MeterOperation(m1,
52 MeterOperation.Type.ADD);
53 final MeterOperation op2 = new MeterOperation(m2,
54 MeterOperation.Type.ADD);
55
56 new EqualsTester()
57 .addEqualityGroup(op1, sameAsOp1)
58 .addEqualityGroup(op2)
59 .testEquals();
60 }
61
62 @Test
63 public void testConstruction() {
64 final Meter m1 = new TestMeter();
65
66 final MeterOperation op = new MeterOperation(m1, MeterOperation.Type.ADD);
67
68 assertThat(op.meter(), is(m1));
69 }
70
Andrea Campanella5bdbe432021-05-03 15:59:19 +020071 private static final class TestMeter extends AbstractAnnotated implements Meter {
alshabibe1248b62015-08-20 17:21:55 -070072
73 @Override
74 public DeviceId deviceId() {
75 return null;
76 }
77
78 @Override
79 public MeterId id() {
80 return null;
81 }
82
83 @Override
Frank Wangd7e3b4b2017-09-24 13:37:54 +090084 public MeterCellId meterCellId() {
85 return null;
86 }
87
88 @Override
alshabibe1248b62015-08-20 17:21:55 -070089 public ApplicationId appId() {
90 return null;
91 }
92
93 @Override
94 public Unit unit() {
95 return null;
96 }
97
98 @Override
99 public boolean isBurst() {
100 return false;
101 }
102
103 @Override
104 public Collection<Band> bands() {
105 return null;
106 }
107
108 @Override
109 public MeterState state() {
110 return null;
111 }
112
113 @Override
114 public long life() {
115 return 0;
116 }
117
118 @Override
119 public long referenceCount() {
120 return 0;
121 }
122
123 @Override
124 public long packetsSeen() {
125 return 0;
126 }
127
128 @Override
129 public long bytesSeen() {
130 return 0;
131 }
132 }
133
134}