Brian O'Connor | 7cbbbb7 | 2016-04-09 02:13:23 -0700 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2015-present Open Networking Foundation |
Brian O'Connor | 7cbbbb7 | 2016-04-09 02:13:23 -0700 | [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 | */ |
HIGUCHI Yuta | ca9cc8e | 2015-10-29 23:26:51 -0700 | [diff] [blame] | 16 | package org.onlab.graph; |
| 17 | |
| 18 | import static org.junit.Assert.*; |
Andrey Komarov | 2398d96 | 2016-09-26 15:11:23 +0300 | [diff] [blame] | 19 | import static org.onlab.graph.GraphTest.W1; |
HIGUCHI Yuta | ca9cc8e | 2015-10-29 23:26:51 -0700 | [diff] [blame] | 20 | |
| 21 | import org.junit.Test; |
| 22 | |
| 23 | import com.google.common.collect.ImmutableList; |
| 24 | import com.google.common.testing.EqualsTester; |
| 25 | |
| 26 | /** |
| 27 | * Test of DisjointPathPair. |
| 28 | */ |
| 29 | public class DisjointPathPairTest { |
| 30 | |
| 31 | private static final TestVertex A = new TestVertex("A"); |
| 32 | private static final TestVertex B = new TestVertex("B"); |
| 33 | private static final TestVertex C = new TestVertex("C"); |
| 34 | private static final TestVertex D = new TestVertex("D"); |
| 35 | |
Andrey Komarov | 2398d96 | 2016-09-26 15:11:23 +0300 | [diff] [blame] | 36 | private static final TestEdge AB = new TestEdge(A, B); |
| 37 | private static final TestEdge BC = new TestEdge(B, C); |
| 38 | private static final TestEdge AD = new TestEdge(A, D); |
| 39 | private static final TestEdge DC = new TestEdge(D, C); |
HIGUCHI Yuta | ca9cc8e | 2015-10-29 23:26:51 -0700 | [diff] [blame] | 40 | |
Andrey Komarov | 2398d96 | 2016-09-26 15:11:23 +0300 | [diff] [blame] | 41 | private static final Path<TestVertex, TestEdge> ABC = |
| 42 | new DefaultPath<>(ImmutableList.of(AB, BC), W1); |
| 43 | private static final Path<TestVertex, TestEdge> ADC = |
| 44 | new DefaultPath<>(ImmutableList.of(AD, DC), W1); |
HIGUCHI Yuta | ca9cc8e | 2015-10-29 23:26:51 -0700 | [diff] [blame] | 45 | |
| 46 | @Test |
| 47 | public void testSwappingPrimarySecondaryDoesntImpactHashCode() { |
| 48 | assertEquals(new DisjointPathPair<>(ABC, ADC).hashCode(), |
| 49 | new DisjointPathPair<>(ADC, ABC).hashCode()); |
| 50 | } |
| 51 | |
| 52 | @Test |
| 53 | public void testSwappingPrimarySecondaryDoesntImpactEquality() { |
| 54 | new EqualsTester() |
| 55 | .addEqualityGroup(new DisjointPathPair<>(ABC, ADC), |
Ray Milkey | 1f8fcc3 | 2018-09-17 14:25:29 -0700 | [diff] [blame] | 56 | new DisjointPathPair<>(ADC, ABC)) |
| 57 | .testEquals(); |
HIGUCHI Yuta | ca9cc8e | 2015-10-29 23:26:51 -0700 | [diff] [blame] | 58 | } |
| 59 | |
| 60 | } |