Commit 99890b19 authored by Ethan Ordentlich's avatar Ethan Ordentlich
Browse files

update beavermaps and dijkstra tests

parent 5e8ef627
1 merge request!2Review Tests for Project 8
Pipeline #46658 canceled with stage
Showing with 88 additions and 54 deletions
+88 -54
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="BeaverMapsGraph Tests (C)" type="JUnit" factoryName="JUnit">
<module name="project08-beavermaps" />
<option name="MAIN_CLASS_NAME" value="" />
<option name="METHOD_NAME" value="" />
<option name="TEST_OBJECT" value="tags" />
<tag value="C &amp; Beavermap" />
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
</component>
\ No newline at end of file
...@@ -75,8 +75,7 @@ public class BeaverMapsGraph extends Graph<Long, Double> { ...@@ -75,8 +75,7 @@ public class BeaverMapsGraph extends Graph<Long, Double> {
} }
/** /**
* Returns a set of locations which are no more than threshold feet * Returns a set of locations which are reachable along a path that goes no further than `threshold` feet from start
* away from start.
* @param start the location to search around * @param start the location to search around
* @param threshold the number of feet in the search radius * @param threshold the number of feet in the search radius
* @return * @return
......
...@@ -44,6 +44,26 @@ public class BeavermapTests { ...@@ -44,6 +44,26 @@ public class BeavermapTests {
} }
@Tag("C") @Tag("C")
@Tag("Beavermap")
@DisplayName("BeaverMapsGraph implements required public methods")
@Test
@Order(0)
public void testMethodsBeaverMapsGraph() {
SortedSet<String> expected = new TreeSet<>(List.of(
"getLocationByName", "getBuildings", "getClosestBuilding", "dfs", "dijkstra", "addVertex"
));
SortedSet<String> actual = new TreeSet<>(
Stream.of(BeaverMapsGraph.class.getDeclaredMethods())
.filter(Reflection.hasModifier("public"))
.map(x -> x.getName())
.collect(Collectors.toList()));
MatcherAssert.assertThat(new ArrayList<>(actual),
IsIterableContaining.hasItems((expected.toArray())));
}
@Tag("C")
@Tag("Beavermap")
@Order(1)
@DisplayName("Does not use or import disallowed classes") @DisplayName("Does not use or import disallowed classes")
@Test @Test
public void testForInvalidClasses() { public void testForInvalidClasses() {
...@@ -52,10 +72,11 @@ public class BeavermapTests { ...@@ -52,10 +72,11 @@ public class BeavermapTests {
Inspection.assertNoUsageOf(BEAVERMAP_GRAPH_SOURCE, graphDisallow); Inspection.assertNoUsageOf(BEAVERMAP_GRAPH_SOURCE, graphDisallow);
} }
@Order(1) @Order(2)
@DisplayName("Does not use or import disallowed classes from java.util") @DisplayName("Does not use or import disallowed classes from java.util")
@Test @Test
@Tag("C") @Tag("C")
@Tag("Beavermap")
public void testForInvalidImportsJavaUtil() { public void testForInvalidImportsJavaUtil() {
List<String> allowed = List.of("Iterator"); List<String> allowed = List.of("Iterator");
Inspection.assertNoImportsOfExcept(BEAVERMAP_GRAPH_SOURCE, "java\\.util", allowed); Inspection.assertNoImportsOfExcept(BEAVERMAP_GRAPH_SOURCE, "java\\.util", allowed);
...@@ -67,7 +88,10 @@ public class BeavermapTests { ...@@ -67,7 +88,10 @@ public class BeavermapTests {
// Only use Caltech map and buildings to test for correctness // Only use Caltech map and buildings to test for correctness
@Tag("C") @Tag("C")
@Tag("Beavermap")
@Test @Test
@Order(3)
@DisplayName("Test getLocationById()")
public void testGetLocationByID() { public void testGetLocationByID() {
BeaverMapsGraph bmg = new BeaverMapsGraph( BeaverMapsGraph bmg = new BeaverMapsGraph(
"data/caltech/caltech.buildings.json", "data/caltech/caltech.buildings.json",
...@@ -81,7 +105,10 @@ public class BeavermapTests { ...@@ -81,7 +105,10 @@ public class BeavermapTests {
} }
@Tag("C") @Tag("C")
@Tag("Beavermap")
@Test @Test
@Order(4)
@DisplayName("Test getLocationByName()")
public void testGetLocationByName() { public void testGetLocationByName() {
BeaverMapsGraph bmg = new BeaverMapsGraph( BeaverMapsGraph bmg = new BeaverMapsGraph(
"data/caltech/caltech.buildings.json", "data/caltech/caltech.buildings.json",
...@@ -97,12 +124,14 @@ public class BeavermapTests { ...@@ -97,12 +124,14 @@ public class BeavermapTests {
} }
@Tag("C") @Tag("C")
@Tag("Beavermap")
@DisplayName("Test getBuildings()") @DisplayName("Test getBuildings()")
@ParameterizedTest(name = "Test getBuildings() on {0}") @ParameterizedTest(name = "Test getBuildings() on {0}")
@CsvSource({ @CsvSource({
"caltech/caltech.buildings.json, caltech/caltech.waypoints.json, caltech/caltech.roads.json", "caltech/caltech.buildings.json, caltech/caltech.waypoints.json, caltech/caltech.roads.json",
"pasadena/pasadena.buildings.json, pasadena/pasadena.waypoints.json, pasadena/pasadena.roads.json", "pasadena/pasadena.buildings.json, pasadena/pasadena.waypoints.json, pasadena/pasadena.roads.json",
}) })
@Order(5)
public void testGetBuildings(String buildingsFile, String waypointsFile, String roadsFile) { public void testGetBuildings(String buildingsFile, String waypointsFile, String roadsFile) {
BeaverMapsGraph bmg = new BeaverMapsGraph( BeaverMapsGraph bmg = new BeaverMapsGraph(
"data/" + buildingsFile, "data/" + waypointsFile, "data/" + roadsFile); "data/" + buildingsFile, "data/" + waypointsFile, "data/" + roadsFile);
...@@ -117,12 +146,14 @@ public class BeavermapTests { ...@@ -117,12 +146,14 @@ public class BeavermapTests {
} }
@Tag("C") @Tag("C")
@Tag("Beavermap")
@DisplayName("Test getClosestBuilding()") @DisplayName("Test getClosestBuilding()")
@ParameterizedTest(name = "Test getClosestBuilding() on {0}") @ParameterizedTest(name = "Test getClosestBuilding() on {0}")
@CsvSource({ @CsvSource({
"caltech/caltech.buildings.json, caltech/caltech.waypoints.json, caltech/caltech.roads.json, caltech/caltech.closest_trace.json", "caltech/caltech.buildings.json, caltech/caltech.waypoints.json, caltech/caltech.roads.json, caltech/caltech.closest_trace.json",
"pasadena/pasadena.buildings.json, pasadena/pasadena.waypoints.json, pasadena/pasadena.roads.json, pasadena/pasadena.closest_trace.json", "pasadena/pasadena.buildings.json, pasadena/pasadena.waypoints.json, pasadena/pasadena.roads.json, pasadena/pasadena.closest_trace.json",
}) })
@Order(6)
public void testGetClosestLocation(String buildingsFile, String waypointsFile, String roadsFile, String traceFile) { public void testGetClosestLocation(String buildingsFile, String waypointsFile, String roadsFile, String traceFile) {
BeaverMapsGraph bmg = new BeaverMapsGraph( BeaverMapsGraph bmg = new BeaverMapsGraph(
"data/" + buildingsFile, "data/" + waypointsFile, "data/" + roadsFile); "data/" + buildingsFile, "data/" + waypointsFile, "data/" + roadsFile);
...@@ -138,8 +169,10 @@ public class BeavermapTests { ...@@ -138,8 +169,10 @@ public class BeavermapTests {
} }
@Tag("C") @Tag("C")
@DisplayName("Test addVertex() updates BeaverMapsGraph properly") @Tag("Beavermap")
@DisplayName("Test addVertex() updates BeaverMapsGraph and underlying Graph properly")
@Test @Test
@Order(7)
public void testAddVertexBeaverMapsGraph() { public void testAddVertexBeaverMapsGraph() {
BeaverMapsGraph bmg = new BeaverMapsGraph( BeaverMapsGraph bmg = new BeaverMapsGraph(
"data/caltech/caltech.buildings.json", "data/caltech/caltech.buildings.json",
...@@ -150,33 +183,20 @@ public class BeavermapTests { ...@@ -150,33 +183,20 @@ public class BeavermapTests {
Location loc = new Location(b.getAsJsonObject()); Location loc = new Location(b.getAsJsonObject());
bmg.addVertex(loc); bmg.addVertex(loc);
assertNotNull(bmg.getLocationByID(loc.id), "Location id " + loc.id + " not found by id"); assertNotNull(bmg.getLocationByID(loc.id), "Location id " + loc.id + " not found by id");
// Test that the vertex was actually added to the graph
bmg.neighbors(loc.id);
} }
} }
@Tag("C")
@DisplayName("BeaverMapsGraph implements required public methods")
@Test
public void testMethodsBeaverMapsGraph() {
SortedSet<String> expected = new TreeSet<>(List.of(
"getLocationByName", "getBuildings", "getClosestBuilding", "dfs", "dijkstra", "addVertex"
));
SortedSet<String> actual = new TreeSet<>(
Stream.of(BeaverMapsGraph.class.getDeclaredMethods())
.filter(Reflection.hasModifier("public"))
.map(x -> x.getName())
.collect(Collectors.toList()));
MatcherAssert.assertThat(new ArrayList<>(actual),
IsIterableContaining.hasItems((expected.toArray())));
}
// Note: Pasadena map is WAY TOO LARGE to test all edges, don't try // Note: Pasadena map is WAY TOO LARGE to test all edges, don't try
@Tag("C") @Tag("C")
@DisplayName("Tests nodes and edges in map for filename") @Tag("Beavermap")
@DisplayName("Completely check all nodes and edges in BeaverMapsGraph loaded from files")
@ParameterizedTest(name = "Test nodes in file {0}") @ParameterizedTest(name = "Test nodes in file {0}")
@CsvSource({ @CsvSource({
"caltech/caltech.buildings.json, caltech/caltech.waypoints.json, caltech/caltech.roads.json, caltech/caltech.neighbors_trace.json" "caltech/caltech.buildings.json, caltech/caltech.waypoints.json, caltech/caltech.roads.json, caltech/caltech.neighbors_trace.json"
}) })
@Order(8)
public void testNodesEdgesInMap(String bFile, String wFile, String roadsFile, String traceFile) { public void testNodesEdgesInMap(String bFile, String wFile, String roadsFile, String traceFile) {
BeaverMapsGraph bmg = new BeaverMapsGraph("data/" + bFile, "data/" + wFile, "data/" + roadsFile); BeaverMapsGraph bmg = new BeaverMapsGraph("data/" + bFile, "data/" + wFile, "data/" + roadsFile);
...@@ -204,6 +224,7 @@ public class BeavermapTests { ...@@ -204,6 +224,7 @@ public class BeavermapTests {
} }
// Use this instead of MatcherAssert to provide better errors (though I doubt they'll be needed) // Use this instead of MatcherAssert to provide better errors (though I doubt they'll be needed)
// Should use Truth instead... but not this year.
if (missingNeighbors.size() > 0) { if (missingNeighbors.size() > 0) {
fail(locID + " missing neighbors " + missingNeighbors); fail(locID + " missing neighbors " + missingNeighbors);
} else if (actualNeighbors.size() != 0) { } else if (actualNeighbors.size() != 0) {
...@@ -221,6 +242,7 @@ public class BeavermapTests { ...@@ -221,6 +242,7 @@ public class BeavermapTests {
"caltech/caltech.buildings.json, caltech/caltech.waypoints.json, caltech/caltech.roads.json, caltech/caltech.radius_trace.json", "caltech/caltech.buildings.json, caltech/caltech.waypoints.json, caltech/caltech.roads.json, caltech/caltech.radius_trace.json",
"pasadena/pasadena.buildings.json, pasadena/pasadena.waypoints.json, pasadena/pasadena.roads.json, pasadena/pasadena.radius_trace.json", "pasadena/pasadena.buildings.json, pasadena/pasadena.waypoints.json, pasadena/pasadena.roads.json, pasadena/pasadena.radius_trace.json",
}) })
@Order(9)
public void testDFSRadius(String buildingsFile, String waypointsFile, String roadsFile, String traceFile) { public void testDFSRadius(String buildingsFile, String waypointsFile, String roadsFile, String traceFile) {
BeaverMapsGraph bmg = new BeaverMapsGraph( BeaverMapsGraph bmg = new BeaverMapsGraph(
...@@ -252,6 +274,7 @@ public class BeavermapTests { ...@@ -252,6 +274,7 @@ public class BeavermapTests {
@Tag("A") @Tag("A")
@DisplayName("Test buildings are ignored in dijkstra path") @DisplayName("Test buildings are ignored in dijkstra path")
@Test @Test
@Order(10)
public void testDijkstraIgnoreBuildings() { public void testDijkstraIgnoreBuildings() {
BeaverMapsGraph bmg = new BeaverMapsGraph( BeaverMapsGraph bmg = new BeaverMapsGraph(
"data/caltech/caltech.buildings.json", "data/caltech/caltech.buildings.json",
...@@ -284,6 +307,7 @@ public class BeavermapTests { ...@@ -284,6 +307,7 @@ public class BeavermapTests {
"caltech/caltech.buildings.json, caltech/caltech.waypoints.json, caltech/caltech.roads.json, caltech/caltech.paths_trace.json", "caltech/caltech.buildings.json, caltech/caltech.waypoints.json, caltech/caltech.roads.json, caltech/caltech.paths_trace.json",
"pasadena/pasadena.buildings.json, pasadena/pasadena.waypoints.json, pasadena/pasadena.roads.json, pasadena/pasadena.paths_trace.json", "pasadena/pasadena.buildings.json, pasadena/pasadena.waypoints.json, pasadena/pasadena.roads.json, pasadena/pasadena.paths_trace.json",
}) })
@Order(11)
public void testDijkstraBeaverMap(String buildingsFile, String waypointsFile, String roadsFile, String traceFile) throws FileNotFoundException { public void testDijkstraBeaverMap(String buildingsFile, String waypointsFile, String roadsFile, String traceFile) throws FileNotFoundException {
BeaverMapsGraph bmg = new BeaverMapsGraph( BeaverMapsGraph bmg = new BeaverMapsGraph(
"data/" + buildingsFile, "data/" + waypointsFile, "data/" + roadsFile); "data/" + buildingsFile, "data/" + waypointsFile, "data/" + roadsFile);
......
...@@ -7,10 +7,7 @@ import edu.caltech.cs2.helpers.Reflection; ...@@ -7,10 +7,7 @@ import edu.caltech.cs2.helpers.Reflection;
import edu.caltech.cs2.interfaces.IDeque; import edu.caltech.cs2.interfaces.IDeque;
import edu.caltech.cs2.interfaces.IGraph; import edu.caltech.cs2.interfaces.IGraph;
import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.*;
import org.junit.jupiter.api.Order;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.CsvSource; import org.junit.jupiter.params.provider.CsvSource;
...@@ -25,13 +22,14 @@ import java.util.Scanner; ...@@ -25,13 +22,14 @@ import java.util.Scanner;
import static org.junit.jupiter.api.Assertions.*; import static org.junit.jupiter.api.Assertions.*;
@Tag("A") @Tag("A")
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
public class DijkstraTest { public class DijkstraTest {
@Order(0) @Order(0)
@DisplayName("Loop path should be singleton") @DisplayName("Loop path should be singleton")
@Test @Test
public void dijkstraShortTripTest() { public void dijkstraShortTripTest() {
IDeque<Location> res = GraphMaker.transformToLocations(GraphMaker.generateCompleteGraph(10)).dijkstra(new Location(1), new Location(1)); IDeque<Location> res = GraphMaker.transformToLocations(GraphMaker.completeGraph(10)).dijkstra(new Location(1), new Location(1));
assertEquals(1, res.size(), "Path from a node to itself should only include the node once"); assertEquals(1, res.size(), "Path from a node to itself should only include the node once");
assertEquals(res.peek(), new Location(1), "Path from a node to itself should only include the node once"); assertEquals(res.peek(), new Location(1), "Path from a node to itself should only include the node once");
} }
...@@ -40,27 +38,27 @@ public class DijkstraTest { ...@@ -40,27 +38,27 @@ public class DijkstraTest {
@DisplayName("Disconnected graph should not have a path") @DisplayName("Disconnected graph should not have a path")
@Test @Test
public void dijkstraDisconnectedTest() { public void dijkstraDisconnectedTest() {
IDeque<Location> res = GraphMaker.transformToLocations(GraphMaker.generateDisjointCompleteGraphs(10)).dijkstra(new Location(1), new Location(9)); IDeque<Location> res = GraphMaker.transformToLocations(GraphMaker.disjointCompleteGraphs(10)).dijkstra(new Location(1), new Location(9));
assertNull(res, "Disconnected graph should give null path"); assertNull(res, "Disconnected graph should give null path");
} }
@Order(2) @Order(2)
@ParameterizedTest @ParameterizedTest(name = "Graph: {0}, start: {1}, end: {2}, trace file: {3}")
@DisplayName("Tests correctness of Dijkstra implementation") @DisplayName("Tests correctness of Dijkstra implementation")
@CsvSource({ @CsvSource({
"graph1, 1, 3, simple_1_3", "simpleGraph, 1, 3, simple_1_3",
"graph2, 0, 1, line_0_1", "linearGraph, 0, 1, line_0_1",
"graph2, 0, 5, line_0_5", "linearGraph, 0, 5, line_0_5",
"graph2, 0, 20, line_0_20", "linearGraph, 0, 20, line_0_20",
"graph2, 0, 99, line_0_99", "linearGraph, 0, 99, line_0_99",
"graph2, 1, 0, line_1_0", "linearGraph, 1, 0, line_1_0",
"graph3, 0, 1, graph3_0_1", "tournamentGraph, 0, 1, graph3_0_1",
"graph3, 99, 0, graph3_99_0" "tournamentGraph, 99, 0, graph3_99_0"
}) })
public void dijkstraTestGraph(String graphName, int start, int end, String traceFile) public void dijkstraTestGraph(String graphName, int start, int end, String traceFile)
throws IllegalAccessException, InvocationTargetException, FileNotFoundException { throws IllegalAccessException, InvocationTargetException, FileNotFoundException {
BeaverMapsGraph bmg; BeaverMapsGraph bmg;
if (graphName.equals("graph1")) { if (graphName.equals("simpleGraph")) {
Method graphGen = Reflection.getMethod(GraphMaker.class, graphName); Method graphGen = Reflection.getMethod(GraphMaker.class, graphName);
bmg = GraphMaker.transformToLocations( bmg = GraphMaker.transformToLocations(
(IGraph<Integer, Integer>) graphGen.invoke(null)); (IGraph<Integer, Integer>) graphGen.invoke(null));
...@@ -121,6 +119,7 @@ public class DijkstraTest { ...@@ -121,6 +119,7 @@ public class DijkstraTest {
two = (two + 1) % num_vertices; two = (two + 1) % num_vertices;
int dice = r.nextInt(5); int dice = r.nextInt(5);
// TODO: y
if (dice <= 4) { if (dice <= 4) {
refg.addEdge(one, two, r.nextInt(100)); refg.addEdge(one, two, r.nextInt(100));
} else if (dice <= 5) { } else if (dice <= 5) {
...@@ -135,10 +134,10 @@ public class DijkstraTest { ...@@ -135,10 +134,10 @@ public class DijkstraTest {
String line = s.nextLine(); String line = s.nextLine();
if (line.equals("null")) { if (line.equals("null")) {
assertNull(res, "Path does not exist from " + startvertex + " to " + endvertex + " but was found"); assertNull(res, "Path does not exist from " + startvertex + " to " + endvertex + " but a path was found");
} }
else { else {
assertNotNull(res, "Path exists from " + startvertex + " to " + endvertex + " but was not found"); assertNotNull(res, "Path exists from " + startvertex + " to " + endvertex + " but a path was not found");
double pathLen = 0; double pathLen = 0;
Location prev = null; Location prev = null;
for (Location l : res) { for (Location l : res) {
...@@ -149,7 +148,7 @@ public class DijkstraTest { ...@@ -149,7 +148,7 @@ public class DijkstraTest {
} }
double expectedLen = Double.parseDouble(line); double expectedLen = Double.parseDouble(line);
assertEquals(expectedLen, pathLen, "Path lengths are not equivalent"); assertEquals(expectedLen, pathLen, "Path is not the shortest path by length");
} }
} }
} }
......
...@@ -27,7 +27,7 @@ public class GraphMaker { ...@@ -27,7 +27,7 @@ public class GraphMaker {
* Generate a simple graph * Generate a simple graph
* @return graph * @return graph
*/ */
public static IGraph<Integer, Integer> generateSimpleGraph() { public static IGraph<Integer, Integer> simpleGraph() {
IGraph<Integer, Integer> g = new Graph<>(); IGraph<Integer, Integer> g = new Graph<>();
g.addVertex(1); g.addVertex(1);
g.addVertex(2); g.addVertex(2);
...@@ -43,7 +43,7 @@ public class GraphMaker { ...@@ -43,7 +43,7 @@ public class GraphMaker {
* @param n - number of vertices in the linear graph * @param n - number of vertices in the linear graph
* @return graph, with edges labelled with the source vertex * @return graph, with edges labelled with the source vertex
*/ */
public static IGraph<Integer, Integer> generateLinearGraph(int n) { public static IGraph<Integer, Integer> linearGraph(int n) {
IGraph<Integer, Integer> g = new Graph<>(); IGraph<Integer, Integer> g = new Graph<>();
for (int i = 0; i < n; i++) { for (int i = 0; i < n; i++) {
assertTrue(g.addVertex(i), "Adding a new vertex should return true"); assertTrue(g.addVertex(i), "Adding a new vertex should return true");
...@@ -81,7 +81,7 @@ public class GraphMaker { ...@@ -81,7 +81,7 @@ public class GraphMaker {
* @param n - number of vertices * @param n - number of vertices
* @return graph * @return graph
*/ */
public static IGraph<Integer, Integer> generateTournamentGraph(int n) { public static IGraph<Integer, Integer> tournamentGraph(int n) {
IGraph<Integer, Integer> g = new Graph<>(); IGraph<Integer, Integer> g = new Graph<>();
for (int i = 0; i < n; i++) { for (int i = 0; i < n; i++) {
assertTrue(g.addVertex(i), "Adding a new vertex should return true"); assertTrue(g.addVertex(i), "Adding a new vertex should return true");
...@@ -115,7 +115,7 @@ public class GraphMaker { ...@@ -115,7 +115,7 @@ public class GraphMaker {
* @param n - number of vertices * @param n - number of vertices
* @return graph * @return graph
*/ */
public static IGraph<Integer, Integer> generateCompleteGraph(int n) { public static IGraph<Integer, Integer> completeGraph(int n) {
IGraph<Integer, Integer> g = new Graph<>(); IGraph<Integer, Integer> g = new Graph<>();
for (int i = 0; i < n; i++) { for (int i = 0; i < n; i++) {
assertTrue(g.addVertex(i), "Adding a new vertex should return true"); assertTrue(g.addVertex(i), "Adding a new vertex should return true");
...@@ -153,7 +153,7 @@ public class GraphMaker { ...@@ -153,7 +153,7 @@ public class GraphMaker {
* @param n - number of vertices in each complete component * @param n - number of vertices in each complete component
* @return graph * @return graph
*/ */
public static IGraph<Integer, Integer> generateDisjointCompleteGraphs(int n) { public static IGraph<Integer, Integer> disjointCompleteGraphs(int n) {
IGraph<Integer, Integer> g = new Graph<>(); IGraph<Integer, Integer> g = new Graph<>();
for (int i = 0; i < n; i++) { for (int i = 0; i < n; i++) {
assertTrue(g.addVertex(i), "Adding a new vertex should return true"); assertTrue(g.addVertex(i), "Adding a new vertex should return true");
......
...@@ -57,11 +57,11 @@ public class GraphTests { ...@@ -57,11 +57,11 @@ public class GraphTests {
@DisplayName("Test creating various graphs") @DisplayName("Test creating various graphs")
public void creationTest() { public void creationTest() {
assertTimeout(Duration.ofMillis(MEDIUM_OP_TIMEOUT_MS), () -> { assertTimeout(Duration.ofMillis(MEDIUM_OP_TIMEOUT_MS), () -> {
GraphMaker.generateSimpleGraph(); GraphMaker.simpleGraph();
GraphMaker.verifyLinearGraph(GraphMaker.generateLinearGraph(100), 100); GraphMaker.verifyLinearGraph(GraphMaker.linearGraph(100), 100);
GraphMaker.verifyTournamentGraph(GraphMaker.generateTournamentGraph(100), 100); GraphMaker.verifyTournamentGraph(GraphMaker.tournamentGraph(100), 100);
GraphMaker.verifyCompleteGraph(GraphMaker.generateCompleteGraph(100), 100); GraphMaker.verifyCompleteGraph(GraphMaker.completeGraph(100), 100);
GraphMaker.verifyDisjointCompleteGraphs(GraphMaker.generateDisjointCompleteGraphs(100), 100); GraphMaker.verifyDisjointCompleteGraphs(GraphMaker.disjointCompleteGraphs(100), 100);
}); });
} }
...@@ -206,7 +206,7 @@ public class GraphTests { ...@@ -206,7 +206,7 @@ public class GraphTests {
@DisplayName("Test that all edges in a complete graph are present") @DisplayName("Test that all edges in a complete graph are present")
public void adjacentStressTest() { public void adjacentStressTest() {
assertTimeout(Duration.ofMillis(STRESS_OP_TIMEOUT_MS), () -> { assertTimeout(Duration.ofMillis(STRESS_OP_TIMEOUT_MS), () -> {
IGraph<Integer, Integer> g = GraphMaker.generateCompleteGraph(400); IGraph<Integer, Integer> g = GraphMaker.completeGraph(400);
for (int i = 0; i < 400; i++) for (int i = 0; i < 400; i++)
for (int j = 0; j < 400; j++) for (int j = 0; j < 400; j++)
if (i != j) if (i != j)
...@@ -219,7 +219,7 @@ public class GraphTests { ...@@ -219,7 +219,7 @@ public class GraphTests {
@DisplayName("Test that directed edges in a tournament graph are correct") @DisplayName("Test that directed edges in a tournament graph are correct")
public void testNeighbors() { public void testNeighbors() {
assertTimeout(Duration.ofMillis(SIMPLE_OP_TIMEOUT_MS), () -> { assertTimeout(Duration.ofMillis(SIMPLE_OP_TIMEOUT_MS), () -> {
IGraph<Integer, Integer> g = GraphMaker.generateTournamentGraph(10); IGraph<Integer, Integer> g = GraphMaker.tournamentGraph(10);
Set<Integer> vertices = new HashSet<Integer>(); Set<Integer> vertices = new HashSet<Integer>();
for (int i = 0; i < 10; i++) { for (int i = 0; i < 10; i++) {
......
...@@ -13,7 +13,7 @@ import java.util.*; ...@@ -13,7 +13,7 @@ import java.util.*;
import static org.junit.jupiter.api.Assertions.*; import static org.junit.jupiter.api.Assertions.*;
@Tag("C") @Tag("C")
@DisplayName("Test graph of shared appearances in Marvel comic books") @DisplayName("Test graph of shared appearances in Marvel comic books (MarvelTests)")
public class MarvelTests { public class MarvelTests {
private static Graph<String, Integer> MARVEL_GRAPH; private static Graph<String, Integer> MARVEL_GRAPH;
private static final int COMMON_TIMEOUT_MS = 1500; private static final int COMMON_TIMEOUT_MS = 1500;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment