/** * Checks for the correct removal of a vehicle. * * @throws IOException */ @Test public void testRemoveVehicle() throws IOException { getFirstVehicle(); RemoveVehicleQuery rvq = conn.queryRemoveVehicle(); rvq.setVehicleData(firstVehicle, 1); rvq.run(); conn.nextSimStep(); assertNull(conn.getVehicleRepository().getByID(firstVehicle.getID())); }
/** * This test ensures that a vehicle's X/Y position never goes outside the road bounds. * * @throws IOException */ @Test public void testVehiclePositionIsInBounds() throws IOException { getFirstVehicle(); while (conn.getVehicleRepository().getByID(firstVehicle.getID()) != null) { Point2D pos = firstVehicle.getPosition(); assertTrue(pos.getX() >= 0); assertTrue(pos.getX() < 2500); assertEquals(-1.65, pos.getY(), DELTA); conn.nextSimStep(); } }
/** * This test shows how to change a vehicle's destination road to "end", which is just before the * default "rend", then advances the simulation to check that "rend" is never traversed by the * vehicle until it exits. * * @throws IOException */ @Test public void testChangeTarget() throws IOException { getFirstVehicle(); Vehicle v = firstVehicle; Edge endEdge = conn.getEdgeRepository().getByID("end"); v.changeTarget(endEdge); Edge lastEdge = null; while (conn.getVehicleRepository().getByID(v.getID()) != null) { lastEdge = v.getCurrentEdge(); assertFalse(lastEdge.getID().equals("rend")); conn.nextSimStep(); } }