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