diff --git a/src/test/java/it/unibz/inf/isochrone/db/DatabaseTest.java b/src/test/java/it/unibz/inf/isochrone/db/DatabaseTest.java index 4c053eaf1ba522d6611784365c1719f69fe5cdde..abd86205fde9aec9ef051ce14c8095b1b81c9840 100644 --- a/src/test/java/it/unibz/inf/isochrone/db/DatabaseTest.java +++ b/src/test/java/it/unibz/inf/isochrone/db/DatabaseTest.java @@ -22,8 +22,6 @@ public class DatabaseTest { private static final int EXPECTED_NODE_COUNT = 2687; private static final int LINK_ID = 1846; private static final int NODE_ID = 5013; - - private Database db; private Map<Integer, Node> nodes; private Map<Integer, Link> links; @@ -31,9 +29,6 @@ public class DatabaseTest { public void setUp() { nodes = new HashMap<Integer, Node>(); links = new LinkedHashMap<Integer, Link>(); - - db = new Database(Dataset.BZ, Mode.MULTIMODAL, Direction.INCOMING); - db.readNetwork(nodes, links); } @AfterTest @@ -47,6 +42,7 @@ public class DatabaseTest { @Test public void testCreateDatabaseObject() { + final Database db = new Database(Dataset.BZ, Mode.MULTIMODAL, Direction.INCOMING); Assert.assertNotNull(db, "Database object could not be created!"); } @@ -56,12 +52,16 @@ public class DatabaseTest { final LinkedHashMap<Integer, Link> compareLinks = new LinkedHashMap<Integer, Link>(); fillHashMaps(compareNodes, compareLinks); + initDb(); + Assert.assertEquals(nodes.get(NODE_ID), compareNodes.get(NODE_ID), "Nodes comparison"); Assert.assertEquals(links.get(LINK_ID), compareLinks.get(LINK_ID), "Links comparison"); } @Test public void testCountEdges() { + initDb(); + // 2687 Doesn't correspond to the number of nodes in // the nodes table, but the number of distinct // target/source node in the edges table @@ -71,6 +71,13 @@ public class DatabaseTest { // Private methods + private Database initDb() { + final Database db = new Database(Dataset.BZ, Mode.MULTIMODAL, Direction.INCOMING); + db.readNetwork(nodes, links); + + return db; + } + private void fillHashMaps(final HashMap<Integer, Node> nodeHashMap, final LinkedHashMap<Integer, Link> linkHashMap) { final Node n1 = new Node(NODE_ID);