|
1 | 1 | package com.baeldung.graph; |
2 | 2 |
|
3 | | -import org.junit.Assert; |
| 3 | +import static org.junit.Assert.assertEquals; |
4 | 4 | import org.junit.Test; |
5 | 5 |
|
6 | | -public class GraphTraversalUnitTest { |
| 6 | +public class GraphUnitTest { |
7 | 7 | @Test |
8 | 8 | public void givenAGraph_whenTraversingDepthFirst_thenExpectedResult() { |
9 | 9 | Graph graph = createGraph(); |
10 | | - Assert.assertEquals("[Bob, Rob, Maria, Alice, Mark]", |
| 10 | + assertEquals("[Bob, Rob, Maria, Alice, Mark]", |
11 | 11 | GraphTraversal.depthFirstTraversal(graph, "Bob").toString()); |
12 | 12 | } |
13 | 13 |
|
14 | 14 | @Test |
15 | 15 | public void givenAGraph_whenTraversingBreadthFirst_thenExpectedResult() { |
16 | 16 | Graph graph = createGraph(); |
17 | | - Assert.assertEquals("[Bob, Alice, Rob, Mark, Maria]", |
| 17 | + assertEquals("[Bob, Alice, Rob, Mark, Maria]", |
| 18 | + GraphTraversal.breadthFirstTraversal(graph, "Bob").toString()); |
| 19 | + } |
| 20 | + |
| 21 | + @Test |
| 22 | + public void givenAGraph_whenRemoveVertex_thenVertedNotFound() { |
| 23 | + Graph graph = createGraph(); |
| 24 | + assertEquals("[Bob, Alice, Rob, Mark, Maria]", |
| 25 | + GraphTraversal.breadthFirstTraversal(graph, "Bob").toString()); |
| 26 | + |
| 27 | + graph.removeVertex("Maria"); |
| 28 | + assertEquals("[Bob, Alice, Rob, Mark]", |
18 | 29 | GraphTraversal.breadthFirstTraversal(graph, "Bob").toString()); |
19 | 30 | } |
20 | 31 |
|
|
0 commit comments