blob: 0fa563f93f42d4db60c26c1cb593e054460d9d91 [file] [log] [blame]
Ray Milkeyf19b7152014-11-21 10:56:52 -08001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2014-present Open Networking Foundation
Ray Milkeyf19b7152014-11-21 10:56:52 -08003 *
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;
Ray Milkey7bf273c2017-09-27 16:15:15 -070021import org.onosproject.net.flow.oldbatch.FlowRuleBatchEntry;
22import org.onosproject.net.flow.oldbatch.FlowRuleBatchOperation;
Brian O'Connorabafb502014-12-02 22:26:20 -080023import org.onosproject.net.intent.IntentTestsMocks;
Ray Milkeyf19b7152014-11-21 10:56:52 -080024
25import com.google.common.testing.EqualsTester;
26
27/**
28 * Unit tests for flow rule batch classes.
29 */
30public class FlowRuleBatchOperationTest {
31
32 /**
33 * Tests the equals(), hashCode() and toString() methods.
34 */
35 @Test
36 public void testEquals() {
37 final FlowRule rule = new IntentTestsMocks.MockFlowRule(1);
38 final FlowRuleBatchEntry entry1 = new FlowRuleBatchEntry(
39 FlowRuleBatchEntry.FlowRuleOperation.ADD, rule);
40 final FlowRuleBatchEntry entry2 = new FlowRuleBatchEntry(
41 FlowRuleBatchEntry.FlowRuleOperation.MODIFY, rule);
42 final FlowRuleBatchEntry entry3 = new FlowRuleBatchEntry(
43 FlowRuleBatchEntry.FlowRuleOperation.REMOVE, rule);
44 final LinkedList<FlowRuleBatchEntry> ops1 = new LinkedList<>();
45 ops1.add(entry1);
46 final LinkedList<FlowRuleBatchEntry> ops2 = new LinkedList<>();
47 ops1.add(entry2);
48 final LinkedList<FlowRuleBatchEntry> ops3 = new LinkedList<>();
49 ops3.add(entry3);
50
Brian O'Connor72cb19a2015-01-16 16:14:41 -080051 final FlowRuleBatchOperation operation1 = new FlowRuleBatchOperation(ops1, null, 0);
52 final FlowRuleBatchOperation sameAsOperation1 = new FlowRuleBatchOperation(ops1, null, 0);
53 final FlowRuleBatchOperation operation2 = new FlowRuleBatchOperation(ops2, null, 0);
54 final FlowRuleBatchOperation operation3 = new FlowRuleBatchOperation(ops3, null, 0);
Ray Milkeyf19b7152014-11-21 10:56:52 -080055
56 new EqualsTester()
57 .addEqualityGroup(operation1, sameAsOperation1)
58 .addEqualityGroup(operation2)
59 .addEqualityGroup(operation3)
60 .testEquals();
61 }
62}