@Override public Departure createDeparture(final Id<Departure> departureId, final double time) { return new DepartureImpl(departureId, time); }
/** * In case we once should have more than one implementation of * {@link Departure}, simply inherit from this test and overwrite * this method to return your own implementation. * * @param id * @param time * @return a new instance of a Departure with the given attributes */ protected Departure createDeparture(final Id<Departure> id, final double time) { return new DepartureImpl(id, time); }
} else if (Constants.DEPARTURE.equals(name)) { Id<Departure> id = Id.create(atts.getValue(Constants.ID), Departure.class); Departure departure = new DepartureImpl(id, Time.parseTime(atts.getValue("departureTime"))); String vehicleRefId = atts.getValue(Constants.VEHICLE_REF_ID); if (vehicleRefId != null) {
} else if (Constants.DEPARTURE.equals(name)) { Id<Departure> id = Id.create(atts.getValue(Constants.ID), Departure.class); this.currentDeparture = new DepartureImpl(id, Time.parseTime(atts.getValue("departureTime"))); this.currentAttributes = this.currentDeparture.getAttributes(); String vehicleRefId = atts.getValue(Constants.VEHICLE_REF_ID);
public void testGetDeparturesImmutable() { Fixture f = new Fixture(); Departure dep1 = new DepartureImpl(Id.create(1, Departure.class), 7.0*3600); assertEquals(0, f.tRoute.getDepartures().size()); try { f.tRoute.getDepartures().put(dep1.getId(), dep1); fail("missing exception"); } catch (UnsupportedOperationException e) { log.info("catched expected exception.", e); } }
public void testAddDeparturesException() { Fixture f = new Fixture(); Departure dep1a = new DepartureImpl(Id.create(1, Departure.class), 7.0*3600); Departure dep1b = new DepartureImpl(Id.create(1, Departure.class), 7.0*3600); assertEquals(0, f.tRoute.getDepartures().size()); f.tRoute.addDeparture(dep1a); assertEquals(1, f.tRoute.getDepartures().size()); try { f.tRoute.addDeparture(dep1b); fail("missing exception."); } catch (IllegalArgumentException e) { log.info("catched expected exception.", e); } }
public void testAddDepartures() { Fixture f = new Fixture(); Departure dep1 = new DepartureImpl(Id.create(1, Departure.class), 7.0*3600); Departure dep2 = new DepartureImpl(Id.create(2, Departure.class), 8.0*3600); Departure dep3 = new DepartureImpl(Id.create(3, Departure.class), 9.0*3600); assertEquals(0, f.tRoute.getDepartures().size()); f.tRoute.addDeparture(dep1); assertEquals(1, f.tRoute.getDepartures().size()); assertEquals(dep1, f.tRoute.getDepartures().get(dep1.getId())); f.tRoute.addDeparture(dep2); assertEquals(2, f.tRoute.getDepartures().size()); assertEquals(dep1, f.tRoute.getDepartures().get(dep1.getId())); assertEquals(dep2, f.tRoute.getDepartures().get(dep2.getId())); assertNull(f.tRoute.getDepartures().get(dep3.getId())); f.tRoute.addDeparture(dep3); assertEquals(3, f.tRoute.getDepartures().size()); assertEquals(dep3, f.tRoute.getDepartures().get(dep3.getId())); }
public void testRemoveDepartures() { Fixture f = new Fixture(); Departure dep1 = new DepartureImpl(Id.create(1, Departure.class), 7.0*3600); Departure dep2 = new DepartureImpl(Id.create(2, Departure.class), 8.0*3600); f.tRoute.addDeparture(dep1); f.tRoute.addDeparture(dep2); assertEquals(2, f.tRoute.getDepartures().size()); assertNotNull(f.tRoute.getDepartures().get(dep1.getId())); assertNotNull(f.tRoute.getDepartures().get(dep2.getId())); assertTrue(f.tRoute.removeDeparture(dep1)); assertEquals(1, f.tRoute.getDepartures().size()); assertNull(f.tRoute.getDepartures().get(dep1.getId())); assertNotNull(f.tRoute.getDepartures().get(dep2.getId())); assertTrue(f.tRoute.removeDeparture(dep2)); assertEquals(0, f.tRoute.getDepartures().size()); f.tRoute.addDeparture(dep1); assertEquals(1, f.tRoute.getDepartures().size()); assertFalse(f.tRoute.removeDeparture(dep2)); assertEquals(1, f.tRoute.getDepartures().size()); assertNotNull(f.tRoute.getDepartures().get(dep1.getId())); }