From bc67e95f7fed441af6581cac13e5a95fb1201945 Mon Sep 17 00:00:00 2001 From: Holt59 Date: Sat, 24 Feb 2018 21:12:07 +0100 Subject: [PATCH] Switch from ArrayList to List in Graph. --- src/main/org/insa/graph/Graph.java | 9 ++++----- src/test/org/insa/graph/PathTest.java | 20 ++++++++++++++++++++ 2 files changed, 24 insertions(+), 5 deletions(-) create mode 100644 src/test/org/insa/graph/PathTest.java diff --git a/src/main/org/insa/graph/Graph.java b/src/main/org/insa/graph/Graph.java index 748eed2..97f7d8c 100644 --- a/src/main/org/insa/graph/Graph.java +++ b/src/main/org/insa/graph/Graph.java @@ -1,6 +1,5 @@ package org.insa.graph; -import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -10,15 +9,15 @@ public class Graph { private final int mapId; // Nodes of the graph. - private final ArrayList nodes; + private final List nodes; /** * @param mapId ID of this graph. - * @param nodes List of nodes for this graph. + * @param list List of nodes for this graph. */ - public Graph(int mapId, ArrayList nodes) { + public Graph(int mapId, List list) { this.mapId = mapId; - this.nodes = nodes; + this.nodes = list; } /** diff --git a/src/test/org/insa/graph/PathTest.java b/src/test/org/insa/graph/PathTest.java new file mode 100644 index 0000000..55f3157 --- /dev/null +++ b/src/test/org/insa/graph/PathTest.java @@ -0,0 +1,20 @@ +package org.insa.graph; + +import java.io.IOException; +import java.util.Arrays; + +import org.junit.jupiter.api.BeforeAll; + +public class PathTest { + + // Small graph use for tests + private Graph graph; + + @BeforeAll + static void initAll() throws IOException { + Node[] nodes = new Node[] {}; + + graph = new Graph(0, Arrays.asList(nodes)); + } + +}