/** * @author Robert Dempsey, Student Number: N5400872 Tests that a locomotive at the end will be * successfully removed * @throws TrainException */ @Test public void testRemoveCarriageLastCarriageLoco() throws TrainException { final Integer GROSS_WEIGHT = 90; final String CLASSIFICATION = "4S"; final Locomotive LOCOMOTIVE = new Locomotive(GROSS_WEIGHT, CLASSIFICATION); DepartingTrain departingTrain = new DepartingTrain(); departingTrain.addCarriage(LOCOMOTIVE); departingTrain.removeCarriage(); assertNull(departingTrain.firstCarriage()); }
/** * @author Robert Dempsey, Student Number: N5400872 Tests that a freight car at the end will be * successfully removed * @throws TrainException */ @Test public void testRemoveCarriageLastCarriageFreight() throws TrainException { final Integer GROSS_WEIGHT = 90; final String CLASSIFICATION = "4S"; final String GOODS_TYPE = "G"; final Locomotive LOCOMOTIVE = new Locomotive(GROSS_WEIGHT, CLASSIFICATION); final FreightCar FREIGHTCAR = new FreightCar(GROSS_WEIGHT, GOODS_TYPE); DepartingTrain departingTrain = new DepartingTrain(); departingTrain.addCarriage(LOCOMOTIVE); departingTrain.addCarriage(FREIGHTCAR); departingTrain.removeCarriage(); assertEquals(LOCOMOTIVE, departingTrain.firstCarriage()); assertNull(departingTrain.nextCarriage()); }
/** * @author Robert Dempsey, Student Number: N5400872 Tests that an exception is thrown if a * carriage is attempted to be removed when there are passengers on the train * @throws TrainException */ @Test(expected = TrainException.class) public void testRemoveCarriagePassengersOnTrain() throws TrainException { final Integer SEATS = 20; final Integer PASSENGERS = 19; final Integer GROSS_WEIGHT = 90; final String CLASSIFICATION = "4S"; final Locomotive LOCOMOTIVE = new Locomotive(GROSS_WEIGHT, CLASSIFICATION); final PassengerCar PASSENGERCAR_01 = new PassengerCar(GROSS_WEIGHT, SEATS); DepartingTrain departingTrain = new DepartingTrain(); departingTrain.addCarriage(LOCOMOTIVE); departingTrain.addCarriage(PASSENGERCAR_01); departingTrain.board(PASSENGERS); departingTrain.removeCarriage(); }
/** * @author Robert Dempsey, Student Number: N5400872 Tests that a passenger car at the end will be * successfully removed * @throws TrainException */ @Test public void testRemoveCarriageLastCarriagePassenger() throws TrainException { final Integer SEATS = 20; final Integer GROSS_WEIGHT = 90; final String CLASSIFICATION = "4S"; final Locomotive LOCOMOTIVE = new Locomotive(GROSS_WEIGHT, CLASSIFICATION); final PassengerCar PASSENGERCAR_01 = new PassengerCar(GROSS_WEIGHT, SEATS); DepartingTrain departingTrain = new DepartingTrain(); departingTrain.addCarriage(LOCOMOTIVE); departingTrain.addCarriage(PASSENGERCAR_01); departingTrain.removeCarriage(); assertEquals(LOCOMOTIVE, departingTrain.firstCarriage()); assertNull(departingTrain.nextCarriage()); }
/** * @author Robert Dempsey, Student Number: N5400872 Tests that an exception is thrown if a * carriage is attempted to be removed when no carriages exist * @throws TrainException */ @Test(expected = TrainException.class) public void testRemoveCarriageNoRollingStockOnTrain() throws TrainException { DepartingTrain departingTrain = new DepartingTrain(); departingTrain.removeCarriage(); }