* It shows a doc wrapper style operation.
*/
List<Car> cars = dealer.getSedans("porsche");
assertEquals(2, cars.size());
Porsche car = (Porsche) cars.get(0);
assertNotNull(car);
if (car != null && "Porsche".equals(car.getMake())
&& "Boxster".equals(car.getModel())
&& "1998".equals(car.getYear())
&& "white".equals(car.getColor())) {
// get the right car
} else {
fail("Get the wrong car!");
}
/**
* CarDealer.tradeIn(Car) takes an abstract class Car and returns the same.
* We will send a sub-class instead and expect to get the same.
*
*/
Porsche oldCar = new Porsche();
oldCar.setMake("Porsche");
oldCar.setColor("white");
oldCar.setModel("GT2000");
oldCar.setYear("2000");
Porsche newCar = (Porsche)dealer.tradeIn(oldCar);
assertNotNull(newCar);
if (newCar != null && "Porsche".equals(newCar.getMake())
&& "911GT3".equals(newCar.getModel())
&& "2007".equals(newCar.getYear())
&& "black".equals(newCar.getColor())) {
// get the right car
} else {
fail("Get the wrong car!");
}
}