package education.jtrainer.tutorial.junit; import org.springframework.beans.factory.annotation.Autowired; public class ReservationService { @Autowired public CarFactory carFactory; public Reservation getReservation(String carType) throws Exception { Car reservedCar=carFactory.getCar(carType); if (reservedCar==null) throw new Exception("car type not available"); Reservation reservation=new Reservation(); reservation.setReservedCar(reservedCar); return reservation; } public CarFactory getCarFactory() { return carFactory; } public void setCarFactory(CarFactory carFactory) { this.carFactory = carFactory; } }