blob: b5a415f96f1ff47f2bac0ba4edfd0a60c97b098e [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.*;
19
20import org.junit.Test;
21
22import com.google.common.collect.ImmutableList;
23import com.google.common.testing.EqualsTester;
24
25/**
26 * Test of DisjointPathPair.
27 */
28public class DisjointPathPairTest {
29
30 private static final TestVertex A = new TestVertex("A");
31 private static final TestVertex B = new TestVertex("B");
32 private static final TestVertex C = new TestVertex("C");
33 private static final TestVertex D = new TestVertex("D");
34
35 private static final TestEdge AB = new TestEdge(A, B, 1.0);
36 private static final TestEdge BC = new TestEdge(B, C, 1.0);
37 private static final TestEdge AD = new TestEdge(A, D, 1.0);
38 private static final TestEdge DC = new TestEdge(D, C, 1.0);
39
40 private static final Path<TestVertex, TestEdge> ABC
41 = new DefaultPath<>(ImmutableList.of(AB, BC), 1.0);
42 private static final Path<TestVertex, TestEdge> ADC
43 = new DefaultPath<>(ImmutableList.of(AD, DC), 1.0);
44
45 @Test
46 public void testSwappingPrimarySecondaryDoesntImpactHashCode() {
47 assertEquals(new DisjointPathPair<>(ABC, ADC).hashCode(),
48 new DisjointPathPair<>(ADC, ABC).hashCode());
49 }
50
51 @Test
52 public void testSwappingPrimarySecondaryDoesntImpactEquality() {
53 new EqualsTester()
54 .addEqualityGroup(new DisjointPathPair<>(ABC, ADC),
55 new DisjointPathPair<>(ADC, ABC));
56 }
57
58}