@Test public void testBuildGarageInvalidOwner() { Garage garage = getValidGarage(); garage.getOwner().setId(0); garage.getOwner().setName("hh"); ComplexResult result = garageService.buildGarage(garage); System.out.println(result); assertThat(result.isSuccess(), is(false)); assertThat(result.getErrorNumber(), is(2)); }
@Override public ComplexResult buildGarage(Garage garage) { Preconditions.checkNotNull(garage, "garage should not be null"); ComplexResult result = FluentValidator.checkAll() .configure(springApplicationContextRegistry) .on(garage, new HibernateSupportedValidator<Garage>().setHiberanteValidator(hibernateValidator)) .on(garage, new GarageCarNotExceedLimitValidator()) .onEach(garage.getCarList()) .doValidate().result(toComplex()); return result; }
GarageServiceImpl implements GarageService { @Override public ComplexResult buildGarage(Garage garage) { Preconditions.checkNotNull(garage, "garage should not be null"); ComplexResult result = FluentValidator.checkAll() .configure(springApplicationContextRegistry) .on(garage, new HibernateSupportedValidator<Garage>().setHiberanteValidator(hibernateValidator)) .on(garage, new GarageCarNotExceedLimitValidator()) .onEach(garage.getCarList()) .doValidate().result(toComplex()); return result; } }
GarageServiceImpl implements GarageService { @Override public ComplexResult buildGarage(Garage garage) { Preconditions.checkNotNull(garage, "garage should not be null"); ComplexResult result = FluentValidator.checkAll() .configure(springApplicationContextRegistry) .on(garage, new HibernateSupportedValidator<Garage>().setHiberanteValidator(hibernateValidator)) .on(garage, new GarageCarNotExceedLimitValidator()) .onEach(garage.getCarList()) .doValidate().result(toComplex()); return result; }  }
GarageServiceImpl implements GarageService { @Override public ComplexResult buildGarage(Garage garage) { Preconditions.checkNotNull(garage, "garage should not be null"); ComplexResult result = FluentValidator.checkAll() .configure(springApplicationContextRegistry) .on(garage, new HibernateSupportedValidator<Garage>().setHiberanteValidator(hibernateValidator)) .on(garage, new GarageCarNotExceedLimitValidator()) .onEach(garage.getCarList()) .doValidate().result(toComplex()); 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 ComplexResult buildGarage(Garage garage) { Preconditions.checkNotNull(garage, "garage should not be null"); ComplexResult result = FluentValidator.checkAll() .configure(springApplicationContextRegistry) .on(garage, new HibernateSupportedValidator<Garage>().setHiberanteValidator(hibernateValidator)) .on(garage, new GarageCarNotExceedLimitValidator()) .onEach(garage.getCarList()) .doValidate().result(toComplex()); return result; }  @Override Result addCars(List<Car> cars); @Override Result addCarsThrowException(List<Car> cars); @Override Result addCar(Car car); @Override ComplexResult buildGarage(Garage garage);  }