blob: 4d49048e2d2521ee5d1425b5202d47caec8e07c3 [file] [log] [blame]
Brian O'Connor7cbbbb72016-04-09 02:13:23 -07001/*
2 * Copyright 2015-present 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 */
HIGUCHI Yutaca9cc8e2015-10-29 23:26:51 -070016package org.onlab.graph;
17
18import static org.junit.Assert.*;
Andrey Komarov2398d962016-09-26 15:11:23 +030019import static org.onlab.graph.GraphTest.W1;
HIGUCHI Yutaca9cc8e2015-10-29 23:26:51 -070020
21import org.junit.Test;
22
23import com.google.common.collect.ImmutableList;
24import com.google.common.testing.EqualsTester;
25
26/**
27 * Test of DisjointPathPair.
28 */
29public 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 Komarov2398d962016-09-26 15:11:23 +030036 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 Yutaca9cc8e2015-10-29 23:26:51 -070040
Andrey Komarov2398d962016-09-26 15:11:23 +030041 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 Yutaca9cc8e2015-10-29 23:26:51 -070045
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),
56 new DisjointPathPair<>(ADC, ABC));
57 }
58
59}