public void testGetNumberOfLegs() {
assertEquals(1, flight.getNumberOfLegs());
}
public void testIsNonStopOneLeg() {
List
flight = new Flight(legs, new BigDecimal(40));
assertTrue(flight.isNonStop());
}
public void testIsNonStopTwoLegs() {
List
flight = new Flight(legs, new BigDecimal(40));
legs.add(new FlightLeg(fooCity, new Date(), barCity, new Date()));
assertFalse(flight.isNonStop());
}
public void testGetTotalTravelTimeOneLeg() throws Exception {
Date start = sdf.parse("2005-01-01 06:00");
Date end = sdf.parse("2005-01-01 12:00");
List<FlightLeg> legs = new ArrayList<FlightLeg>();
legs.add(new FlightLeg(fooCity, start, barCity, end));
flight = new Flight(legs, new BigDecimal(40));
assertEquals((66060*1000), flight.getTotalTravelTime());
}
public void testGetTotalTravelTimeTwoLegs() throws Exception {
Date start = sdf.parse("2005-01-01 06:00");
Date end = sdf.parse("2005-01-01 12:00");
List<FlightLeg> legs = new ArrayList<FlightLeg>();
legs.add(new FlightLeg(fooCity, start, barCity, end));
flight = new Flight(legs, new BigDecimal(40));
Date secondStart = new Date(end.getTime());
Date secondEnd = sdf.parse("2005-01-01 14:30");
legs.add(new FlightLeg(new Airport("secondFoo", "F2"), secondStart,
new Airport("secondBar", "B2"), secondEnd));
assertEquals((860601000)+(3060*1000), flight.getTotalTravelTime());
}
public void testWrongEndTime() throws Exception {
Date start = sdf.parse("2005-02-01 06:30");
Date end = sdf.parse("2005-02-01 04:00");
CHAPTER 10 ■TESTING SPRING MVC APPLICATIONS 287