blob: 2501206b4256dd3de0dd9c1557cebc560a164139 [file] [log] [blame]
Thomas Vachuska24c849c2014-10-27 09:53:05 -07001/*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
tom144de692014-08-29 11:38:44 -070019package org.onlab.graph;
20
21import org.junit.Test;
22
23import static com.google.common.collect.ImmutableSet.of;
24import static org.junit.Assert.assertEquals;
25
26/**
27 * Base for all graph search tests.
28 */
29public abstract class AbstractGraphPathSearchTest extends GraphTest {
30
31 /**
32 * Creates a test-specific graph search to exercise.
33 *
34 * @return graph search
35 */
36 protected abstract AbstractGraphPathSearch<TestVertex, TestEdge> graphSearch();
37
38 @Test(expected = IllegalArgumentException.class)
39 public void noSuchSourceArgument() {
40 graphSearch().search(new AdjacencyListsGraph<>(of(B, C),
41 of(new TestEdge(B, C, 1))),
42 A, H, weight);
43 }
44
45 @Test(expected = NullPointerException.class)
46 public void nullGraphArgument() {
47 graphSearch().search(null, A, H, weight);
48 }
49
50 @Test(expected = NullPointerException.class)
51 public void nullSourceArgument() {
52 graphSearch().search(new AdjacencyListsGraph<>(of(B, C),
53 of(new TestEdge(B, C, 1))),
54 null, H, weight);
55 }
56
57 @Test
58 public void samenessThreshold() {
59 AbstractGraphPathSearch<TestVertex, TestEdge> search = graphSearch();
60 search.setSamenessThreshold(0.3);
61 assertEquals("incorrect threshold", 0.3, search.samenessThreshold(), 0.01);
62 }
63
64}