@Test(expected = RuntimeException.class) public void shouldThrowErrorWhenFindCarWithInvalidId() { // setup test? // Use import.sql for hibernate auto-insert? Car car = carRepository.findById(-1L); }
@Test public void shouldReturnNonNullWhenFindCarWithValidId() throws Exception { Car car = CarBuilder.aCar().build(); saveDomainEntityToRepositoryWithTransaction(car); Car foundCar = carRepository.findById(car.getId()); assertThat(foundCar).isNotNull(); }
@Test(expected = Exception.class) public void shouldThrowErrorWhenFindCarWithNullId() { // Car car = new Car(CarProcessState.AwaitingCapture); // Car carResponse = applicationProcessService.moveProcessForward(car); // assertThat(carResponse).isNotNull(); // log.info("applicationSearchService={}", applicationSearchService); // log.info("carResponse={}", carResponse); // log.info("carResponse.getId()={}", carResponse.getId()); Car carFound = carRepository.findById(null); }
@Test public void shouldReturnWithoutErrorWhenSavingExistingCar() throws NotSupportedException, SystemException, SecurityException, IllegalStateException, RollbackException, HeuristicMixedException, HeuristicRollbackException { Car car = CarBuilder.aCar().build(); saveDomainEntityToRepositoryWithTransaction(car); car = carRepository.findById(car.getId()); car.setPrice(28); saveDomainEntityToRepositoryWithTransaction(car); assertThat(car).isNotNull(); }