diff --git a/src/test/java/GraphDataTest.java b/src/test/java/GraphDataTest.java index 7fed958..102d717 100644 --- a/src/test/java/GraphDataTest.java +++ b/src/test/java/GraphDataTest.java @@ -7,6 +7,7 @@ import java.nio.file.Files; import java.nio.file.Paths; import java.util.HashSet; +import java.util.List; import java.util.Set; import static org.junit.jupiter.api.Assertions.*; @@ -154,6 +155,21 @@ public void TestRemoveEdgeIfExists(){ assertThrows(Exception.class, () -> graphApi.removeEdge("B","C")); } + @Test + @DisplayName("Test dfs graph search api") + public void TestGraphSearch() { + Path path = graphApi.GraphSearch("C", "D"); + List expected = List.of(new String[]{"D", "A", "C"}); + assertEquals(path.path, expected); + } + + @Test + @DisplayName("Test dfs graph search api (node does not exist)") + public void TestGraphSearchNotExist() { + Path path = graphApi.GraphSearch("C", "X"); + assertNull(path); + } + @Test @DisplayName("Test DOT graph generation") public void TestOutputDOTGraph() throws IOException {