@Test public void testRemove() { MinimalTransferTimes mtt = new MinimalTransferTimesImpl(); Assert.assertEquals(Double.NaN, mtt.get(this.stopId1, this.stopId2), 0.0); mtt.set(this.stopId1, this.stopId2, 180.0); mtt.set(this.stopId1, this.stopId3, 240.0); Assert.assertEquals(180.0, mtt.get(this.stopId1, this.stopId2), 0.0); Assert.assertEquals(240.0, mtt.get(this.stopId1, this.stopId3), 0.0); Assert.assertEquals(180.0, mtt.remove(this.stopId1, this.stopId2), 0.0); Assert.assertEquals(Double.NaN, mtt.get(this.stopId1, this.stopId2), 0.0); Assert.assertEquals(240.0, mtt.get(this.stopId1, this.stopId3), 0.0); Assert.assertEquals(Double.NaN, mtt.remove(this.stopId1, this.stopId4), 0.0); // we never set it, let's not throw an exception Assert.assertEquals(Double.NaN, mtt.get(this.stopId1, this.stopId4), 0.0); }
@Test public void testValidator_Transfers_missingStop() { Scenario scenario = ScenarioUtils.createScenario(ConfigUtils.createConfig()); TransitSchedule schedule = scenario.getTransitSchedule(); TransitScheduleFactory factory = schedule.getFactory(); Id<TransitStopFacility> id1 = Id.create("stop1", TransitStopFacility.class); Id<TransitStopFacility> id2 = Id.create("stop2", TransitStopFacility.class); Id<TransitStopFacility> id3 = Id.create("stop3", TransitStopFacility.class); Id<TransitStopFacility> id4 = Id.create("stop4", TransitStopFacility.class); schedule.addStopFacility(factory.createTransitStopFacility(id1, new Coord(10000, 10000), false)); schedule.addStopFacility(factory.createTransitStopFacility(id2, new Coord(20000, 10000), false)); schedule.getMinimalTransferTimes().set(id1, id3, 120); TransitScheduleValidator.ValidationResult result = TransitScheduleValidator.validateTransfers(schedule); Assert.assertEquals("Should warn against missing stop3.", 1, result.getIssues().size()); Assert.assertTrue("Message should contain hint about stop3 being missing. " + result.getIssues().get(0).getMessage(), result.getIssues().get(0).getMessage().contains("stop3")); schedule.getMinimalTransferTimes().remove(id1, id3); schedule.getMinimalTransferTimes().set(id4, id2, 120); result = TransitScheduleValidator.validateTransfers(schedule); Assert.assertEquals("Should warn against missing stop4.", 1, result.getIssues().size()); Assert.assertTrue("Message should contain hint about stop4 being missing. " + result.getIssues().get(0).getMessage(), result.getIssues().get(0).getMessage().contains("stop4")); }