Ray Milkey | f19b715 | 2014-11-21 10:56:52 -0800 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2014-present Open Networking Foundation |
Ray Milkey | f19b715 | 2014-11-21 10:56:52 -0800 | [diff] [blame] | 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'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 16 | package org.onosproject.net.flow; |
Ray Milkey | f19b715 | 2014-11-21 10:56:52 -0800 | [diff] [blame] | 17 | |
| 18 | import java.util.LinkedList; |
| 19 | |
| 20 | import org.junit.Test; |
Ray Milkey | 7bf273c | 2017-09-27 16:15:15 -0700 | [diff] [blame] | 21 | import org.onosproject.net.flow.oldbatch.FlowRuleBatchEntry; |
| 22 | import org.onosproject.net.flow.oldbatch.FlowRuleBatchOperation; |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 23 | import org.onosproject.net.intent.IntentTestsMocks; |
Ray Milkey | f19b715 | 2014-11-21 10:56:52 -0800 | [diff] [blame] | 24 | |
| 25 | import com.google.common.testing.EqualsTester; |
| 26 | |
| 27 | /** |
| 28 | * Unit tests for flow rule batch classes. |
| 29 | */ |
| 30 | public 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'Connor | 72cb19a | 2015-01-16 16:14:41 -0800 | [diff] [blame] | 51 | 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 Milkey | f19b715 | 2014-11-21 10:56:52 -0800 | [diff] [blame] | 55 | |
| 56 | new EqualsTester() |
| 57 | .addEqualityGroup(operation1, sameAsOperation1) |
| 58 | .addEqualityGroup(operation2) |
| 59 | .addEqualityGroup(operation3) |
| 60 | .testEquals(); |
| 61 | } |
| 62 | } |