use of jmri.jmrit.operations.locations.LocationManager in project JMRI by JMRI.
the class ManageLocationsFrame method saveTableValues.
@SuppressFBWarnings(value = "WMI_WRONG_MAP_ITERATOR", justification = "only in slow debug")
private void saveTableValues() {
if ((Boolean) locModel.getValueAt(0, 1)) {
listenerLoc.setLocation((Double) locModel.getValueAt(0, 2), (Double) locModel.getValueAt(0, 3), (Double) locModel.getValueAt(0, 4));
listenerLoc.setOrientation((Double) locModel.getValueAt(0, 5), (Double) locModel.getValueAt(0, 6));
VSDecoderManager.instance().getVSDecoderPreferences().setListenerPosition(listenerLoc);
}
HashMap<String, PhysicalLocation> data = reporterModel.getDataMap();
ReporterManager mgr = jmri.InstanceManager.getDefault(jmri.ReporterManager.class);
for (String s : data.keySet()) {
log.debug("Reporter: " + s + " Location: " + data.get(s));
Reporter r = mgr.getByDisplayName(s);
PhysicalLocation.setBeanPhysicalLocation(data.get(s), r);
}
data = blockModel.getDataMap();
BlockManager bmgr = jmri.InstanceManager.getDefault(jmri.BlockManager.class);
for (String s : data.keySet()) {
log.debug("Block: " + s + " Location: " + data.get(s));
Block b = bmgr.getByDisplayName(s);
PhysicalLocation.setBeanPhysicalLocation(data.get(s), b);
}
data = opsModel.getDataMap();
LocationManager lmgr = LocationManager.instance();
for (String s : data.keySet()) {
log.debug("OpsLocation: " + s + " Location: " + data.get(s));
Location l = lmgr.getLocationByName(s);
l.setPhysicalLocation(data.get(s));
}
}
use of jmri.jmrit.operations.locations.LocationManager in project JMRI by JMRI.
the class ScheduleGuiTests method loadLocations.
private void loadLocations() {
// create 5 locations
LocationManager lManager = LocationManager.instance();
Location l1 = lManager.newLocation("Test Loc E");
l1.addTrack("Test Track", Track.SPUR);
Location l2 = lManager.newLocation("Test Loc D");
l2.setLength(1002);
Location l3 = lManager.newLocation("Test Loc C");
l3.setLength(1003);
Location l4 = lManager.newLocation("Test Loc B");
l4.setLength(1004);
Location l5 = lManager.newLocation("Test Loc A");
l5.setLength(1005);
}
use of jmri.jmrit.operations.locations.LocationManager in project JMRI by JMRI.
the class ScheduleGuiTests method testScheduleOptionsFrame.
@Test
public void testScheduleOptionsFrame() {
Assume.assumeFalse(GraphicsEnvironment.isHeadless());
LocationManager lManager = LocationManager.instance();
Track track = lManager.getLocationByName("Test Loc E").getTrackByName("Test Track", null);
ScheduleManager sManager = ScheduleManager.instance();
Schedule schedule = sManager.newSchedule("test schedule");
ScheduleEditFrame f = new ScheduleEditFrame(schedule, track);
Assert.assertNotNull(f);
// TODO improve test
ScheduleOptionsFrame sf = new ScheduleOptionsFrame(f);
Assert.assertNotNull(sf);
sf.dispose();
f.dispose();
}
use of jmri.jmrit.operations.locations.LocationManager in project JMRI by JMRI.
the class OperationsCarRouterTest method testCarRouting.
/**
* Test car routing. First set of tests confirm proper operation of just one
* location. The next set of tests confirms operation using one train and
* two locations. When this test was written, routing up to 5 trains and 6
* locations was supported.
*
*/
public void testCarRouting() {
// now load up the managers
TrainManager tmanager = TrainManager.instance();
RouteManager rmanager = RouteManager.instance();
LocationManager lmanager = LocationManager.instance();
Router router = Router.instance();
CarManager cmanager = CarManager.instance();
CarTypes ct = CarTypes.instance();
// register the car and engine types used
ct.addName("Boxcar");
ct.addName("Caboose");
ct.addName("Flat");
// create 6 locations and tracks
Location Acton = lmanager.newLocation("Acton MA");
Assert.assertEquals("Location 1 Name", "Acton MA", Acton.getName());
Assert.assertEquals("Location 1 Initial Length", 0, Acton.getLength());
Track AS1 = Acton.addTrack("Acton Siding 1", Track.SPUR);
AS1.setLength(300);
Assert.assertEquals("Location AS1 Name", "Acton Siding 1", AS1.getName());
Assert.assertEquals("Location AS1 Length", 300, AS1.getLength());
Track AS2 = Acton.addTrack("Acton Siding 2", Track.SPUR);
AS2.setLength(300);
Assert.assertEquals("Location AS2 Name", "Acton Siding 2", AS2.getName());
Assert.assertEquals("Location AS2 Length", 300, AS2.getLength());
Track AY = Acton.addTrack("Acton Yard", Track.YARD);
AY.setLength(400);
Assert.assertEquals("Location AY Name", "Acton Yard", AY.getName());
Assert.assertEquals("Location AY Length", 400, AY.getLength());
Track AI = Acton.addTrack("Acton Interchange", Track.INTERCHANGE);
AI.setLength(500);
Assert.assertEquals("Track AI Name", "Acton Interchange", AI.getName());
Assert.assertEquals("Track AI Length", 500, AI.getLength());
Assert.assertEquals("Track AI Train Directions", DIRECTION_ALL, AI.getTrainDirections());
// add a second interchange track
Track AI2 = Acton.addTrack("Acton Interchange 2", Track.INTERCHANGE);
AI2.setLength(500);
// bias tracks
AI2.setMoves(100);
Assert.assertEquals("Track AI2 Name", "Acton Interchange 2", AI2.getName());
Assert.assertEquals("Track AI2 Length", 500, AI2.getLength());
Assert.assertEquals("Track AI2 Train Directions", DIRECTION_ALL, AI2.getTrainDirections());
Location Bedford = lmanager.newLocation("Bedford MA");
Assert.assertEquals("Location 1 Name", "Bedford MA", Bedford.getName());
Assert.assertEquals("Location 1 Initial Length", 0, Bedford.getLength());
Track BS1 = Bedford.addTrack("Bedford Siding 1", Track.SPUR);
BS1.setLength(300);
Assert.assertEquals("Location BS1 Name", "Bedford Siding 1", BS1.getName());
Assert.assertEquals("Location BS1 Length", 300, BS1.getLength());
Track BS2 = Bedford.addTrack("Bedford Siding 2", Track.SPUR);
BS2.setLength(300);
Assert.assertEquals("Location BS2 Name", "Bedford Siding 2", BS2.getName());
Assert.assertEquals("Location BS2 Length", 300, BS2.getLength());
Track BY = Bedford.addTrack("Bedford Yard", Track.YARD);
BY.setLength(400);
Assert.assertEquals("Location BY Name", "Bedford Yard", BY.getName());
Assert.assertEquals("Location BY Length", 400, BY.getLength());
Track BI = Bedford.addTrack("Bedford Interchange", Track.INTERCHANGE);
BI.setLength(500);
Assert.assertEquals("Track BI Name", "Bedford Interchange", BI.getName());
Assert.assertEquals("Track BI Length", 500, BI.getLength());
Location Clinton = lmanager.newLocation("Clinton MA");
Assert.assertEquals("Location 1 Name", "Clinton MA", Clinton.getName());
Assert.assertEquals("Location 1 Initial Length", 0, Clinton.getLength());
Track CS1 = Clinton.addTrack("Clinton Siding 1", Track.SPUR);
CS1.setLength(300);
Assert.assertEquals("Location CS1 Name", "Clinton Siding 1", CS1.getName());
Assert.assertEquals("Location CS1 Length", 300, CS1.getLength());
Track CS2 = Clinton.addTrack("Clinton Siding 2", Track.SPUR);
CS2.setLength(300);
Assert.assertEquals("Location CS2 Name", "Clinton Siding 2", CS2.getName());
Assert.assertEquals("Location CS2 Length", 300, BS2.getLength());
Track CY = Clinton.addTrack("Clinton Yard", Track.YARD);
CY.setLength(400);
Assert.assertEquals("Location CY Name", "Clinton Yard", CY.getName());
Assert.assertEquals("Location CY Length", 400, CY.getLength());
Track CI = Clinton.addTrack("Clinton Interchange", Track.INTERCHANGE);
CI.setLength(500);
Assert.assertEquals("Track CI Name", "Clinton Interchange", CI.getName());
Assert.assertEquals("Track CI Length", 500, CI.getLength());
Location Danbury = lmanager.newLocation("Danbury MA");
Track DS1 = Danbury.addTrack("Danbury Siding 1", Track.SPUR);
DS1.setLength(300);
Track DS2 = Danbury.addTrack("Danbury Siding 2", Track.SPUR);
DS2.setLength(300);
Track DY = Danbury.addTrack("Danbury Yard", Track.YARD);
DY.setLength(400);
Track DI = Danbury.addTrack("Danbury Interchange", Track.INTERCHANGE);
DI.setLength(500);
Location Essex = lmanager.newLocation("Essex MA");
Track ES1 = Essex.addTrack("Essex Siding 1", Track.SPUR);
ES1.setLength(300);
Track ES2 = Essex.addTrack("Essex Siding 2", Track.SPUR);
ES2.setLength(300);
Track EY = Essex.addTrack("Essex Yard", Track.YARD);
EY.setLength(400);
Track EI = Essex.addTrack("Essex Interchange", Track.INTERCHANGE);
EI.setLength(500);
Location Foxboro = lmanager.newLocation("Foxboro MA");
Track FS1 = Foxboro.addTrack("Foxboro Siding 1", Track.SPUR);
FS1.setLength(300);
Track FS2 = Foxboro.addTrack("Foxboro Siding 2", Track.SPUR);
FS2.setLength(300);
Track FY = Foxboro.addTrack("Foxboro Yard", Track.YARD);
FY.setLength(400);
Track FI = Foxboro.addTrack("Foxboro Interchange", Track.INTERCHANGE);
FI.setLength(500);
// create 2 cars
Car c3 = cmanager.newCar("BA", "3");
c3.setTypeName("Boxcar");
c3.setLength("40");
c3.setOwner("DAB");
c3.setBuilt("1984");
Assert.assertEquals("Box Car 3 Length", "40", c3.getLength());
Car c4 = cmanager.newCar("BB", "4");
c4.setTypeName("Flat");
c4.setLength("40");
c4.setOwner("AT");
c4.setBuilt("1-86");
Assert.assertEquals("Box Car 4 Length", "40", c4.getLength());
Assert.assertEquals("place car at BI", Track.OKAY, c3.setLocation(Acton, AS1));
Assert.assertFalse("Try routing no final destination", router.setDestination(c3, null, null));
Assert.assertEquals("Check car's destination", "", c3.getDestinationName());
Assert.assertEquals("place car at Acton", Track.OKAY, c4.setLocation(Acton, AS1));
Assert.assertFalse("Try routing no final destination", router.setDestination(c4, null, null));
Assert.assertEquals("Check car's destination", "", c4.getDestinationName());
// test disable routing
Setup.setCarRoutingEnabled(false);
c3.setFinalDestination(Bedford);
Assert.assertFalse("Test router disabled", router.setDestination(c3, null, null));
Assert.assertEquals("Router status", Router.STATUS_ROUTER_DISABLED, router.getStatus());
Setup.setCarRoutingEnabled(true);
// first try car routing with just one location
c3.setFinalDestination(Acton);
Assert.assertFalse("Try routing final destination equal to current", router.setDestination(c3, null, null));
Assert.assertEquals("Check car's destination", "", c3.getDestinationName());
Assert.assertEquals("Router status", Router.STATUS_CAR_AT_DESINATION, router.getStatus());
// now try with next track not equal to current
c3.setFinalDestination(Acton);
c3.setFinalDestinationTrack(AS2);
Assert.assertFalse("Try routing final track not equal to current", router.setDestination(c3, null, null));
Assert.assertEquals("Check car's destination", "", c3.getDestinationName());
Assert.assertEquals("Router status", Router.STATUS_NOT_ABLE, router.getStatus());
// now try with next track equal to current
c3.setFinalDestination(Acton);
c3.setFinalDestinationTrack(AS1);
Assert.assertFalse("Try routing final track equal to current", router.setDestination(c3, null, null));
Assert.assertEquals("Check car's destination", "", c3.getDestinationName());
Assert.assertEquals("Router status", Router.STATUS_CAR_AT_DESINATION, router.getStatus());
// create a local train servicing Acton
Train ActonTrain = tmanager.newTrain("Acton Local");
Route routeA = rmanager.newRoute("A");
RouteLocation rlA = routeA.addLocation(Acton);
// set train icon coordinates
rlA.setTrainIconX(25);
rlA.setTrainIconY(250);
ActonTrain.setRoute(routeA);
c3.setFinalDestination(Acton);
c3.setFinalDestinationTrack(AS2);
Assert.assertTrue("Try routing final track with Acton Local", router.setDestination(c3, null, null));
Assert.assertEquals("Check car's destination", "Acton MA", c3.getDestinationName());
Assert.assertEquals("Check car's destination track", "Acton Siding 2", c3.getDestinationTrackName());
Assert.assertEquals("Router status", Track.OKAY, router.getStatus());
// specify the Acton train
// clear previous destination
c3.setDestination(null, null);
c3.setFinalDestination(Acton);
c3.setFinalDestinationTrack(AS2);
Assert.assertTrue("Try routing final track with Acton Local", router.setDestination(c3, ActonTrain, null));
Assert.assertEquals("Check car's destination", "Acton MA", c3.getDestinationName());
Assert.assertEquals("Check car's destination track", "Acton Siding 2", c3.getDestinationTrackName());
Assert.assertEquals("Router status", Track.OKAY, router.getStatus());
// Set the track length to be less the length of c3
AS2.setLength(c3.getTotalLength() - 1);
// clear previous destination
c3.setDestination(null, null);
// local move, alternate or yard track option should be ignored
c3.setFinalDestination(Acton);
c3.setFinalDestinationTrack(AS2);
Assert.assertTrue("Try routing final track with Acton Local", router.setDestination(c3, ActonTrain, null));
Assert.assertEquals("Check car's destination", "", c3.getDestinationName());
Assert.assertEquals("Check car's destination track", "", c3.getDestinationTrackName());
Assert.assertTrue("Should report that the issue was track length", router.getStatus().startsWith(Track.CAPACITY));
// restore track length
AS2.setLength(300);
// don't allow train to service boxcars
ActonTrain.deleteTypeName("Boxcar");
// and the next destination for the car
// clear previous destination
c3.setDestination(null, null);
c3.setFinalDestination(Acton);
c3.setFinalDestinationTrack(AS2);
Assert.assertFalse("Try routing with train that doesn't service Boxcar", router.setDestination(c3, null, null));
Assert.assertEquals("Check car's destination", "", c3.getDestinationName());
Assert.assertEquals("Router status", Router.STATUS_NOT_ABLE, router.getStatus());
// try the car type Flat
// clear previous destination
c4.setDestination(null, null);
c4.setFinalDestination(Acton);
c4.setFinalDestinationTrack(AS2);
Assert.assertTrue("Try routing with train that service Flat", router.setDestination(c4, null, null));
Assert.assertEquals("Check car's destination", "Acton MA", c4.getDestinationName());
Assert.assertEquals("Router status", Track.OKAY, router.getStatus());
// now allow Boxcar again
ActonTrain.addTypeName("Boxcar");
Assert.assertTrue("Try routing with train that does service Boxcar", router.setDestination(c3, null, null));
Assert.assertEquals("Check car's destination", "Acton MA", c3.getDestinationName());
Assert.assertEquals("Router status", Track.OKAY, router.getStatus());
// don't allow train to service boxcars with road name BA
ActonTrain.addRoadName("BA");
ActonTrain.setRoadOption(Train.EXCLUDE_ROADS);
// and the next destination for the car
// clear previous destination
c3.setDestination(null, null);
c3.setFinalDestination(Acton);
c3.setFinalDestinationTrack(AS2);
Assert.assertFalse("Try routing with train that doesn't service road name BA", router.setDestination(c3, null, null));
Assert.assertEquals("Check car's destination", "", c3.getDestinationName());
Assert.assertEquals("Router status", Router.STATUS_NOT_ABLE, router.getStatus());
// try the car road name BB
// clear previous destination
c4.setDestination(null, null);
c4.setFinalDestination(Acton);
c4.setFinalDestinationTrack(AS2);
Assert.assertTrue("Try routing with train that services road BB", router.setDestination(c4, null, null));
Assert.assertEquals("Check car's destination", "Acton MA", c4.getDestinationName());
Assert.assertEquals("Router status", Track.OKAY, router.getStatus());
// now try again but allow road name
ActonTrain.setRoadOption(Train.ALL_ROADS);
Assert.assertTrue("Try routing with train that does service road name BA", router.setDestination(c3, null, null));
Assert.assertEquals("Check car's destination", "Acton MA", c3.getDestinationName());
Assert.assertEquals("Router status", Track.OKAY, router.getStatus());
// don't service cars built before 1985
ActonTrain.setBuiltStartYear("1985");
ActonTrain.setBuiltEndYear("2010");
// and the next destination for the car
// clear previous destination
c3.setDestination(null, null);
c3.setFinalDestination(Acton);
c3.setFinalDestinationTrack(AS2);
Assert.assertFalse("Try routing with train that doesn't service car built before 1985", router.setDestination(c3, null, null));
Assert.assertEquals("Check car's destination", "", c3.getDestinationName());
Assert.assertEquals("Router status", Router.STATUS_NOT_ABLE, router.getStatus());
// try the car built after 1985
// clear previous destination
c4.setDestination(null, null);
c4.setFinalDestination(Acton);
c4.setFinalDestinationTrack(AS2);
Assert.assertTrue("Try routing with train that services car built after 1985", router.setDestination(c4, null, null));
Assert.assertEquals("Check car's destination", "Acton MA", c4.getDestinationName());
Assert.assertEquals("Router status", Track.OKAY, router.getStatus());
// car was built in 1984 should work
ActonTrain.setBuiltStartYear("1983");
Assert.assertTrue("Try routing with train that doesn't service car built before 1983", router.setDestination(c3, null, null));
Assert.assertEquals("Check car's destination", "Acton MA", c3.getDestinationName());
Assert.assertEquals("Router status", Track.OKAY, router.getStatus());
// try car loads
c3.setLoadName("Tools");
ActonTrain.addLoadName("Tools");
ActonTrain.setLoadOption(Train.EXCLUDE_LOADS);
// and the next destination for the car
// clear previous destination
c3.setDestination(null, null);
c3.setFinalDestination(Acton);
c3.setFinalDestinationTrack(AS2);
Assert.assertFalse("Try routing with train that doesn't service load Tools", router.setDestination(c3, null, null));
Assert.assertEquals("Check car's destination", "", c3.getDestinationName());
Assert.assertEquals("Router status", Router.STATUS_NOT_ABLE, router.getStatus());
// try the car load "E"
// clear previous destination
c4.setDestination(null, null);
c4.setFinalDestination(Acton);
c4.setFinalDestinationTrack(AS2);
Assert.assertTrue("Try routing with train that services load E", router.setDestination(c4, null, null));
Assert.assertEquals("Check car's destination", "Acton MA", c4.getDestinationName());
ActonTrain.setLoadOption(Train.ALL_LOADS);
Assert.assertTrue("Try routing with train that that does service load Tools", router.setDestination(c3, null, null));
Assert.assertEquals("Check car's destination", "Acton MA", c3.getDestinationName());
// now test by modifying the route
rlA.setPickUpAllowed(false);
// and the next destination for the car
// clear previous destination
c3.setDestination(null, null);
c3.setFinalDestination(Acton);
c3.setFinalDestinationTrack(AS2);
Assert.assertFalse("Try routing with train that doesn't pickup cars", router.setDestination(c3, null, null));
Assert.assertEquals("Check car's destination", "", c3.getDestinationName());
Assert.assertEquals("Router status", Router.STATUS_NOT_ABLE, router.getStatus());
rlA.setPickUpAllowed(true);
Assert.assertTrue("Try routing with train that that can pickup cars", router.setDestination(c3, null, null));
Assert.assertEquals("Check car's destination", "Acton MA", c3.getDestinationName());
rlA.setDropAllowed(false);
// and the next destination for the car
// clear previous destination
c3.setDestination(null, null);
c3.setFinalDestination(Acton);
c3.setFinalDestinationTrack(AS2);
Assert.assertFalse("Try routing with train that doesn't drop cars", router.setDestination(c3, null, null));
Assert.assertEquals("Check car's destination", "", c3.getDestinationName());
Assert.assertEquals("Router status", Router.STATUS_NOT_ABLE, router.getStatus());
rlA.setDropAllowed(true);
Assert.assertTrue("Try routing with train that that can drop cars", router.setDestination(c3, null, null));
Assert.assertEquals("Check car's destination", "Acton MA", c3.getDestinationName());
rlA.setMaxCarMoves(0);
// and the next destination for the car
// clear previous destination
c3.setDestination(null, null);
c3.setFinalDestination(Acton);
c3.setFinalDestinationTrack(AS2);
Assert.assertFalse("Try routing with train that doesn't service location", router.setDestination(c3, null, null));
Assert.assertEquals("Check car's destination", "", c3.getDestinationName());
Assert.assertEquals("Router status", Router.STATUS_NOT_ABLE, router.getStatus());
rlA.setMaxCarMoves(10);
Assert.assertTrue("Try routing with train that does service location", router.setDestination(c3, null, null));
Assert.assertEquals("Check car's destination", "Acton MA", c3.getDestinationName());
// test train depart direction
Assert.assertEquals("check default direction", Track.NORTH, rlA.getTrainDirection());
// set the depart location Acton to service by South bound trains only
Acton.setTrainDirections(Track.SOUTH);
// and the next destination for the car
// clear previous destination
c3.setDestination(null, null);
c3.setFinalDestination(Acton);
c3.setFinalDestinationTrack(AS2);
Assert.assertTrue("Try routing with local train that departs north, location south", router.setDestination(c3, null, null));
Assert.assertEquals("Check car's destination", "Acton MA", c3.getDestinationName());
Acton.setTrainDirections(Track.NORTH);
// clear previous destination
c3.setDestination(null, null);
c3.setFinalDestination(Acton);
c3.setFinalDestinationTrack(AS2);
Assert.assertTrue("Try routing with local train that departs north, location north", router.setDestination(c3, null, null));
Assert.assertEquals("Check car's destination", "Acton MA", c3.getDestinationName());
// set the depart track Acton to service by local train only
AS1.setTrainDirections(0);
// and the next destination for the car
// clear previous destination
c3.setDestination(null, null);
c3.setFinalDestination(Acton);
c3.setFinalDestinationTrack(AS2);
Assert.assertTrue("Try routing with local only", router.setDestination(c3, null, null));
Assert.assertEquals("Check car's destination", "Acton MA", c3.getDestinationName());
// clear previous destination
c3.setDestination(null, null);
c3.setFinalDestination(Acton);
c3.setFinalDestinationTrack(AS2);
AS1.setTrainDirections(Track.NORTH);
Assert.assertTrue("Try routing with local train that departs north, track north", router.setDestination(c3, null, null));
Assert.assertEquals("Check car's destination", "Acton MA", c3.getDestinationName());
// test arrival directions
// set the arrival track Acton to service by local trains only
AS2.setTrainDirections(0);
// and the next destination for the car
// clear previous destination
c3.setDestination(null, null);
c3.setFinalDestination(Acton);
// now specify the actual track
c3.setFinalDestinationTrack(AS2);
Assert.assertTrue("Try routing with local train", router.setDestination(c3, null, null));
Assert.assertEquals("Check car's destination", "Acton MA", c3.getDestinationName());
AS2.setTrainDirections(Track.NORTH);
// clear previous destination
c3.setDestination(null, null);
c3.setFinalDestination(Acton);
// now specify the actual track
c3.setFinalDestinationTrack(AS2);
Assert.assertTrue("Try routing with train that departs north, track north", router.setDestination(c3, null, null));
Assert.assertEquals("Check car's destination", "Acton MA", c3.getDestinationName());
// add a second local train
// create a local train servicing Acton
Route routeA2 = rmanager.newRoute("A2");
RouteLocation rlA2 = routeA2.addLocation(Acton);
// set train icon coordinates
rlA2.setTrainIconX(25);
rlA2.setTrainIconY(250);
Train ActonTrain2 = tmanager.newTrain("Acton Local 2");
ActonTrain2.setRoute(routeA2);
// try routing with this train
// clear previous destination
c3.setDestination(null, null);
c3.setFinalDestination(Acton);
c3.setFinalDestinationTrack(AS2);
Assert.assertTrue("Try routing final track with Acton Local", router.setDestination(c3, ActonTrain2, null));
Assert.assertEquals("Check car's destination", "Acton MA", c3.getDestinationName());
Assert.assertEquals("Check car's destination track", "Acton Siding 2", c3.getDestinationTrackName());
// don't allow Acton Local 2 to service boxcars
ActonTrain2.deleteTypeName("Boxcar");
// and the next destination for the car
// clear previous destination
c3.setDestination(null, null);
c3.setFinalDestination(Acton);
c3.setFinalDestinationTrack(AS2);
// Should be able to route using Acton Local, but destination should not be set
Assert.assertTrue("Try routing with train that doesn't service Boxcar", router.setDestination(c3, ActonTrain2, null));
Assert.assertEquals("Check car's destination", "", c3.getDestinationName());
Assert.assertEquals("Router status", Router.STATUS_NOT_THIS_TRAIN, router.getStatus());
// Two locations one train testing begins
// set next destination Bedford
// clear previous destination
c3.setDestination(null, null);
c3.setFinalDestination(Bedford);
c3.setFinalDestinationTrack(null);
// should fail no train!
Assert.assertFalse("Try routing with final destination", router.setDestination(c3, null, null));
// create a train with a route from Acton to Bedford
Train ActonToBedfordTrain = tmanager.newTrain("Acton to Bedford");
Route routeAB = rmanager.newRoute("AB");
RouteLocation rlActon = routeAB.addLocation(Acton);
RouteLocation rlBedford = routeAB.addLocation(Bedford);
// set train icon coordinates
rlBedford.setTrainIconX(100);
rlBedford.setTrainIconY(250);
ActonToBedfordTrain.setRoute(routeAB);
// should work
Assert.assertTrue("Try routing with final destination and train", router.setDestination(c3, null, null));
Assert.assertEquals("Check car's destination", "Bedford MA", c3.getDestinationName());
// try specific train
// clear previous destination
c3.setDestination(null, null);
c3.setFinalDestination(Bedford);
c3.setFinalDestinationTrack(null);
Assert.assertTrue("Try routing with final destination and train", router.setDestination(c3, ActonToBedfordTrain, null));
Assert.assertEquals("Check car's destination", "Bedford MA", c3.getDestinationName());
// don't allow train to service boxcars
ActonToBedfordTrain.deleteTypeName("Boxcar");
// and the next destination for the car
// clear previous destination
c3.setDestination(null, null);
c3.setFinalDestination(Bedford);
Assert.assertFalse("Try routing with train that doesn't service Boxcar", router.setDestination(c3, null, null));
Assert.assertEquals("Check car's destination", "", c3.getDestinationName());
Assert.assertEquals("Router status", Router.STATUS_NOT_ABLE, router.getStatus());
// try the car type Flat
// clear previous destination
c4.setDestination(null, null);
c4.setFinalDestination(Bedford);
c4.setFinalDestinationTrack(null);
Assert.assertTrue("Try routing with train that service Flat", router.setDestination(c4, null, null));
Assert.assertEquals("Check car's destination", "Bedford MA", c4.getDestinationName());
// now allow Boxcar again
ActonToBedfordTrain.addTypeName("Boxcar");
Assert.assertTrue("Try routing with train that does service Boxcar", router.setDestination(c3, null, null));
Assert.assertEquals("Check car's destination", "Bedford MA", c3.getDestinationName());
// don't allow train to service boxcars with road name BA
ActonToBedfordTrain.addRoadName("BA");
ActonToBedfordTrain.setRoadOption(Train.EXCLUDE_ROADS);
// and the next destination for the car
// clear previous destination
c3.setDestination(null, null);
c3.setFinalDestination(Bedford);
Assert.assertFalse("Try routing with train that doesn't service road name BA", router.setDestination(c3, null, null));
Assert.assertEquals("Check car's destination", "", c3.getDestinationName());
Assert.assertEquals("Router status", Router.STATUS_NOT_ABLE, router.getStatus());
// try the car road name BB
// clear previous destination
c4.setDestination(null, null);
c4.setFinalDestination(Bedford);
Assert.assertTrue("Try routing with train that services road BB", router.setDestination(c4, null, null));
Assert.assertEquals("Check car's destination", "Bedford MA", c4.getDestinationName());
// now try again but allow road name
ActonToBedfordTrain.setRoadOption(Train.ALL_ROADS);
Assert.assertTrue("Try routing with train that does service road name BA", router.setDestination(c3, null, null));
Assert.assertEquals("Check car's destination", "Bedford MA", c3.getDestinationName());
// don't service cars built before 1985
ActonToBedfordTrain.setBuiltStartYear("1985");
ActonToBedfordTrain.setBuiltEndYear("2010");
// and the next destination for the car
// clear previous destination
c3.setDestination(null, null);
c3.setFinalDestination(Bedford);
Assert.assertFalse("Try routing with train that doesn't service car built before 1985", router.setDestination(c3, null, null));
Assert.assertEquals("Check car's destination", "", c3.getDestinationName());
// try the car built after 1985
// clear previous destination
c4.setDestination(null, null);
c4.setFinalDestination(Bedford);
Assert.assertTrue("Try routing with train that services car built after 1985", router.setDestination(c4, null, null));
Assert.assertEquals("Check car's destination", "Bedford MA", c4.getDestinationName());
// car was built in 1984 should work
ActonToBedfordTrain.setBuiltStartYear("1983");
Assert.assertTrue("Try routing with train that doesn't service car built before 1983", router.setDestination(c3, null, null));
Assert.assertEquals("Check car's destination", "Bedford MA", c3.getDestinationName());
// try car loads
c3.setLoadName("Tools");
ActonToBedfordTrain.addLoadName("Tools");
ActonToBedfordTrain.setLoadOption(Train.EXCLUDE_LOADS);
// and the next destination for the car
// clear previous destination
c3.setDestination(null, null);
c3.setFinalDestination(Bedford);
Assert.assertFalse("Try routing with train that doesn't service load Tools", router.setDestination(c3, null, null));
Assert.assertEquals("Check car's destination", "", c3.getDestinationName());
// try the car load "E"
// clear previous destination
c4.setDestination(null, null);
c4.setFinalDestination(Bedford);
Assert.assertTrue("Try routing with train that services load E", router.setDestination(c4, null, null));
Assert.assertEquals("Check car's destination", "Bedford MA", c4.getDestinationName());
ActonToBedfordTrain.setLoadOption(Train.ALL_LOADS);
Assert.assertTrue("Try routing with train that that does service load Tools", router.setDestination(c3, null, null));
Assert.assertEquals("Check car's destination", "Bedford MA", c3.getDestinationName());
// don't allow Bedford to service Flat
// clear previous destination
c4.setDestination(null, null);
c4.setFinalDestination(Bedford);
Bedford.deleteTypeName("Flat");
Assert.assertFalse("Try routing with Bedford that does not service Flat", router.setDestination(c4, null, null));
Assert.assertEquals("Check car's destination", "", c4.getDestinationName());
Assert.assertTrue("Router status", router.getStatus().startsWith(Track.TYPE));
// restore Bedford can service Flat
Bedford.addTypeName("Flat");
// now test by modifying the route
rlActon.setPickUpAllowed(false);
// and the next destination for the car
// clear previous destination
c3.setDestination(null, null);
c3.setFinalDestination(Bedford);
Assert.assertFalse("Try routing with train that doesn't pickup cars", router.setDestination(c3, null, null));
Assert.assertEquals("Check car's destination", "", c3.getDestinationName());
rlActon.setPickUpAllowed(true);
Assert.assertTrue("Try routing with train that that can pickup cars", router.setDestination(c3, null, null));
Assert.assertEquals("Check car's destination", "Bedford MA", c3.getDestinationName());
rlBedford.setDropAllowed(false);
// and the next destination for the car
// clear previous destination
c3.setDestination(null, null);
c3.setFinalDestination(Bedford);
Assert.assertFalse("Try routing with train that doesn't drop cars", router.setDestination(c3, null, null));
Assert.assertEquals("Check car's destination", "", c3.getDestinationName());
rlBedford.setDropAllowed(true);
Assert.assertTrue("Try routing with train that that can drop cars", router.setDestination(c3, null, null));
Assert.assertEquals("Check car's destination", "Bedford MA", c3.getDestinationName());
rlBedford.setMaxCarMoves(0);
// and the next destination for the car
// clear previous destination
c3.setDestination(null, null);
c3.setFinalDestination(Bedford);
Assert.assertFalse("Try routing with train that doesn't service destination", router.setDestination(c3, null, null));
Assert.assertEquals("Check car's destination", "", c3.getDestinationName());
rlBedford.setMaxCarMoves(5);
Assert.assertTrue("Try routing with train that does service destination", router.setDestination(c3, null, null));
Assert.assertEquals("Check car's destination", "Bedford MA", c3.getDestinationName());
rlActon.setMaxCarMoves(0);
// and the next destination for the car
// clear previous destination
c3.setDestination(null, null);
c3.setFinalDestination(Bedford);
Assert.assertFalse("Try routing with train that doesn't service location", router.setDestination(c3, null, null));
Assert.assertEquals("Check car's destination", "", c3.getDestinationName());
rlActon.setMaxCarMoves(5);
Assert.assertTrue("Try routing with train that does service location", router.setDestination(c3, null, null));
Assert.assertEquals("Check car's destination", "Bedford MA", c3.getDestinationName());
// test train depart direction
Assert.assertEquals("check default direction", Track.NORTH, rlActon.getTrainDirection());
// set the depart location Acton to service by South bound trains only
Acton.setTrainDirections(Track.SOUTH);
// and the next destination for the car
// clear previous destination
c3.setDestination(null, null);
c3.setFinalDestination(Bedford);
// remove the Action local by not allowing train to service boxcars
ActonTrain.deleteTypeName("Boxcar");
Assert.assertFalse("Try routing with train that departs north, location south", router.setDestination(c3, null, null));
Assert.assertEquals("Check car's destination", "", c3.getDestinationName());
Acton.setTrainDirections(Track.NORTH);
Assert.assertTrue("Try routing with train that departs north, location north", router.setDestination(c3, null, null));
Assert.assertEquals("Check car's destination", "Bedford MA", c3.getDestinationName());
// set the depart track Acton to service by South bound trains only
AS1.setTrainDirections(Track.SOUTH);
// and the next destination for the car
// clear previous destination
c3.setDestination(null, null);
c3.setFinalDestination(Bedford);
Assert.assertFalse("Try routing with train that departs north, track south", router.setDestination(c3, null, null));
Assert.assertEquals("Check car's destination", "", c3.getDestinationName());
AS1.setTrainDirections(Track.NORTH);
Assert.assertTrue("Try routing with train that departs north, track north", router.setDestination(c3, null, null));
Assert.assertEquals("Check car's destination", "Bedford MA", c3.getDestinationName());
// test arrival directions
// set the arrival location Bedford to service by South bound trains only
Bedford.setTrainDirections(Track.SOUTH);
// and the next destination for the car
// clear previous destination
c3.setDestination(null, null);
c3.setFinalDestination(Bedford);
Assert.assertFalse("Try routing with train that arrives north, destination south", router.setDestination(c3, null, null));
Assert.assertEquals("Check car's destination", "", c3.getDestinationName());
Bedford.setTrainDirections(Track.NORTH);
Assert.assertTrue("Try routing with train that arrives north, destination north", router.setDestination(c3, null, null));
Assert.assertEquals("Check car's destination", "Bedford MA", c3.getDestinationName());
// set the depart track Acton to service by South bound trains only
BS1.setTrainDirections(Track.SOUTH);
// and the next destination for the car
// clear previous destination
c3.setDestination(null, null);
c3.setFinalDestination(Bedford);
Assert.assertTrue("Try routing with train that arrives north, but no final track", router.setDestination(c3, null, null));
Assert.assertEquals("Check car's destination", "Bedford MA", c3.getDestinationName());
// clear previous destination
c3.setDestination(null, null);
// the final destination for the car
c3.setFinalDestination(Bedford);
// now specify the actual track
c3.setFinalDestinationTrack(BS1);
Assert.assertFalse("Try routing with train that arrives north, now with track", router.setDestination(c3, null, null));
Assert.assertEquals("Check car's destination", "", c3.getDestinationName());
BS1.setTrainDirections(Track.NORTH);
Assert.assertTrue("Try routing with train that departs north, track north", router.setDestination(c3, null, null));
Assert.assertEquals("Check car's destination", "Bedford MA", c3.getDestinationName());
Setup.setOnlyActiveTrainsEnabled(true);
// clear previous destination
c3.setDestination(null, null);
c3.setFinalDestination(Bedford);
Assert.assertTrue("Try routing only active trains", router.setDestination(c3, null, null));
// now deselect the Action to Bedford train
ActonToBedfordTrain.setBuildEnabled(false);
// clear previous destination
c3.setDestination(null, null);
c3.setFinalDestination(Bedford);
Assert.assertFalse("Try routing only active trains, Action to Beford deselected", router.setDestination(c3, null, null));
Assert.assertEquals("Router status", Router.STATUS_NOT_ABLE, router.getStatus());
Setup.setOnlyActiveTrainsEnabled(false);
// clear previous destination
c3.setDestination(null, null);
c3.setFinalDestination(Bedford);
Assert.assertTrue("Try routing, only active trains deselected", router.setDestination(c3, null, null));
// test yard and alternate track options
BS1.setLength(c3.getTotalLength());
// c4 is the same length as c3, so the track is now full
Assert.assertEquals("Use up all of the space for BS1", Track.OKAY, c4.setLocation(Bedford, BS1));
// clear previous destination
c3.setDestination(null, null);
c3.setFinalDestination(Bedford);
c3.setFinalDestinationTrack(BS1);
Assert.assertTrue("Test search for yard", router.setDestination(c3, null, null));
Assert.assertEquals("Destination", "Bedford MA", c3.getDestinationName());
Assert.assertEquals("Destination track should be yard", "Bedford Yard", c3.getDestinationTrackName());
// the car was sent to a yard track because the spur was full
Assert.assertTrue("Should be reporting length issue", router.getStatus().startsWith(Track.LENGTH));
// remove yard type
BY.setTrackType(Track.SPUR);
// clear previous destination
c3.setDestination(null, null);
c3.setFinalDestination(Bedford);
c3.setFinalDestinationTrack(BS1);
Assert.assertTrue("Test search for yard that doesn't exist", router.setDestination(c3, null, null));
Assert.assertEquals("Destination", "", c3.getDestinationName());
Assert.assertTrue("Should be reporting length issue", router.getStatus().startsWith(Track.LENGTH));
// restore yard type
BY.setTrackType(Track.YARD);
// test alternate track option
BS1.setAlternateTrack(BS2);
// clear previous destination
c3.setDestination(null, null);
c3.setFinalDestination(Bedford);
c3.setFinalDestinationTrack(BS1);
Assert.assertTrue("Test use alternate", router.setDestination(c3, null, null));
Assert.assertEquals("Destination", "Bedford MA", c3.getDestinationName());
Assert.assertEquals("Destination track should be siding", "Bedford Siding 2", c3.getDestinationTrackName());
// the car was sent to the alternate track because the spur was full
Assert.assertTrue("Should be reporting length issue", router.getStatus().startsWith(Track.LENGTH));
// restore track length and remove alternate
BS1.setLength(300);
BS1.setAlternateTrack(null);
// One train tests complete. Start two train testing.
// Force first move to be by local train
AS1.setTrainDirections(0);
// restore the local
ActonTrain.addTypeName("Boxcar");
// clear previous destination
c3.setDestination(null, null);
// the final destination for the car
c3.setFinalDestination(Bedford);
// now specify the actual track
c3.setFinalDestinationTrack(BS1);
Assert.assertTrue("Try routing two trains via interchange", router.setDestination(c3, null, null));
Assert.assertEquals("Check car's destination", "Acton MA", c3.getDestinationName());
Assert.assertEquals("Check car's destination track", "Acton Interchange", c3.getDestinationTrackName());
// don't allow use of interchange track
AI.setDropOption(Track.TRAINS);
// clear previous destination
c3.setDestination(null, null);
// the final destination for the car
c3.setFinalDestination(Bedford);
// now specify the actual track
c3.setFinalDestinationTrack(BS1);
Assert.assertTrue("Try routing two trains via interchange", router.setDestination(c3, null, null));
Assert.assertEquals("Check car's destination", "Acton MA", c3.getDestinationName());
Assert.assertEquals("Check car's destination track", "Acton Interchange 2", c3.getDestinationTrackName());
AI2.setDropOption(Track.TRAINS);
// clear previous destination
c3.setDestination(null, null);
// the final destination for the car
c3.setFinalDestination(Bedford);
// now specify the actual track
c3.setFinalDestinationTrack(BS1);
Assert.assertTrue("Try routing two trains via yard", router.setDestination(c3, null, null));
Assert.assertEquals("Check car's destination", "Acton MA", c3.getDestinationName());
Assert.assertEquals("Check car's destination track", "Acton Yard", c3.getDestinationTrackName());
// allow use of interchange track
AI.setDropOption(Track.ANY);
AI2.setDropOption(Track.ANY);
// clear previous destination
c3.setDestination(null, null);
// the final destination for the car
c3.setFinalDestination(Bedford);
c3.setFinalDestinationTrack(BS1);
// allow Boxcars
ActonTrain2.addTypeName("Boxcar");
Assert.assertTrue("Try routing two trains", router.setDestination(c3, ActonTrain2, null));
Assert.assertEquals("Check car's destination", "Acton MA", c3.getDestinationName());
Assert.assertEquals("Check car's destination track", "Acton Interchange", c3.getDestinationTrackName());
// test to see if second interchange track used if first is full
AI.setLength(c3.getTotalLength() - 1);
// clear previous destination
c3.setDestination(null, null);
// the final destination for the car
c3.setFinalDestination(Bedford);
c3.setFinalDestinationTrack(BS1);
Assert.assertTrue("Try routing two trains to interchange track 2", router.setDestination(c3, ActonTrain2, null));
Assert.assertEquals("Check car's destination", "Acton MA", c3.getDestinationName());
Assert.assertEquals("Check car's destination track", "Acton Interchange 2", c3.getDestinationTrackName());
Assert.assertEquals("Router status", Track.OKAY, router.getStatus());
// use yard track if interchange tracks are full
AI2.setLength(c3.getTotalLength() - 1);
// clear previous destination
c3.setDestination(null, null);
// the final destination for the car
c3.setFinalDestination(Bedford);
c3.setFinalDestinationTrack(BS1);
Assert.assertTrue("Try routing two trains to yard track", router.setDestination(c3, ActonTrain2, null));
Assert.assertEquals("Check car's destination", "Acton MA", c3.getDestinationName());
Assert.assertEquals("Check car's destination track", "Acton Yard", c3.getDestinationTrackName());
// disable using yard tracks for routing
Setup.setCarRoutingViaYardsEnabled(false);
// clear previous destination
c3.setDestination(null, null);
// the final destination for the car
c3.setFinalDestination(Bedford);
c3.setFinalDestinationTrack(BS1);
router.setDestination(c3, ActonTrain2, null);
Assert.assertFalse("Try routing two trains to yard track", router.setDestination(c3, ActonTrain2, null));
Assert.assertEquals("Check car's destination", "", c3.getDestinationName());
Assert.assertEquals("Check car's destination track", "", c3.getDestinationTrackName());
// restore track length
AI.setLength(500);
AI2.setLength(500);
Setup.setCarRoutingViaYardsEnabled(true);
// don't allow train 2 to service boxcars with road name BA
ActonTrain2.addRoadName("BA");
ActonTrain2.setRoadOption(Train.EXCLUDE_ROADS);
// clear previous destination
c3.setDestination(null, null);
// the final destination for the car
c3.setFinalDestination(Bedford);
c3.setFinalDestinationTrack(BS1);
// routing should work using train 1, destination and track should not be set
Assert.assertTrue("Try routing two trains via yard", router.setDestination(c3, ActonTrain2, null));
Assert.assertEquals("Check car's destination", "", c3.getDestinationName());
Assert.assertEquals("Check car's destination track", "", c3.getDestinationTrackName());
// two train testing done!
// now try up to 5 trains to route car
// set final destination Clinton
// clear previous destination
c3.setDestination(null, null);
c3.setFinalDestination(Clinton);
c3.setFinalDestinationTrack(null);
// should fail no train!
Assert.assertFalse("Try routing with final destination", router.setDestination(c3, null, null));
// create a train with a route from Bedford to Clinton
Train BedfordToClintonTrain = tmanager.newTrain("Bedford to Clinton");
Route routeBC = rmanager.newRoute("BC");
routeBC.addLocation(Bedford);
RouteLocation rlchelmsford = routeBC.addLocation(Clinton);
// set train icon coordinates
rlchelmsford.setTrainIconX(175);
rlchelmsford.setTrainIconY(250);
BedfordToClintonTrain.setRoute(routeBC);
// should work
Assert.assertTrue("Try routing with final destination and train", router.setDestination(c3, null, null));
Assert.assertEquals("Check car's destination", "Acton MA", c3.getDestinationName());
Assert.assertEquals("Check car's destination track", "Acton Interchange", c3.getDestinationTrackName());
// allow train 2 to service boxcars with road name BA
ActonTrain2.setRoadOption(Train.ALL_ROADS);
// try with train 2
// clear previous destination
c3.setDestination(null, null);
c3.setFinalDestination(Clinton);
// routing should work using train 2
Assert.assertTrue("Try routing three trains", router.setDestination(c3, ActonTrain2, null));
Assert.assertEquals("Check car's destination", "Acton MA", c3.getDestinationName());
Assert.assertEquals("Check car's destination track", "Acton Interchange", c3.getDestinationTrackName());
// clear previous destination
c3.setDestination(null, null);
c3.setFinalDestination(Clinton);
// test to see if second interchange track used if first is full
AI.setLength(c3.getTotalLength() - 1);
// clear previous destination
c3.setDestination(null, null);
// the final destination for the car
c3.setFinalDestination(Clinton);
Assert.assertTrue("Try routing three trains to interchange track 2", router.setDestination(c3, ActonTrain2, null));
Assert.assertEquals("Check car's destination", "Acton MA", c3.getDestinationName());
Assert.assertEquals("Check car's destination track", "Acton Interchange 2", c3.getDestinationTrackName());
// use yard track if interchange tracks are full
AI2.setLength(c3.getTotalLength() - 1);
// clear previous destination
c3.setDestination(null, null);
// the final destination for the car
c3.setFinalDestination(Clinton);
Assert.assertTrue("Try routing three trains to yard track", router.setDestination(c3, ActonTrain2, null));
Assert.assertEquals("Check car's destination", "Acton MA", c3.getDestinationName());
Assert.assertEquals("Check car's destination track", "Acton Yard", c3.getDestinationTrackName());
// disable the use of yard tracks for routing
Setup.setCarRoutingViaYardsEnabled(false);
// clear previous destination
c3.setDestination(null, null);
// the final destination for the car
c3.setFinalDestination(Clinton);
// both interchange tracks are too short, so there isn't a route
Assert.assertFalse("Try routing three trains to yard track, option disabled", router.setDestination(c3, ActonTrain2, null));
Assert.assertEquals("Check car's destination", "", c3.getDestinationName());
Assert.assertEquals("Check car's destination track", "", c3.getDestinationTrackName());
// Try again with an interchange track that is long enough for car c3.
AI.setLength(c3.getTotalLength());
Assert.assertEquals("c4 consumes all of the interchange track", Track.OKAY, c4.setLocation(AI.getLocation(), AI));
// Track AI is long enough, but c4 is consuming all of the track, but there is a route!
Assert.assertTrue("Try routing three trains to yard track, option disabled", router.setDestination(c3, ActonTrain2, null));
Assert.assertEquals("Check car's destination", "", c3.getDestinationName());
Assert.assertEquals("Check car's destination track", "", c3.getDestinationTrackName());
// restore track length
AI.setLength(500);
AI2.setLength(500);
Setup.setCarRoutingViaYardsEnabled(true);
// clear previous destination
c3.setDestination(null, null);
// the final destination for the car
c3.setFinalDestination(Clinton);
// don't allow train 2 to service cars built before 1985
ActonTrain2.setBuiltStartYear("1985");
ActonTrain2.setBuiltEndYear("2010");
// routing should work using train 1, but destinations and track should not be set
Assert.assertTrue("Try routing three trains", router.setDestination(c3, ActonTrain2, null));
Assert.assertEquals("Check car's destination", "", c3.getDestinationName());
Assert.assertEquals("Check car's destination track", "", c3.getDestinationTrackName());
// allow car to be serviced
// car was built in 1984 should work
ActonTrain2.setBuiltStartYear("1983");
// set final destination Danbury
// clear previous destination
c3.setDestination(null, null);
c3.setFinalDestination(Danbury);
// should fail no train!
Assert.assertFalse("Try routing with final destination", router.setDestination(c3, null, null));
// create a train with a route from Clinton to Danbury
Train ClintonToDanburyTrain = tmanager.newTrain("Clinton to Danbury");
Route routeCD = rmanager.newRoute("CD");
routeCD.addLocation(Clinton);
RouteLocation rlDanbury = routeCD.addLocation(Danbury);
// set train icon coordinates
rlDanbury.setTrainIconX(250);
rlDanbury.setTrainIconY(250);
ClintonToDanburyTrain.setRoute(routeCD);
// should work
Assert.assertTrue("Try routing with final destination and train", router.setDestination(c3, null, null));
Assert.assertEquals("Check car's destination", "Acton MA", c3.getDestinationName());
Assert.assertEquals("Check car's destination track", "Acton Interchange", c3.getDestinationTrackName());
// clear previous destination
c3.setDestination(null, null);
// the final destination for the car
c3.setFinalDestination(Danbury);
// routing should work using train 2
Assert.assertTrue("Try routing four trains", router.setDestination(c3, ActonTrain2, null));
Assert.assertEquals("Check car's destination", "Acton MA", c3.getDestinationName());
Assert.assertEquals("Check car's destination track", "Acton Interchange", c3.getDestinationTrackName());
// clear previous destination
c3.setDestination(null, null);
// the final destination for the car
c3.setFinalDestination(Danbury);
// don't allow train 2 to service cars with load Tools
ActonTrain2.addLoadName("Tools");
ActonTrain2.setLoadOption(Train.EXCLUDE_LOADS);
// routing should work using train 1, but destinations and track should not be set
Assert.assertTrue("Try routing four trains", router.setDestination(c3, ActonTrain2, null));
Assert.assertEquals("Check car's destination", "", c3.getDestinationName());
Assert.assertEquals("Check car's destination track", "", c3.getDestinationTrackName());
// restore train 2
ActonTrain2.setLoadOption(Train.ALL_LOADS);
// set final destination Essex
// clear previous destination
c3.setDestination(null, null);
c3.setFinalDestination(Essex);
// should fail no train!
Assert.assertFalse("Try routing with final destination", router.setDestination(c3, null, null));
// create a train with a route from Danbury to Essex
Train DanburyToEssexTrain = tmanager.newTrain("Danbury to Essex");
Route routeDE = rmanager.newRoute("DE");
RouteLocation rlDanbury2 = routeDE.addLocation(Danbury);
RouteLocation rlEssex = routeDE.addLocation(Essex);
// set the number of car moves to 8 for a later test
rlDanbury2.setMaxCarMoves(8);
rlEssex.setMaxCarMoves(8);
// set train icon coordinates
rlEssex.setTrainIconX(25);
rlEssex.setTrainIconY(275);
DanburyToEssexTrain.setRoute(routeDE);
// should work
Assert.assertTrue("Try routing with final destination and train", router.setDestination(c3, null, null));
Assert.assertEquals("Check car's destination", "Acton MA", c3.getDestinationName());
Assert.assertEquals("Check car's destination track", "Acton Interchange", c3.getDestinationTrackName());
// routing should work using train 2
// clear previous destination
c3.setDestination(null, null);
c3.setFinalDestination(Essex);
Assert.assertTrue("Try routing five trains", router.setDestination(c3, ActonTrain2, null));
Assert.assertEquals("Check car's destination", "Acton MA", c3.getDestinationName());
Assert.assertEquals("Check car's destination track", "Acton Interchange", c3.getDestinationTrackName());
// clear previous destination
c3.setDestination(null, null);
c3.setFinalDestination(Essex);
// don't allow train 2 to pickup
rlA2.setPickUpAllowed(false);
// routing should work using train 1, but destinations and track should not be set
Assert.assertTrue("Try routing five trains", router.setDestination(c3, ActonTrain2, null));
Assert.assertEquals("Check car's destination", "", c3.getDestinationName());
Assert.assertEquals("Check car's destination track", "", c3.getDestinationTrackName());
Assert.assertEquals("Check status", Router.STATUS_NOT_THIS_TRAIN, router.getStatus());
// set final destination Foxboro
// clear previous destination
c3.setDestination(null, null);
c3.setFinalDestination(Foxboro);
// should fail no train!
Assert.assertFalse("Try routing with final destination", router.setDestination(c3, null, null));
// create a train with a route from Essex to Foxboro
Train EssexToFoxboroTrain = tmanager.newTrain("Essex to Foxboro");
Route routeEF = rmanager.newRoute("EF");
routeEF.addLocation(Essex);
RouteLocation rlFoxboro = routeEF.addLocation(Foxboro);
// set train icon coordinates
rlFoxboro.setTrainIconX(100);
rlFoxboro.setTrainIconY(275);
EssexToFoxboroTrain.setRoute(routeEF);
// 6th train should fail! Only 5 trains supported
Assert.assertFalse("Try routing with final destination and train", router.setDestination(c3, null, null));
Assert.assertFalse("Try routing with final destination and train", router.setDestination(c3, ActonTrain, null));
Assert.assertFalse("Try routing with final destination and train", router.setDestination(c3, ActonTrain2, null));
// get rid of the local train
AS1.setTrainDirections(Track.NORTH);
// now should work!
Assert.assertTrue("Try routing with final destination and train", router.setDestination(c3, null, null));
Assert.assertEquals("Check car's destination", "Bedford MA", c3.getDestinationName());
Assert.assertEquals("Check car's destination track", "Bedford Interchange", c3.getDestinationTrackName());
// require local train for next test
AS1.setTrainDirections(0);
//TODO test restrict location by car type
//TODO test restrict tracks by type road, load
}
use of jmri.jmrit.operations.locations.LocationManager in project JMRI by JMRI.
the class OperationsCarRouterTest method testRoutingWithSchedulesMatchMode2.
/*
* Using the setup from the previous tests, use trains and schedules to move
* cars. This test creates 1 schedule in match mode with multiple items.
* Cars use final destination to activate schedule
*/
public void testRoutingWithSchedulesMatchMode2() {
TrainManager tmanager = TrainManager.instance();
CarManager cmanager = CarManager.instance();
LocationManager lmanager = LocationManager.instance();
loadLocationsTrainsAndCars();
List<Train> trains = tmanager.getTrainsByNameList();
Assert.assertEquals("confirm number of trains", 7, trains.size());
Car c3 = cmanager.getByRoadAndNumber("BA", "3");
Car c4 = cmanager.getByRoadAndNumber("BB", "4");
Car c5 = cmanager.getByRoadAndNumber("BC", "5");
Car c6 = cmanager.getByRoadAndNumber("BD", "6");
Car c7 = cmanager.getByRoadAndNumber("BA", "7");
Car c8 = cmanager.getByRoadAndNumber("BB", "8");
Car c9 = cmanager.getByRoadAndNumber("BC", "9");
Assert.assertNotNull("confirm car not null", c3);
Assert.assertNotNull("confirm car not null", c4);
Assert.assertNotNull("confirm car not null", c5);
Assert.assertNotNull("confirm car not null", c6);
Assert.assertNotNull("confirm car not null", c7);
Assert.assertNotNull("confirm car not null", c8);
Assert.assertNotNull("confirm car not null", c9);
Location Acton = lmanager.getLocationByName("Acton MA");
Location Bedford = lmanager.getLocationByName("Bedford MA");
Location Clinton = lmanager.getLocationByName("Clinton MA");
Location Danbury = lmanager.getLocationByName("Danbury MA");
Location Essex = lmanager.getLocationByName("Essex MA");
Location Foxboro = lmanager.getLocationByName("Foxboro MA");
Track AS1 = Acton.getTrackByName("Acton Siding 1", Track.SPUR);
Track BS1 = Bedford.getTrackByName("Bedford Siding 1", Track.SPUR);
Track CS1 = Clinton.getTrackByName("Clinton Siding 1", Track.SPUR);
Track DS1 = Danbury.getTrackByName("Danbury Siding 1", Track.SPUR);
Track DS2 = Danbury.getTrackByName("Danbury Siding 2", Track.SPUR);
Track ES1 = Essex.getTrackByName("Essex Siding 1", Track.SPUR);
//Track ES2 = Essex.getTrackByName("Essex Siding 2", Track.SIDING);
Track FS1 = Foxboro.getTrackByName("Foxboro Siding 1", Track.SPUR);
// set the depart track Acton to service by local train only
AS1.setTrainDirections(0);
// create schedules
ScheduleManager scheduleManager = ScheduleManager.instance();
Schedule schA = scheduleManager.newSchedule("Schedule ABC");
ScheduleItem schAItem1 = schA.addItem("Boxcar");
schAItem1.setReceiveLoadName("Cardboard");
schAItem1.setShipLoadName("Metal");
schAItem1.setDestination(Acton);
schAItem1.setDestinationTrack(AS1);
ScheduleItem schAItem2 = schA.addItem("Flat");
//schAItem2.setLoad("Junk");
schAItem2.setShipLoadName("Metal");
schAItem2.setDestination(Danbury);
schAItem2.setDestinationTrack(DS2);
ScheduleItem schAItem3 = schA.addItem("Boxcar");
schAItem3.setReceiveLoadName("Tools");
schAItem3.setShipLoadName("Screws");
schAItem3.setDestination(Bedford);
schAItem3.setDestinationTrack(BS1);
ScheduleItem schAItem4 = schA.addItem("Boxcar");
schAItem4.setReceiveLoadName(CarLoads.instance().getDefaultEmptyName());
schAItem4.setShipLoadName("Bolts");
schAItem4.setDestination(Danbury);
schAItem4.setDestinationTrack(DS1);
ScheduleItem schAItem5 = schA.addItem("Boxcar");
schAItem5.setReceiveLoadName(CarLoads.instance().getDefaultLoadName());
schAItem5.setShipLoadName("Nuts");
schAItem5.setDestination(Foxboro);
schAItem5.setDestinationTrack(FS1);
// Add schedule to tracks
CS1.setScheduleId("");
ES1.setScheduleId(schA.getId());
// set schedule into match mode
ES1.setScheduleMode(Track.MATCH);
// c3 (BA 3) is a Boxcar
c3.setLoadName("Tools");
c3.setFinalDestination(Essex);
// c4 (BB 4) is a Flat
c4.setLoadName(CarLoads.instance().getDefaultEmptyName());
c4.setFinalDestination(Essex);
c4.setFinalDestinationTrack(ES1);
// c5 (BC 5) is a Boxcar
c5.setLoadName("Tools");
c5.setFinalDestination(Essex);
// c6 (BD 6) is a Boxcar
c6.setLoadName(CarLoads.instance().getDefaultEmptyName());
c6.setFinalDestination(Essex);
// c7 (BA 7) is a Boxcar
c7.setLoadName("Cardboard");
c7.setFinalDestination(Essex);
c7.setFinalDestinationTrack(ES1);
// c8 (BB 8) is a Boxcar
c8.setLoadName("Tools");
// serve BB 8 and BC 9 after the other cars
c8.setMoves(20);
// c9 (BC 9) is a Boxcar
c9.setLoadName(CarLoads.instance().getDefaultEmptyName());
c9.setMoves(21);
// place cars
Assert.assertEquals("Place car", Track.OKAY, c3.setLocation(Acton, AS1));
Assert.assertEquals("Place car", Track.OKAY, c4.setLocation(Acton, AS1));
Assert.assertEquals("Place car", Track.OKAY, c5.setLocation(Acton, AS1));
Assert.assertEquals("Place car", Track.OKAY, c6.setLocation(Acton, AS1));
Assert.assertEquals("Place car", Track.OKAY, c7.setLocation(Acton, AS1));
Assert.assertEquals("Place car", Track.OKAY, c8.setLocation(Danbury, DS1));
Assert.assertEquals("Place car", Track.OKAY, c9.setLocation(Danbury, DS1));
// build train
Train ActonTrain = tmanager.getTrainByName("Acton Local");
ActonTrain.build();
Assert.assertTrue("Acton train built", ActonTrain.isBuilt());
// check car destinations
Assert.assertEquals("Car BA 3 destination", "Acton MA", c3.getDestinationName());
Assert.assertEquals("Car BA 3 destination track", "Acton Interchange", c3.getDestinationTrackName());
Assert.assertEquals("Car BA 3 final destination", "Essex MA", c3.getFinalDestinationName());
Assert.assertEquals("Car BA 3 final destination track", "", c3.getFinalDestinationTrackName());
Assert.assertEquals("Car BB 4 destination", "Acton MA", c4.getDestinationName());
Assert.assertEquals("Car BB 4 destination track", "Acton Interchange", c4.getDestinationTrackName());
Assert.assertEquals("Car BB 4 final destination", "Essex MA", c4.getFinalDestinationName());
Assert.assertEquals("Car BB 4 final destination track", "Essex Siding 1", c4.getFinalDestinationTrackName());
Assert.assertEquals("Car BC 5 destination", "Acton MA", c5.getDestinationName());
Assert.assertEquals("Car BC 5 destination track", "Acton Interchange", c5.getDestinationTrackName());
Assert.assertEquals("Car BC 5 final destination", "Essex MA", c5.getFinalDestinationName());
Assert.assertEquals("Car BC 5 final destination track", "", c5.getFinalDestinationTrackName());
Assert.assertEquals("Car BD 6 destination", "Acton MA", c6.getDestinationName());
Assert.assertEquals("Car BD 6 destination track", "Acton Interchange", c6.getDestinationTrackName());
Assert.assertEquals("Car BD 6 final destination", "Essex MA", c6.getFinalDestinationName());
Assert.assertEquals("Car BD 6 final destination track", "", c6.getFinalDestinationTrackName());
Assert.assertEquals("Car BA 7 destination", "Acton MA", c7.getDestinationName());
Assert.assertEquals("Car BA 7 destination track", "Acton Interchange", c7.getDestinationTrackName());
Assert.assertEquals("Car BA 7 final destination", "Essex MA", c7.getFinalDestinationName());
Assert.assertEquals("Car BA 7 final destination track", "Essex Siding 1", c7.getFinalDestinationTrackName());
Assert.assertEquals("Car BB 8 destination", "", c8.getDestinationName());
Assert.assertEquals("Car BB 8 destination track", "", c8.getDestinationTrackName());
Assert.assertEquals("Car BB 8 final destination", "", c8.getFinalDestinationName());
Assert.assertEquals("Car BB 8 final destination track", "", c8.getFinalDestinationTrackName());
Assert.assertEquals("Car BC 9 destination", "", c9.getDestinationName());
Assert.assertEquals("Car BC 9 destination track", "", c9.getDestinationTrackName());
Assert.assertEquals("Car BC 9 final destination", "", c9.getFinalDestinationName());
Assert.assertEquals("Car BC 9 final destination track", "", c9.getFinalDestinationTrackName());
// check car schedule ids
// no track assignment, schedule not tested
Assert.assertEquals("Car BA 3 schedule id", "", c3.getScheduleItemId());
// has track assignment
Assert.assertEquals("Car BB 4 schedule id", schAItem2.getId(), c4.getScheduleItemId());
Assert.assertEquals("Car BC 5 schedule id", "", c5.getScheduleItemId());
Assert.assertEquals("Car BD 6 schedule id", "", c6.getScheduleItemId());
// has track assignment
Assert.assertEquals("Car BA 7 schedule id", schAItem1.getId(), c7.getScheduleItemId());
Assert.assertEquals("Car BB 8 schedule id", "", c8.getScheduleItemId());
Assert.assertEquals("Car BC 9 schedule id", "", c9.getScheduleItemId());
ActonTrain.terminate();
// move the cars to Bedford
Train ActonToBedfordTrain = tmanager.getTrainByName("Acton to Bedford");
ActonToBedfordTrain.build();
Assert.assertTrue("Acton train built", ActonToBedfordTrain.isBuilt());
ActonToBedfordTrain.terminate();
// move the cars to Clinton
Train BedfordToClintonTrain = tmanager.getTrainByName("Bedford to Clinton");
BedfordToClintonTrain.build();
Assert.assertTrue("Bedford train built", BedfordToClintonTrain.isBuilt());
BedfordToClintonTrain.terminate();
// move the cars to Danbury
Train ClintonToDanburyTrain = tmanager.getTrainByName("Clinton to Danbury");
ClintonToDanburyTrain.build();
Assert.assertTrue("Clinton train built", ClintonToDanburyTrain.isBuilt());
ClintonToDanburyTrain.terminate();
// move the cars to Essex (number of moves is 8)
Train DanburyToEssexTrain = tmanager.getTrainByName("Danbury to Essex");
DanburyToEssexTrain.build();
Assert.assertTrue("Danbury train built", DanburyToEssexTrain.isBuilt());
// check car destinations
// BA 3 (Boxcar)
Assert.assertEquals("Car BA 3 destination", "Essex MA", c3.getDestinationName());
Assert.assertEquals("Car BA 3 destination track", "Essex Siding 1", c3.getDestinationTrackName());
// new final destination and load for car BA 3
Assert.assertEquals("Car BA 3 final destination", "Bedford MA", c3.getFinalDestinationName());
Assert.assertEquals("Car BA 3 final destination track", "Bedford Siding 1", c3.getFinalDestinationTrackName());
Assert.assertEquals("Car BA 3 final load", "Screws", c3.getNextLoadName());
Assert.assertEquals("Car BA 3 schedule id", "", c3.getScheduleItemId());
// BB 4 (Flat)
Assert.assertEquals("Car BB 4 destination", "Essex MA", c4.getDestinationName());
Assert.assertEquals("Car BB 4 destination track", "Essex Siding 1", c4.getDestinationTrackName());
// new final destination and load for car BB 4
Assert.assertEquals("Car BB 4 final destination", "Danbury MA", c4.getFinalDestinationName());
Assert.assertEquals("Car BB 4 final destination track", "Danbury Siding 2", c4.getFinalDestinationTrackName());
Assert.assertEquals("Car BB 4 final load", "Metal", c4.getNextLoadName());
Assert.assertEquals("Car BB 4 schedule id", "", c4.getScheduleItemId());
// BC 5 (Boxcar)
Assert.assertEquals("Car BC 5 destination", "Essex MA", c5.getDestinationName());
Assert.assertEquals("Car BC 5 destination track", "Essex Siding 1", c5.getDestinationTrackName());
// new final destination and load for car BC 5, same as BA 3
Assert.assertEquals("Car BC 5 final destination", "Bedford MA", c5.getFinalDestinationName());
Assert.assertEquals("Car BC 5 final destination track", "Bedford Siding 1", c5.getFinalDestinationTrackName());
Assert.assertEquals("Car BC 5 final load", "Screws", c5.getNextLoadName());
Assert.assertEquals("Car BC 5 schedule id", "", c5.getScheduleItemId());
// BD 6 (Boxcar) note second Boxcar
Assert.assertEquals("Car BD 6 destination", "Essex MA", c6.getDestinationName());
Assert.assertEquals("Car BD 6 destination track", "Essex Siding 1", c6.getDestinationTrackName());
// new final destination and load for car BD 6
Assert.assertEquals("Car BD 6 final destination", "Danbury MA", c6.getFinalDestinationName());
Assert.assertEquals("Car BD 6 final destination track", "Danbury Siding 1", c6.getFinalDestinationTrackName());
Assert.assertEquals("Car BC 6 final load", "Bolts", c6.getNextLoadName());
Assert.assertEquals("Car BD 6 schedule id", "", c6.getScheduleItemId());
// BA 7 (Boxcar) note 3rd Boxcar
Assert.assertEquals("Car BA 7 destination", "Essex MA", c7.getDestinationName());
Assert.assertEquals("Car BA 7 destination track", "Essex Siding 1", c7.getDestinationTrackName());
// new final destination and load for car BA 7
Assert.assertEquals("Car BA 7 final destination", "Acton MA", c7.getFinalDestinationName());
Assert.assertEquals("Car BA 7 final destination track", "Acton Siding 1", c7.getFinalDestinationTrackName());
Assert.assertEquals("Car BA 7 final load", "Metal", c7.getNextLoadName());
Assert.assertEquals("Car BA 7 schedule id", "", c7.getScheduleItemId());
// BB 8 (Boxcar) at Danbury to be added to train
Assert.assertEquals("Car BB 8 destination", "Essex MA", c8.getDestinationName());
Assert.assertEquals("Car BB 8 destination track", "Essex Siding 1", c8.getDestinationTrackName());
// Should match schedule item 16c3
Assert.assertEquals("Car BB 8 final destination", "Bedford MA", c8.getFinalDestinationName());
Assert.assertEquals("Car BB 8 final destination track", "Bedford Siding 1", c8.getFinalDestinationTrackName());
Assert.assertEquals("Car BB 8 final load", "Screws", c8.getNextLoadName());
Assert.assertEquals("Car BB 8 schedule id", "", c8.getScheduleItemId());
// BB 9 (Boxcar) at Danbury to be added to train
Assert.assertEquals("Car BC 9 destination", "Essex MA", c9.getDestinationName());
Assert.assertEquals("Car BC 9 destination track", "Essex Siding 1", c9.getDestinationTrackName());
// Should match schedule item 16c4
Assert.assertEquals("Car BC 9 final destination", "Danbury MA", c9.getFinalDestinationName());
Assert.assertEquals("Car BC 9 final destination track", "Danbury Siding 1", c9.getFinalDestinationTrackName());
Assert.assertEquals("Car BC 9 final load", "Bolts", c9.getNextLoadName());
Assert.assertEquals("Car BC 9 schedule id", "", c9.getScheduleItemId());
// test reset, car final destinations should revert.
DanburyToEssexTrain.reset();
Assert.assertEquals("Car BA 3 destination", "", c3.getDestinationName());
Assert.assertEquals("Car BA 3 destination track", "", c3.getDestinationTrackName());
Assert.assertEquals("Car BA 3 final destination", "Essex MA", c3.getFinalDestinationName());
Assert.assertEquals("Car BA 3 final destination track", "", c3.getFinalDestinationTrackName());
Assert.assertEquals("Car BA 3 next load", "", c3.getNextLoadName());
Assert.assertEquals("Car BB 4 destination", "", c4.getDestinationName());
Assert.assertEquals("Car BB 4 destination track", "", c4.getDestinationTrackName());
Assert.assertEquals("Car BB 4 final destination", "Essex MA", c4.getFinalDestinationName());
Assert.assertEquals("Car BB 4 final destination track", "Essex Siding 1", c4.getFinalDestinationTrackName());
Assert.assertEquals("Car BC 5 destination", "", c5.getDestinationName());
Assert.assertEquals("Car BC 5 destination track", "", c5.getDestinationTrackName());
Assert.assertEquals("Car BC 5 final destination", "Essex MA", c5.getFinalDestinationName());
Assert.assertEquals("Car BC 5 final destination track", "", c5.getFinalDestinationTrackName());
Assert.assertEquals("Car BD 6 destination", "", c6.getDestinationName());
Assert.assertEquals("Car BD 6 destination track", "", c6.getDestinationTrackName());
Assert.assertEquals("Car BD 6 final destination", "Essex MA", c6.getFinalDestinationName());
Assert.assertEquals("Car BD 6 final destination track", "", c6.getFinalDestinationTrackName());
Assert.assertEquals("Car BA 7 destination", "", c7.getDestinationName());
Assert.assertEquals("Car BA 7 destination track", "", c7.getDestinationTrackName());
Assert.assertEquals("Car BA 7 final destination", "Essex MA", c7.getFinalDestinationName());
Assert.assertEquals("Car BA 7 final destination track", "Essex Siding 1", c7.getFinalDestinationTrackName());
Assert.assertEquals("Car BB 8 destination", "", c8.getDestinationName());
Assert.assertEquals("Car BB 8 destination track", "", c8.getDestinationTrackName());
Assert.assertEquals("Car BB 8 final destination", "", c8.getFinalDestinationName());
Assert.assertEquals("Car BB 8 final destination track", "", c8.getFinalDestinationTrackName());
Assert.assertEquals("Car BC 9 destination", "", c9.getDestinationName());
Assert.assertEquals("Car BC 9 destination track", "", c9.getDestinationTrackName());
Assert.assertEquals("Car BC 9 final destination", "", c9.getFinalDestinationName());
Assert.assertEquals("Car BC 9 final destination track", "", c9.getFinalDestinationTrackName());
// // try again
// DanburyToEssexTrain.build();
// Assert.assertTrue("Bedford train built", DanburyToEssexTrain.isBuilt());
//
// // check car destinations
// // BA 3 (Boxcar) this car's load and final destination is now different
// Assert.assertEquals("Car BA 3 destination","Essex MA", c3.getDestinationName());
// Assert.assertEquals("Car BA 3 destination track","Essex Siding 1", c3.getDestinationTrackName());
// // new final destination and load for car BA 3
// Assert.assertEquals("Car BA 3 final destination","Acton MA", c3.getFinalDestinationName());
// Assert.assertEquals("Car BA 3 final destination track","Acton Siding 1", c3.getFinalDestinationTrackName());
// Assert.assertEquals("Car BA 3 next load","Metal", c3.getNextLoadName());
// Assert.assertEquals("Car BA 3 schedule id", "", c3.getScheduleId());
// // BB 4 (Flat) resets the match pointer so car BC 5 final destination and load is the same as last time
// Assert.assertEquals("Car BB 4 destination","Essex MA", c4.getDestinationName());
// Assert.assertEquals("Car BB 4 destination track","Essex Siding 1", c4.getDestinationTrackName());
// // new final destination and load for car BB 4
// Assert.assertEquals("Car BB 4 final destination","Danbury MA", c4.getFinalDestinationName());
// Assert.assertEquals("Car BB 4 final destination track","Danbury Siding 2", c4.getFinalDestinationTrackName());
// Assert.assertEquals("Car BB 4 next load","Metal", c4.getNextLoadName());
// Assert.assertEquals("Car BB 4 schedule id", "", c4.getScheduleId());
// // BC 5 (Boxcar)
// Assert.assertEquals("Car BC 5 destination","Essex MA", c5.getDestinationName());
// Assert.assertEquals("Car BC 5 destination track","Essex Siding 1", c5.getDestinationTrackName());
// // new final destination and load for car BC 5, same as BA 3
// Assert.assertEquals("Car BC 5 final destination","Bedford MA", c5.getFinalDestinationName());
// Assert.assertEquals("Car BC 5 final destination track","Bedford Siding 1", c5.getFinalDestinationTrackName());
// Assert.assertEquals("Car BC 5 next load","Screws", c5.getNextLoadName());
// Assert.assertEquals("Car BC 5 schedule id", "", c5.getScheduleId());
// // BD 6 (Boxcar) note second Boxcar
// Assert.assertEquals("Car BD 6 destination","Essex MA", c6.getDestinationName());
// Assert.assertEquals("Car BD 6 destination track","Essex Siding 1", c6.getDestinationTrackName());
// // new final destination and load for car BD 6
// Assert.assertEquals("Car BD 6 final destination","Danbury MA", c6.getFinalDestinationName());
// Assert.assertEquals("Car BD 6 final destination track","Danbury Siding 1", c6.getFinalDestinationTrackName());
// Assert.assertEquals("Car BC 6 next load", "Bolts", c6.getNextLoadName());
// Assert.assertEquals("Car BD 6 schedule id", "", c6.getScheduleId());
// // BA 7 (Boxcar) note 3rd Boxcar
// Assert.assertEquals("Car BA 7 destination","Essex MA", c7.getDestinationName());
// Assert.assertEquals("Car BA 7 destination track","Essex Siding 1", c7.getDestinationTrackName());
// // new final destination and load for car BA 7
// Assert.assertEquals("Car BA 7 final destination","Acton MA", c7.getFinalDestinationName());
// Assert.assertEquals("Car BA 7 final destination track","Acton Siding 1", c7.getFinalDestinationTrackName());
// Assert.assertEquals("Car BA 7 next load", "Metal", c7.getNextLoadName());
// Assert.assertEquals("Car BA 7 schedule id", "", c7.getScheduleId());
// // BB 8 (Boxcar) at Danbury to be added to train
// Assert.assertEquals("Car BB 8 destination","Essex MA", c8.getDestinationName());
// Assert.assertEquals("Car BB 8 destination track","Essex Siding 1", c8.getDestinationTrackName());
// // Should match schedule item 16c3
// Assert.assertEquals("Car BB 8 final destination","Bedford MA", c8.getFinalDestinationName());
// Assert.assertEquals("Car BB 8 final destination track","Bedford Siding 1", c8.getFinalDestinationTrackName());
// Assert.assertEquals("Car BB 8 next load", "Screws", c8.getNextLoadName());
// Assert.assertEquals("Car BB 8 schedule id", "", c8.getScheduleId());
// // BB 9 (Boxcar) at Danbury to be added to train
// Assert.assertEquals("Car BC 9 destination","Essex MA", c9.getDestinationName());
// Assert.assertEquals("Car BC 9 destination track","Essex Siding 1", c9.getDestinationTrackName());
// // Should match schedule item 16c4
// Assert.assertEquals("Car BC 9 final destination","Danbury MA", c9.getFinalDestinationName());
// Assert.assertEquals("Car BC 9 final destination track","Danbury Siding 1", c9.getFinalDestinationTrackName());
// Assert.assertEquals("Car BC 9 next load", "Bolts", c9.getNextLoadName());
// Assert.assertEquals("Car BC 9 schedule id", "", c9.getScheduleId());
//
// DanburyToEssexTrain.terminate();
//
// // check car destinations
// // BA 3 (Boxcar)
// Assert.assertEquals("Car BA 3 destination","", c3.getDestinationName());
// Assert.assertEquals("Car BA 3 destination track","", c3.getDestinationTrackName());
// // new final destination and load for car BA 3
// Assert.assertEquals("Car BA 3 final destination","Acton MA", c3.getFinalDestinationName());
// Assert.assertEquals("Car BA 3 final destination track","Acton Siding 1", c3.getFinalDestinationTrackName());
// Assert.assertEquals("Car BA 3 load","Metal", c3.getLoadName());
// Assert.assertEquals("Car BA 3 next load","", c3.getNextLoadName());
// Assert.assertEquals("Car BA 3 schedule id", "", c3.getScheduleId());
// // BB 4 (Flat)
// Assert.assertEquals("Car BB 4 destination","", c4.getDestinationName());
// Assert.assertEquals("Car BB 4 destination track","", c4.getDestinationTrackName());
// // new final destination and load for car BB 4
// Assert.assertEquals("Car BB 4 final destination","Danbury MA", c4.getFinalDestinationName());
// Assert.assertEquals("Car BB 4 final destination track","Danbury Siding 2", c4.getFinalDestinationTrackName());
// Assert.assertEquals("Car BB 4 load","Metal", c4.getLoadName());
// Assert.assertEquals("Car BB 4 next load","", c4.getNextLoadName());
// Assert.assertEquals("Car BB 4 schedule id", "", c4.getScheduleId());
// // BC 5 (Boxcar)
// Assert.assertEquals("Car BC 5 destination","", c5.getDestinationName());
// Assert.assertEquals("Car BC 5 destination track","", c5.getDestinationTrackName());
// // new final destination and load for car BC 5, same as BA 3
// Assert.assertEquals("Car BC 5 final destination","Bedford MA", c5.getFinalDestinationName());
// Assert.assertEquals("Car BC 5 final destination track","Bedford Siding 1", c5.getFinalDestinationTrackName());
// Assert.assertEquals("Car BC 5 load","Screws", c5.getLoadName());
// Assert.assertEquals("Car BC 5 next load","", c5.getNextLoadName());
// Assert.assertEquals("Car BC 5 schedule id", "", c5.getScheduleId());
// // BD 6 (Boxcar) note second Boxcar
// Assert.assertEquals("Car BD 6 destination","", c6.getDestinationName());
// Assert.assertEquals("Car BD 6 destination track","", c6.getDestinationTrackName());
// // new final destination and load for car BD 6
// Assert.assertEquals("Car BD 6 final destination","Danbury MA", c6.getFinalDestinationName());
// Assert.assertEquals("Car BD 6 final destination track","Danbury Siding 1", c6.getFinalDestinationTrackName());
// Assert.assertEquals("Car BC 6 load", "Bolts", c6.getLoadName());
// Assert.assertEquals("Car BC 6 next load", "", c6.getNextLoadName());
// Assert.assertEquals("Car BD 6 schedule id", "", c6.getScheduleId());
// // BA 7 (Boxcar) note 3rd Boxcar
// Assert.assertEquals("Car BA 7 destination","", c7.getDestinationName());
// Assert.assertEquals("Car BA 7 destination track","", c7.getDestinationTrackName());
// // new final destination and load for car BA 7
// Assert.assertEquals("Car BA 7 final destination","Acton MA", c7.getFinalDestinationName());
// Assert.assertEquals("Car BA 7 final destination track","Acton Siding 1", c7.getFinalDestinationTrackName());
// Assert.assertEquals("Car BA 7 load", "Metal", c7.getLoadName());
// Assert.assertEquals("Car BA 7 next load", "", c7.getNextLoadName());
// Assert.assertEquals("Car BA 7 schedule id", "", c7.getScheduleId());
// // BB 8 (Boxcar)
// Assert.assertEquals("Car BB 8 destination","", c8.getDestinationName());
// Assert.assertEquals("Car BB 8 destination track","", c8.getDestinationTrackName());
// // Should match schedule item 16c3
// Assert.assertEquals("Car BB 8 final destination","Bedford MA", c8.getFinalDestinationName());
// Assert.assertEquals("Car BB 8 final destination track","Bedford Siding 1", c8.getFinalDestinationTrackName());
// Assert.assertEquals("Car BB 8 load", "Screws", c8.getLoadName());
// Assert.assertEquals("Car BB 8 next load", "", c8.getNextLoadName());
// Assert.assertEquals("Car BB 8 schedule id", "", c8.getScheduleId());
// // BB 9 (Boxcar)
// Assert.assertEquals("Car BC 9 destination","", c9.getDestinationName());
// Assert.assertEquals("Car BC 9 destination track","", c9.getDestinationTrackName());
// // Should match schedule item 16c4
// Assert.assertEquals("Car BC 9 final destination","Danbury MA", c9.getFinalDestinationName());
// Assert.assertEquals("Car BC 9 final destination track","Danbury Siding 1", c9.getFinalDestinationTrackName());
// Assert.assertEquals("Car BC 9 load", "Bolts", c9.getLoadName());
// Assert.assertEquals("Car BC 9 next load", "", c9.getNextLoadName());
// Assert.assertEquals("Car BC 9 schedule id", "", c9.getScheduleId());
}
Aggregations