From 1bf5cd272c0aa62d90b296db3c602cd8ef9eceff Mon Sep 17 00:00:00 2001
From: Nikolaus Krismer <nikolaus.krismer@uibk.ac.at>
Date: Wed, 13 Aug 2014 12:50:03 +0200
Subject: [PATCH] added test for reachable bus stations (fixes todo in
 isochrone class)

---
 .../isochrone/network/ReachabilityTest.java   | 63 +++++++++++++++++++
 1 file changed, 63 insertions(+)
 create mode 100644 src/test/java/it/unibz/inf/isochrone/network/ReachabilityTest.java

diff --git a/src/test/java/it/unibz/inf/isochrone/network/ReachabilityTest.java b/src/test/java/it/unibz/inf/isochrone/network/ReachabilityTest.java
new file mode 100644
index 00000000..c9ffeb70
--- /dev/null
+++ b/src/test/java/it/unibz/inf/isochrone/network/ReachabilityTest.java
@@ -0,0 +1,63 @@
+package it.unibz.inf.isochrone.network;
+
+import it.unibz.inf.isochrone.algorithm.MineX;
+import it.unibz.inf.isochrone.config.ConfigDataset;
+import it.unibz.inf.isochrone.network.AlgorithmHelper.AlgorithmResult;
+import it.unibz.inf.isochrone.util.EnumContainer.Direction;
+import it.unibz.inf.isochrone.util.EnumContainer.Mode;
+
+import java.util.Calendar;
+import java.util.Collection;
+import java.util.GregorianCalendar;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.testng.Assert;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+/**
+ * This checks if some well known isochrones are calculated the right way. Note
+ * that there is the possibility that one of the test fails due to changes in
+ * the network. So one should check for such changes (e.g. by visual isochrone
+ * comparison using a GUI), before fixing a broken test.
+ */
+public class ReachabilityTest {
+	private static final Logger LOGGER = LoggerFactory.getLogger(ReachabilityTest.class);
+	// local test parameters
+	private static final String DATASET = "bz";
+	private static final Double WALKING_SPEED = 1.0;
+	private static final int DURATION = 900;
+	private static final Calendar TIME = new GregorianCalendar(2011, 9, 14, 9, 0, 0);
+	private static final int STARTNODE_ID = 2000499; // FUB; Dominikanerplatz (also NodeID 2000500)
+	private static final Mode MODE = Mode.MULTIMODAL;
+	private static final Direction DIRECTION = Direction.INCOMING;
+	private static final TestParameters PARAM_LOCAL = new TestParameters(WALKING_SPEED, DURATION, TIME, MODE, STARTNODE_ID, DATASET, DIRECTION);
+
+	@BeforeClass
+	public void setup() {
+		LOGGER.info("Starting test(s) in class \"" + ReachabilityTest.class.getSimpleName() + "\"");
+		// loads dataset configurations (we do this before testing, so timings are correct)
+		ConfigDataset.getInstance(PARAM_LOCAL.getDataset());
+	}
+
+	@Test
+	public void testBzBusStation15() {
+		final int nodeIdToCheck = 5117; // bus station id = 5117; Defregger Str./Fagenstraße (reachable by bus route 1)
+
+		LOGGER.info("Checking nodes from FUB (15min isncoming isochrone)");
+		final AlgorithmResult result = AlgorithmHelper.run(MineX.class, PARAM_LOCAL, true);
+		final Collection<Node> resultNodes = result.getOutput().getNodes();
+
+		boolean foundNode = false;
+		for (final Node node : resultNodes) {
+			if (node.getId() == nodeIdToCheck) {
+				foundNode = true;
+				break;
+			}
+		}
+
+		Assert.assertTrue(foundNode, "Expected node not found in 15min incoming isochrone to FUB");
+	}
+
+}
-- 
GitLab