blob: 07b60faa5b34706aadfc06a0912a9f617f034fce [file] [log] [blame]
Ray Milkeyf19b7152014-11-21 10:56:52 -08001/*
2 * Copyright 2014 Open Networking Laboratory
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 */
Brian O'Connorabafb502014-12-02 22:26:20 -080016package org.onosproject.net.flow;
Ray Milkeyf19b7152014-11-21 10:56:52 -080017
18import java.util.LinkedList;
19
20import org.junit.Test;
Brian O'Connorabafb502014-12-02 22:26:20 -080021import org.onosproject.net.intent.IntentTestsMocks;
Ray Milkeyf19b7152014-11-21 10:56:52 -080022
23import com.google.common.testing.EqualsTester;
24
25/**
26 * Unit tests for flow rule batch classes.
27 */
28public class FlowRuleBatchOperationTest {
29
30 /**
31 * Tests the equals(), hashCode() and toString() methods.
32 */
33 @Test
34 public void testEquals() {
35 final FlowRule rule = new IntentTestsMocks.MockFlowRule(1);
36 final FlowRuleBatchEntry entry1 = new FlowRuleBatchEntry(
37 FlowRuleBatchEntry.FlowRuleOperation.ADD, rule);
38 final FlowRuleBatchEntry entry2 = new FlowRuleBatchEntry(
39 FlowRuleBatchEntry.FlowRuleOperation.MODIFY, rule);
40 final FlowRuleBatchEntry entry3 = new FlowRuleBatchEntry(
41 FlowRuleBatchEntry.FlowRuleOperation.REMOVE, rule);
42 final LinkedList<FlowRuleBatchEntry> ops1 = new LinkedList<>();
43 ops1.add(entry1);
44 final LinkedList<FlowRuleBatchEntry> ops2 = new LinkedList<>();
45 ops1.add(entry2);
46 final LinkedList<FlowRuleBatchEntry> ops3 = new LinkedList<>();
47 ops3.add(entry3);
48
49 final FlowRuleBatchOperation operation1 = new FlowRuleBatchOperation(ops1);
50 final FlowRuleBatchOperation sameAsOperation1 = new FlowRuleBatchOperation(ops1);
51 final FlowRuleBatchOperation operation2 = new FlowRuleBatchOperation(ops2);
52 final FlowRuleBatchOperation operation3 = new FlowRuleBatchOperation(ops3);
53
54 new EqualsTester()
55 .addEqualityGroup(operation1, sameAsOperation1)
56 .addEqualityGroup(operation2)
57 .addEqualityGroup(operation3)
58 .testEquals();
59 }
60}