@Test public void testAddCarMultipleError() { Result result = garageService.addCar(new Car("BMW", "XXXXX1234", 0)); System.out.println(result); assertThat(result.isSuccess(), is(false)); assertThat(result.getErrorNumber(), is(2)); assertThat(result.getErrors().get(0), is(String.format(CarError.SEATCOUNT_ERROR.msg(), 0))); assertThat(result.getErrors().get(1), is(String.format(CarError.LICENSEPLATE_ERROR.msg(), "XXXXX1234"))); }
@Override public Result addCar(Car car) { Preconditions.checkNotNull(car, "car should not be null"); Result result = FluentValidator.checkAll().failOver() .on(car.getManufacturer(), new CarManufacturerValidator()) .on(car.getSeatCount(), new CarSeatCountValidator()) .on(car.getLicensePlate(), new CarLicensePlateValidator()) .doValidate().result(toSimple()); return result; }
GarageServiceImpl implements GarageService { @Override public Result addCar(Car car) { Preconditions.checkNotNull(car, "car should not be null"); Result result = FluentValidator.checkAll().failOver() .on(car.getManufacturer(), new CarManufacturerValidator()) .on(car.getSeatCount(), new CarSeatCountValidator()) .on(car.getLicensePlate(), new CarLicensePlateValidator()) .doValidate().result(toSimple()); return result; } }
GarageServiceImpl implements GarageService { @Override public Result addCar(Car car) { Preconditions.checkNotNull(car, "car should not be null"); Result result = FluentValidator.checkAll().failOver() .on(car.getManufacturer(), new CarManufacturerValidator()) .on(car.getSeatCount(), new CarSeatCountValidator()) .on(car.getLicensePlate(), new CarLicensePlateValidator()) .doValidate().result(toSimple()); return result; }  }
GarageServiceImpl implements GarageService { @Override public Result addCar(Car car) { Preconditions.checkNotNull(car, "car should not be null"); Result result = FluentValidator.checkAll().failOver() .on(car.getManufacturer(), new CarManufacturerValidator()) .on(car.getSeatCount(), new CarSeatCountValidator()) .on(car.getLicensePlate(), new CarLicensePlateValidator()) .doValidate().result(toSimple()); return result; }  @Override Result addCars(List<Car> cars); @Override Result addCarsThrowException(List<Car> cars); @Override Result addCar(Car car); @Override ComplexResult buildGarage(Garage garage); }
GarageServiceImpl implements GarageService { @Override public Result addCar(Car car) { Preconditions.checkNotNull(car, "car should not be null"); Result result = FluentValidator.checkAll().failOver() .on(car.getManufacturer(), new CarManufacturerValidator()) .on(car.getSeatCount(), new CarSeatCountValidator()) .on(car.getLicensePlate(), new CarLicensePlateValidator()) .doValidate().result(toSimple()); return result; }  @Override Result addCars(List<Car> cars); @Override Result addCarsThrowException(List<Car> cars); @Override Result addCar(Car car); @Override ComplexResult buildGarage(Garage garage);  }