Add partical test files
[nemo.git] / nemo-impl / src / test / java / org / opendaylight / nemo / intent / algorithm / RoutingAlgorithmTest.java
1 /*
2  * Copyright (c) 2015 Huawei, Inc. and others. All rights reserved.
3  *
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
7  */
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.*;
17
18
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.*;
32
33 /**
34  * Created by zhangmeng on 2015/11/6.
35  */
36 public class RoutingAlgorithmTest extends TestCase {
37     private Graph<Vertex,Edge> graph;
38     private DijkstraShortestPath<Vertex, Edge> dijkstraShortestPath;
39     private RoutingAlgorithm routingAlgorithm;
40
41     @Before
42     public void setUp() throws Exception {
43         graph = mock(DirectedSparseGraph.class);
44         dijkstraShortestPath = mock(DijkstraShortestPath.class);
45         routingAlgorithm = mock(RoutingAlgorithm.class);
46     }
47
48     @Test
49     public void testGetVertex() throws Exception {
50         Vertex vertex = routingAlgorithm.getVertex(null);
51         Assert.assertNull(vertex);
52     }
53
54     @Test
55     public void testGetEdge() throws Exception {
56         Edge edge = routingAlgorithm.getEdge(null);
57         Assert.assertNull(edge);
58     }
59
60     @Test
61     public void testGetVertices() throws Exception {
62         Collection<Vertex> collection = routingAlgorithm.getVertices();
63         Assert.assertNotNull(collection);
64     }
65
66     @Test
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);
73     }
74
75     @Test
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);
82     }
83
84
85     @Test
86     public void testRemoveVertex() throws Exception {
87         String flag = "test";
88         routingAlgorithm.removeVertex(flag);
89         Assert.assertNotNull(routingAlgorithm);
90         verify(routingAlgorithm).removeVertex(flag);
91     }
92
93     @Test
94     public void testRemoveEdge() throws Exception {
95         String flag = "test";
96         routingAlgorithm.removeEdge(flag);
97         Assert.assertNotNull(routingAlgorithm);
98         verify(routingAlgorithm).removeEdge(flag);
99     }
100
101     @Test
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);
106     }
107
108     @Test
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);
113     }
114
115     @Test
116     public void testToString() throws Exception {
117         Assert.assertNotNull(routingAlgorithm.toString());
118     }
119 }