use of jmri.jmrit.operations.locations.Location in project JMRI by JMRI.
the class AutomationItemTest method testRouteLocation.
public void testRouteLocation() {
AutomationItem automationItem = new AutomationItem("TestId");
Assert.assertNotNull("test creation", automationItem);
Assert.assertEquals("test id", "TestId", automationItem.getId());
RouteLocation rl = new RouteLocation("testId", new Location("testId", "testLocationName"));
automationItem.setRouteLocation(rl);
Assert.assertEquals("Do nothing action can't have a routeLocation", null, automationItem.getRouteLocation());
automationItem.setAction(new WaitTrainAction());
Assert.assertEquals(rl, automationItem.getRouteLocation());
}
use of jmri.jmrit.operations.locations.Location in project JMRI by JMRI.
the class OperationsRoutesTest method testRouteLocationAttributes.
// test RouteLocation attributes
public void testRouteLocationAttributes() {
Route r1 = new Route("TESTROUTEID", "TESTROUTENAME");
Assert.assertEquals("Route Id", "TESTROUTEID", r1.getId());
Assert.assertEquals("Route Name", "TESTROUTENAME", r1.getName());
Location l1 = new Location("TESTLOCATIONID1", "TESTLOCATIONNAME1");
RouteLocation rl1 = new RouteLocation("TESTROUTELOCATIONID", l1);
rl1.setSequenceId(4);
rl1.setComment("TESTROUTELOCATIONCOMMENT");
rl1.setMaxTrainLength(320);
rl1.setTrainLength(220);
rl1.setTrainWeight(240);
rl1.setMaxCarMoves(32);
rl1.setCarMoves(10);
rl1.setGrade(2.0);
rl1.setTrainIconX(12);
rl1.setTrainIconY(8);
Assert.assertEquals("RouteLocation Id", "TESTROUTELOCATIONID", rl1.getId());
Assert.assertEquals("RouteLocation Name", "TESTLOCATIONNAME1", rl1.getName());
Assert.assertEquals("RouteLocation toString", "TESTLOCATIONNAME1", rl1.toString());
Assert.assertEquals("RouteLocation Comment", "TESTROUTELOCATIONCOMMENT", rl1.getComment());
Assert.assertEquals("RouteLocation Sequence", 4, rl1.getSequenceId());
Assert.assertEquals("RouteLocation Max Train Length", 320, rl1.getMaxTrainLength());
Assert.assertEquals("RouteLocation Train Length", 220, rl1.getTrainLength());
Assert.assertEquals("RouteLocation Train Weight", 240, rl1.getTrainWeight());
Assert.assertEquals("RouteLocation Max Car Moves", 32, rl1.getMaxCarMoves());
Assert.assertEquals("RouteLocation Car Moves", 10, rl1.getCarMoves());
Assert.assertEquals("RouteLocation Grade", "2.0", Double.toString(rl1.getGrade()));
Assert.assertEquals("RouteLocation Icon X", 12, rl1.getTrainIconX());
Assert.assertEquals("RouteLocation Icon Y", 8, rl1.getTrainIconY());
rl1.setTrainDirection(RouteLocation.EAST);
Assert.assertEquals("RouteLocation Train Direction East", 1, rl1.getTrainDirection());
rl1.setTrainDirection(RouteLocation.WEST);
Assert.assertEquals("RouteLocation Train Direction West", 2, rl1.getTrainDirection());
rl1.setTrainDirection(RouteLocation.NORTH);
Assert.assertEquals("RouteLocation Train Direction North", 4, rl1.getTrainDirection());
rl1.setTrainDirection(RouteLocation.SOUTH);
Assert.assertEquals("RouteLocation Train Direction South", 8, rl1.getTrainDirection());
// rl1.setCanDrop(true);
Assert.assertEquals("RouteLocation Train can drop initial", true, rl1.isDropAllowed());
rl1.setDropAllowed(false);
Assert.assertEquals("RouteLocation Train can drop false", false, rl1.isDropAllowed());
rl1.setDropAllowed(true);
Assert.assertEquals("RouteLocation Train can drop true", true, rl1.isDropAllowed());
// rl1.setCanPickup(true);
Assert.assertEquals("RouteLocation Train can Pickup initial", true, rl1.isPickUpAllowed());
rl1.setPickUpAllowed(false);
Assert.assertEquals("RouteLocation Train can Pickup false", false, rl1.isPickUpAllowed());
rl1.setPickUpAllowed(true);
Assert.assertEquals("RouteLocation Train can Pickup true", true, rl1.isPickUpAllowed());
}
use of jmri.jmrit.operations.locations.Location in project JMRI by JMRI.
the class OperationsRoutesTest method testXMLCreate.
/**
* Test route Xml create, read, and backup support. Originally written as
* three separate tests, now combined into one as of 8/29/2013
*
* @throws JDOMException
* @throws IOException
*/
public void testXMLCreate() throws JDOMException, IOException {
RouteManager manager = RouteManager.instance();
List<Route> temprouteList = manager.getRoutesByIdList();
Assert.assertEquals("Starting Number of Routes", 0, temprouteList.size());
Route r1 = manager.newRoute("Test Number 1");
Route r2 = manager.newRoute("Test Number 2");
Route r3 = manager.newRoute("Test Number 3");
temprouteList = manager.getRoutesByIdList();
Assert.assertEquals("New Number of Routes", 3, temprouteList.size());
RouteManagerXml.instance().writeOperationsFile();
// Add some more routes and write file again
// so we can test the backup facility
Route r4 = manager.newRoute("Test Number 4");
Route r5 = manager.newRoute("Test Number 5");
Route r6 = manager.newRoute("Test Number 6");
Assert.assertNotNull("route r1 exists", r1);
Assert.assertNotNull("route r2 exists", r2);
Assert.assertNotNull("route r3 exists", r3);
Assert.assertNotNull("route r4 exists", r4);
Assert.assertNotNull("route r5 exists", r5);
Assert.assertNotNull("route r6 exists", r6);
LocationManager lmanager = LocationManager.instance();
Location Acton = lmanager.newLocation("Acton");
Location Bedford = lmanager.newLocation("Bedford");
Location Chelmsford = lmanager.newLocation("Chelmsford");
r1.setComment("r1 comment");
RouteLocation r1l1 = r1.addLocation(Acton);
r1.addLocation(Bedford);
r1.addLocation(Chelmsford);
r1.addLocation(Bedford);
r1.addLocation(Acton);
r1l1.setDropAllowed(false);
r1l1.setPickUpAllowed(false);
// this value isn't saved
r1l1.setCarMoves(3);
r1l1.setComment("rl1 comment");
r1l1.setGrade(Double.valueOf("5"));
r1l1.setMaxCarMoves(8);
r1l1.setMaxTrainLength(345);
r1l1.setTrainDirection(Location.SOUTH);
r1l1.setTrainIconX(56);
r1l1.setTrainIconY(78);
// this value isn't saved
r1l1.setTrainLength(234);
// this value isn't saved
r1l1.setTrainWeight(987);
r2.setComment("r2 comment");
r2.addLocation(Chelmsford);
RouteLocation r2l2 = r2.addLocation(Bedford);
r2.addLocation(Chelmsford);
RouteLocation r2l4 = r2.addLocation(Bedford);
r2l2.setDropAllowed(false);
r2l2.setPickUpAllowed(true);
// this value isn't saved
r2l2.setCarMoves(3);
r2l2.setComment("r2l2 comment");
r2l2.setGrade(Double.valueOf("1"));
r2l2.setMaxCarMoves(181);
r2l2.setMaxTrainLength(4561);
r2l2.setTrainDirection(Location.EAST);
r2l2.setTrainIconX(651);
r2l2.setTrainIconY(871);
// this value isn't saved
r2l2.setTrainLength(234);
// this value isn't saved
r2l2.setTrainWeight(987);
r2l4.setDropAllowed(true);
r2l4.setPickUpAllowed(false);
// this value isn't saved
r2l4.setCarMoves(3);
r2l4.setComment("r2l4 comment");
r2l4.setGrade(Double.valueOf("2"));
r2l4.setMaxCarMoves(18);
r2l4.setMaxTrainLength(456);
r2l4.setTrainDirection(Location.NORTH);
r2l4.setTrainIconX(65);
r2l4.setTrainIconY(87);
// this value isn't saved
r2l4.setTrainLength(234);
// this value isn't saved
r2l4.setTrainWeight(987);
r3.setComment("r3 comment");
r4.setComment("r4 comment");
r5.setComment("r5 comment");
r6.setComment("r6 comment");
RouteManagerXml.instance().writeOperationsFile();
// now perform read operation
manager.dispose();
manager = RouteManager.instance();
temprouteList = manager.getRoutesByIdList();
Assert.assertEquals("Starting Number of Routes", 0, temprouteList.size());
RouteManagerXml.instance().readFile(RouteManagerXml.instance().getDefaultOperationsFilename());
temprouteList = manager.getRoutesByIdList();
Assert.assertEquals("Number of Routes", 6, temprouteList.size());
r1 = manager.getRouteByName("Test Number 1");
r2 = manager.getRouteByName("Test Number 2");
r3 = manager.getRouteByName("Test Number 3");
r4 = manager.getRouteByName("Test Number 4");
r5 = manager.getRouteByName("Test Number 5");
r6 = manager.getRouteByName("Test Number 6");
Assert.assertNotNull("route r1 exists", r1);
Assert.assertNotNull("route r2 exists", r2);
Assert.assertNotNull("route r3 exists", r3);
Assert.assertNotNull("route r4 exists", r4);
Assert.assertNotNull("route r5 exists", r5);
Assert.assertNotNull("route r6 exists", r6);
Assert.assertEquals("r1 comment", "r1 comment", r1.getComment());
List<RouteLocation> locs = r1.getLocationsBySequenceList();
Assert.assertEquals("number of locations in route r1", 5, locs.size());
RouteLocation rl1 = locs.get(0);
Assert.assertEquals("rl1 can drop", false, rl1.isDropAllowed());
Assert.assertEquals("rl1 can pickup", false, rl1.isPickUpAllowed());
// default
Assert.assertEquals("rl1 car moves", 0, rl1.getCarMoves());
Assert.assertEquals("rl1 comment", "rl1 comment", rl1.getComment());
Assert.assertEquals("rl1 grade", "5.0", Double.toString(rl1.getGrade()));
Assert.assertEquals("rl1 max car moves", 8, rl1.getMaxCarMoves());
Assert.assertEquals("rl1 max train length", 345, rl1.getMaxTrainLength());
Assert.assertEquals("rl1 train direction", Location.SOUTH, rl1.getTrainDirection());
Assert.assertEquals("rl1 IconX", 56, rl1.getTrainIconX());
Assert.assertEquals("rl1 IconY", 78, rl1.getTrainIconY());
// default
Assert.assertEquals("rl1 train length", 0, rl1.getTrainLength());
// default
Assert.assertEquals("rl1 train weight", 0, rl1.getTrainWeight());
Assert.assertEquals("r2 comment", "r2 comment", r2.getComment());
locs = r2.getLocationsBySequenceList();
Assert.assertEquals("number of locations in route r2", 4, locs.size());
RouteLocation rl2 = locs.get(1);
Assert.assertEquals("rl2 can drop", false, rl2.isDropAllowed());
Assert.assertEquals("rl2 can pickup", true, rl2.isPickUpAllowed());
// default
Assert.assertEquals("rl2 car moves", 0, rl2.getCarMoves());
Assert.assertEquals("rl2 comment", "r2l2 comment", rl2.getComment());
Assert.assertEquals("rl2 grade", "1.0", Double.toString(rl2.getGrade()));
Assert.assertEquals("rl2 max car moves", 181, rl2.getMaxCarMoves());
Assert.assertEquals("rl2 max train length", 4561, rl2.getMaxTrainLength());
Assert.assertEquals("rl2 train direction", Location.EAST, rl2.getTrainDirection());
Assert.assertEquals("rl2 IconX", 651, rl2.getTrainIconX());
Assert.assertEquals("rl2 IconY", 871, rl2.getTrainIconY());
// default
Assert.assertEquals("rl2 train length", 0, rl2.getTrainLength());
// default
Assert.assertEquals("rl2 train weight", 0, rl2.getTrainWeight());
RouteLocation rl4 = locs.get(3);
Assert.assertEquals("rl4 can drop", true, rl4.isDropAllowed());
Assert.assertEquals("rl4 can pickup", false, rl4.isPickUpAllowed());
// default
Assert.assertEquals("rl4 car moves", 0, rl4.getCarMoves());
Assert.assertEquals("rl4 comment", "r2l4 comment", rl4.getComment());
Assert.assertEquals("rl4 grade", "2.0", Double.toString(rl4.getGrade()));
Assert.assertEquals("rl4 max car moves", 18, rl4.getMaxCarMoves());
Assert.assertEquals("rl4 max train length", 456, rl4.getMaxTrainLength());
Assert.assertEquals("rl4 train direction", Location.NORTH, rl4.getTrainDirection());
Assert.assertEquals("rl4 IconX", 65, rl4.getTrainIconX());
Assert.assertEquals("rl4 IconY", 87, rl4.getTrainIconY());
// default
Assert.assertEquals("rl4 train length", 0, rl4.getTrainLength());
// default
Assert.assertEquals("rl4 train weight", 0, rl4.getTrainWeight());
Assert.assertEquals("r3 comment", "r3 comment", r3.getComment());
Assert.assertEquals("r4 comment", "r4 comment", r4.getComment());
Assert.assertEquals("r5 comment", "r5 comment", r5.getComment());
Assert.assertEquals("r6 comment", "r6 comment", r6.getComment());
// now test backup file
manager.dispose();
// change default file name to backup
RouteManagerXml.instance().setOperationsFileName("OperationsJUnitTestRouteRoster.xml.bak");
manager = RouteManager.instance();
temprouteList = manager.getRoutesByIdList();
Assert.assertEquals("Starting Number of Routes", 0, temprouteList.size());
RouteManagerXml.instance().readFile(RouteManagerXml.instance().getDefaultOperationsFilename());
temprouteList = manager.getRoutesByIdList();
Assert.assertEquals("Number of Routes", 3, temprouteList.size());
r1 = manager.getRouteByName("Test Number 1");
r2 = manager.getRouteByName("Test Number 2");
r3 = manager.getRouteByName("Test Number 3");
r4 = manager.getRouteByName("Test Number 4");
r5 = manager.getRouteByName("Test Number 5");
r6 = manager.getRouteByName("Test Number 6");
Assert.assertNotNull("route r1 exists", r1);
Assert.assertNotNull("route r2 exists", r2);
Assert.assertNotNull("route r3 exists", r3);
Assert.assertNull("route r4 exists", r4);
Assert.assertNull("route r5 exists", r5);
Assert.assertNull("route r6 exists", r6);
}
use of jmri.jmrit.operations.locations.Location in project JMRI by JMRI.
the class CarsTableFrameTest method testCarsTableFrame.
@Test
public void testCarsTableFrame() throws Exception {
Assume.assumeFalse(GraphicsEnvironment.isHeadless());
// remove previous cars
CarManager.instance().dispose();
CarRoads.instance().dispose();
// add Owner1 and Owner2
CarOwners co = CarOwners.instance();
co.addName("Owner1");
co.addName("Owner2");
// add road names
CarRoads cr = CarRoads.instance();
cr.addName("NH");
cr.addName("UP");
cr.addName("AA");
cr.addName("SP");
// add locations
LocationManager lManager = LocationManager.instance();
Location westford = lManager.newLocation("Newer Westford");
Track westfordYard = westford.addTrack("Yard", Track.YARD);
westfordYard.setLength(300);
Track westfordSiding = westford.addTrack("Siding", Track.SPUR);
westfordSiding.setLength(300);
Track westfordAble = westford.addTrack("Able", Track.SPUR);
westfordAble.setLength(300);
Location boxford = lManager.newLocation("Newer Boxford");
Track boxfordYard = boxford.addTrack("Yard", Track.YARD);
boxfordYard.setLength(300);
Track boxfordJacobson = boxford.addTrack("Jacobson", Track.SPUR);
boxfordJacobson.setLength(300);
Track boxfordHood = boxford.addTrack("Hood", Track.SPUR);
boxfordHood.setLength(300);
// enable rfid field
Setup.setRfidEnabled(true);
CarsTableFrame ctf = new CarsTableFrame(true, null, null);
// show all cars?
Assert.assertTrue("show all cars", ctf.showAllCars);
// table should be empty
Assert.assertEquals("number of cars", "0", ctf.numCars.getText());
CarManager cManager = CarManager.instance();
// confirm no cars
Assert.assertEquals("number of cars", 0, cManager.getNumEntries());
// add 5 cars to table
loadCars();
Car c1 = cManager.getByRoadAndNumber("NH", "1");
Assert.assertNotNull(c1);
Assert.assertEquals("c1 location", Track.OKAY, c1.setLocation(westford, westfordYard));
Assert.assertEquals("c1 destination", Track.OKAY, c1.setDestination(boxford, boxfordJacobson));
Car c2 = cManager.getByRoadAndNumber("UP", "22");
Assert.assertNotNull(c2);
Car c3 = cManager.getByRoadAndNumber("AA", "3");
Assert.assertNotNull(c3);
Assert.assertEquals("c3 location", Track.OKAY, c3.setLocation(boxford, boxfordHood));
Assert.assertEquals("c3 destination", Track.OKAY, c3.setDestination(boxford, boxfordYard));
Car c4 = cManager.getByRoadAndNumber("SP", "2");
Assert.assertNotNull(c4);
Assert.assertEquals("c4 location", Track.OKAY, c4.setLocation(westford, westfordSiding));
Assert.assertEquals("c4 destination", Track.OKAY, c4.setDestination(boxford, boxfordHood));
Car c5 = cManager.getByRoadAndNumber("NH", "5");
Assert.assertEquals("c5 location", Track.OKAY, c5.setLocation(westford, westfordAble));
Assert.assertEquals("c5 destination", Track.OKAY, c5.setDestination(westford, westfordAble));
Assert.assertEquals("number of cars", "5", ctf.numCars.getText());
// default is sort by number
List<RollingStock> cars = ctf.carsTableModel.getSelectedCarList();
Assert.assertEquals("1st car in sort by number list", c1.getId(), cars.get(0).getId());
Assert.assertEquals("2nd car in sort by number list", c4.getId(), cars.get(1).getId());
Assert.assertEquals("3rd car in sort by number list", c3.getId(), cars.get(2).getId());
Assert.assertEquals("4th car in sort by number list", c5.getId(), cars.get(3).getId());
Assert.assertEquals("5th car in sort by number list", c2.getId(), cars.get(4).getId());
// now sort by built date
enterClickAndLeave(ctf.sortByBuilt);
cars = ctf.carsTableModel.getSelectedCarList();
Assert.assertEquals("1st car in sort by built list", c5, cars.get(0));
Assert.assertEquals("2nd car in sort by built list", c4, cars.get(1));
Assert.assertEquals("3rd car in sort by built list", c2, cars.get(2));
Assert.assertEquals("4th car in sort by built list", c3, cars.get(3));
Assert.assertEquals("5th car in sort by built list", c1, cars.get(4));
// now sort by color
enterClickAndLeave(ctf.sortByColor);
cars = ctf.carsTableModel.getSelectedCarList();
Assert.assertEquals("1st car in sort by color list", c4.getId(), cars.get(0).getId());
Assert.assertEquals("2nd car in sort by color list", c2.getId(), cars.get(1).getId());
Assert.assertEquals("3rd car in sort by color list", c5.getId(), cars.get(2).getId());
Assert.assertEquals("4th car in sort by color list", c1.getId(), cars.get(3).getId());
Assert.assertEquals("5th car in sort by color list", c3.getId(), cars.get(4).getId());
enterClickAndLeave(ctf.sortByDestination);
cars = ctf.carsTableModel.getSelectedCarList();
Assert.assertEquals("1st car in sort by destination list", c2, cars.get(0));
Assert.assertEquals("2nd car in sort by destination list", c4, cars.get(1));
Assert.assertEquals("3rd car in sort by destination list", c1, cars.get(2));
Assert.assertEquals("4th car in sort by destination list", c3, cars.get(3));
Assert.assertEquals("5th car in sort by destination list", c5, cars.get(4));
enterClickAndLeave(ctf.sortByKernel);
//TODO add kernels
// now sort by load
enterClickAndLeave(ctf.sortByLoad);
cars = ctf.carsTableModel.getSelectedCarList();
Assert.assertEquals("1st car in sort by load list", c2, cars.get(0));
Assert.assertEquals("2nd car in sort by load list", c4, cars.get(1));
Assert.assertEquals("3rd car in sort by load list", c1, cars.get(2));
Assert.assertEquals("4th car in sort by load list", c3, cars.get(3));
Assert.assertEquals("5th car in sort by load list", c5, cars.get(4));
// now sort by location
enterClickAndLeave(ctf.sortByLocation);
cars = ctf.carsTableModel.getSelectedCarList();
Assert.assertEquals("1st car in sort by location list", c2, cars.get(0));
Assert.assertEquals("2nd car in sort by location list", c3, cars.get(1));
Assert.assertEquals("3rd car in sort by location list", c5, cars.get(2));
Assert.assertEquals("4th car in sort by location list", c4, cars.get(3));
Assert.assertEquals("5th car in sort by location list", c1, cars.get(4));
// now sort by moves
enterClickAndLeave(ctf.sortByMoves);
cars = ctf.carsTableModel.getSelectedCarList();
Assert.assertEquals("1st car in sort by move list", c5, cars.get(0));
Assert.assertEquals("2nd car in sort by move list", c4, cars.get(1));
Assert.assertEquals("3rd car in sort by move list", c3, cars.get(2));
Assert.assertEquals("4th car in sort by move list", c2, cars.get(3));
Assert.assertEquals("5th car in sort by move list", c1, cars.get(4));
// test sort by number again
enterClickAndLeave(ctf.sortByNumber);
cars = ctf.carsTableModel.getSelectedCarList();
Assert.assertEquals("1st car in sort by number list 2", c1, cars.get(0));
Assert.assertEquals("2nd car in sort by number list 2", c4, cars.get(1));
Assert.assertEquals("3rd car in sort by number list 2", c3, cars.get(2));
Assert.assertEquals("4th car in sort by number list 2", c5, cars.get(3));
Assert.assertEquals("5th car in sort by number list 2", c2, cars.get(4));
// test sort by owner
//enterClickAndLeave(ctf.sortByOwner);
ctf.sortByOwner.doClick();
cars = ctf.carsTableModel.getSelectedCarList();
Assert.assertEquals("1st car in sort by owner list", c4, cars.get(0));
Assert.assertEquals("2nd car in sort by owner list", c3, cars.get(1));
Assert.assertEquals("3rd car in sort by owner list", c2, cars.get(2));
Assert.assertEquals("4th car in sort by owner list", c5, cars.get(3));
Assert.assertEquals("5th car in sort by owner list", c1, cars.get(4));
// test sort by rfid
//enterClickAndLeave(ctf.sortByRfid);
// use doClick() in case the radio button isn't visible due to scrollbars
ctf.sortByRfid.doClick();
cars = ctf.carsTableModel.getSelectedCarList();
Assert.assertEquals("1st car in sort by rfid list", c5, cars.get(0));
Assert.assertEquals("2nd car in sort by rfid list", c2, cars.get(1));
Assert.assertEquals("3rd car in sort by rfid list", c1, cars.get(2));
Assert.assertEquals("4th car in sort by rfid list", c4, cars.get(3));
Assert.assertEquals("5th car in sort by rfid list", c3, cars.get(4));
// test sort by road
enterClickAndLeave(ctf.sortByRoad);
cars = ctf.carsTableModel.getSelectedCarList();
Assert.assertEquals("1st car in sort by road list", c3, cars.get(0));
Assert.assertEquals("2nd car in sort by road list", c1, cars.get(1));
Assert.assertEquals("3rd car in sort by road list", c5, cars.get(2));
Assert.assertEquals("4th car in sort by road list", c4, cars.get(3));
Assert.assertEquals("5th car in sort by road list", c2, cars.get(4));
enterClickAndLeave(ctf.sortByTrain);
//TODO add trains
// test sort by type
enterClickAndLeave(ctf.sortByType);
cars = ctf.carsTableModel.getSelectedCarList();
Assert.assertEquals("1st car in sort by type list", c2, cars.get(0));
Assert.assertEquals("2nd car in sort by type list", c1, cars.get(1));
Assert.assertEquals("3rd car in sort by type list", c5, cars.get(2));
Assert.assertEquals("4th car in sort by type list", c3, cars.get(3));
Assert.assertEquals("5th car in sort by type list", c4, cars.get(4));
// test find text field
ctf.findCarTextBox.setText("*2");
enterClickAndLeave(ctf.findButton);
// table is sorted by type, cars with number 2 are in the first and last rows
Assert.assertEquals("find car by number 1st", 0, ctf.carsTable.getSelectedRow());
enterClickAndLeave(ctf.findButton);
Assert.assertEquals("find car by number 2nd", 4, ctf.carsTable.getSelectedRow());
// create the CarEditFrame
enterClickAndLeave(ctf.addButton);
ctf.dispose();
}
use of jmri.jmrit.operations.locations.Location in project JMRI by JMRI.
the class CarsTest method testSetLocation.
// test setting the location
public void testSetLocation() {
CarManager manager = CarManager.instance();
Car c1 = manager.newCar("CP", "1");
Car c2 = manager.newCar("ACL", "3");
Car c3 = manager.newCar("CP", "3");
Car c4 = manager.newCar("CP", "3-1");
Car c5 = manager.newCar("PC", "2");
Car c6 = manager.newCar("AA", "1");
//setup the cars
c1.setTypeName("Boxcar");
c2.setTypeName("Boxcar");
c3.setTypeName("Boxcar");
c4.setTypeName("Boxcar");
c5.setTypeName("Boxcar");
c6.setTypeName("Boxcar");
c1.setLength("13");
c2.setLength("9");
c3.setLength("12");
c4.setLength("10");
c5.setLength("11");
c6.setLength("14");
Location l1 = new Location("id1", "B");
Track l1t1 = l1.addTrack("A", Track.SPUR);
Track l1t2 = l1.addTrack("B", Track.SPUR);
Location l2 = new Location("id2", "C");
Track l2t1 = l2.addTrack("B", Track.SPUR);
Track l2t2 = l2.addTrack("A", Track.SPUR);
Location l3 = new Location("id3", "A");
Track l3t1 = l3.addTrack("B", Track.SPUR);
Track l3t2 = l3.addTrack("A", Track.SPUR);
// add track lengths
l1t1.setLength(100);
l1t2.setLength(100);
l2t1.setLength(100);
l2t2.setLength(100);
l3t1.setLength(100);
l3t2.setLength(100);
l1.addTypeName("Boxcar");
l2.addTypeName("Boxcar");
l3.addTypeName("Boxcar");
l1t1.addTypeName("Boxcar");
l1t2.addTypeName("Boxcar");
l2t1.addTypeName("Boxcar");
l2t2.addTypeName("Boxcar");
l3t1.addTypeName("Boxcar");
l3t2.addTypeName("Boxcar");
CarTypes ct = CarTypes.instance();
ct.addName("Boxcar");
// place cars on tracks
Assert.assertEquals("place c1", Track.OKAY, c1.setLocation(l1, l1t1));
Assert.assertEquals("place c2", Track.OKAY, c2.setLocation(l1, l1t2));
Assert.assertEquals("place c3", Track.OKAY, c3.setLocation(l2, l2t1));
Assert.assertEquals("place c4", Track.OKAY, c4.setLocation(l2, l2t2));
Assert.assertEquals("place c5", Track.OKAY, c5.setLocation(l3, l3t1));
Assert.assertEquals("place c6", Track.OKAY, c6.setLocation(l3, l3t2));
}
Aggregations