2 * Copyright (c) 2015 Huawei, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.nemo.intent.algorithm;
9 import edu.uci.ics.jung.algorithms.filters.EdgePredicateFilter;
10 import edu.uci.ics.jung.algorithms.shortestpath.DijkstraShortestPath;
11 import edu.uci.ics.jung.graph.DirectedSparseGraph;
12 import edu.uci.ics.jung.graph.Graph;
13 import edu.uci.ics.jung.graph.util.EdgeType;
14 import org.apache.commons.collections15.Predicate;
15 import org.apache.commons.collections15.Transformer;
16 import org.opendaylight.nemo.intent.algorithm.*;
19 import java.util.Collection;
20 import java.util.List;
21 import junit.framework.TestCase;
22 import org.junit.Assert;
23 import org.junit.Before;
24 import org.junit.Test;
25 import static org.mockito.Matchers.any;
26 import static org.mockito.Mockito.mock;
27 import static org.mockito.Mockito.never;
28 import static org.mockito.Mockito.verify;
29 import static org.mockito.Mockito.when;
30 import static org.mockito.Mockito.*;
31 import static org.junit.Assert.*;
34 * Created by zhangmeng on 2015/11/6.
36 public class RoutingAlgorithmTest extends TestCase {
37 private Graph<Vertex,Edge> graph;
38 private DijkstraShortestPath<Vertex, Edge> dijkstraShortestPath;
39 private RoutingAlgorithm routingAlgorithm;
42 public void setUp() throws Exception {
43 graph = mock(DirectedSparseGraph.class);
44 dijkstraShortestPath = mock(DijkstraShortestPath.class);
45 routingAlgorithm = mock(RoutingAlgorithm.class);
49 public void testGetVertex() throws Exception {
50 Vertex vertex = routingAlgorithm.getVertex(null);
51 Assert.assertNull(vertex);
55 public void testGetEdge() throws Exception {
56 Edge edge = routingAlgorithm.getEdge(null);
57 Assert.assertNull(edge);
61 public void testGetVertices() throws Exception {
62 Collection<Vertex> collection = routingAlgorithm.getVertices();
63 Assert.assertNotNull(collection);
67 public void testAddVertex() throws Exception {
68 Vertex vertex = mock(Vertex.class);
69 Assert.assertNotNull(vertex);
70 routingAlgorithm.addVertex(vertex);
71 verify(routingAlgorithm).addVertex(vertex);
72 Assert.assertNotNull(routingAlgorithm);
76 public void testAddEdge() throws Exception {
77 Edge edge = mock(Edge.class);
78 Assert.assertNotNull(edge);
79 routingAlgorithm.addEdge(edge);
80 verify(routingAlgorithm).addEdge(edge);
81 Assert.assertNotNull(routingAlgorithm);
86 public void testRemoveVertex() throws Exception {
88 routingAlgorithm.removeVertex(flag);
89 Assert.assertNotNull(routingAlgorithm);
90 verify(routingAlgorithm).removeVertex(flag);
94 public void testRemoveEdge() throws Exception {
96 routingAlgorithm.removeEdge(flag);
97 Assert.assertNotNull(routingAlgorithm);
98 verify(routingAlgorithm).removeEdge(flag);
102 public void testComputePath() throws Exception {
103 List<Edge> list = mock(List.class);
104 list = routingAlgorithm.computePath(mock(Vertex.class),mock(Vertex.class));
105 Assert.assertNotNull(list);
109 public void testComputePath1() throws Exception {
110 List<Edge> list = mock(List.class);
111 list = routingAlgorithm.computePath(mock(Vertex.class),mock(Vertex.class));
112 Assert.assertNotNull(list);
116 public void testToString() throws Exception {
117 Assert.assertNotNull(routingAlgorithm.toString());