@Test(expected = IllegalArgumentException.class) public void saveStateHistoryShouldThrowIllegalArgumentExceptionWhenStateDtoIdIsNull() { StateDTO stateDTO = StateDTO.builder().id(null).build(); StateHistoryDTO stateHistoryDTO = StateHistoryDTO.builder().stateDTO(stateDTO).build(); statesHistoryService.saveStateHistory(stateHistoryDTO); }
@Transactional @Override public Long saveStateHistory(StateHistoryDTO state) { Assert.notNull(state); Assert.notNull(state.getStateDTO()); Assert.notNull(state.getStateDTO().getId()); StatesEntity statesEntity = statesRepository.findOne(state.getStateDTO().getId()); Assert.notNull(statesEntity); StatesHistoryEntity statesHistoryEntity = converterService.convert(state, StatesHistoryEntity.class); statesHistoryEntity .setCreationDate(state.getCreationDate() == null ? new Date() : state.getCreationDate()); applicationsService.saveOrUpdate(state.getApplicationDTO()); return statesHistoryRepository.saveAndFlush(statesHistoryEntity).getId(); }
StatesHistoryServiceImpl implements StatesHistoryService { @Transactional @Override public Long saveStateHistory(StateHistoryDTO state) { Assert.notNull(state); Assert.notNull(state.getStateDTO()); Assert.notNull(state.getStateDTO().getId()); StatesEntity statesEntity = statesRepository.findOne(state.getStateDTO().getId()); Assert.notNull(statesEntity); StatesHistoryEntity statesHistoryEntity = converterService.convert(state, StatesHistoryEntity.class); statesHistoryEntity .setCreationDate(state.getCreationDate() == null ? new Date() : state.getCreationDate()); applicationsService.saveOrUpdate(state.getApplicationDTO()); return statesHistoryRepository.saveAndFlush(statesHistoryEntity).getId(); } }
StatesHistoryServiceImpl implements StatesHistoryService { @Transactional @Override public Long saveStateHistory(StateHistoryDTO state) { Assert.notNull(state); Assert.notNull(state.getStateDTO()); Assert.notNull(state.getStateDTO().getId()); StatesEntity statesEntity = statesRepository.findOne(state.getStateDTO().getId()); Assert.notNull(statesEntity); StatesHistoryEntity statesHistoryEntity = converterService.convert(state, StatesHistoryEntity.class); statesHistoryEntity .setCreationDate(state.getCreationDate() == null ? new Date() : state.getCreationDate()); applicationsService.saveOrUpdate(state.getApplicationDTO()); return statesHistoryRepository.saveAndFlush(statesHistoryEntity).getId(); }  }
StatesHistoryServiceImpl implements StatesHistoryService { @Transactional @Override public Long saveStateHistory(StateHistoryDTO state) { Assert.notNull(state); Assert.notNull(state.getStateDTO()); Assert.notNull(state.getStateDTO().getId()); StatesEntity statesEntity = statesRepository.findOne(state.getStateDTO().getId()); Assert.notNull(statesEntity); StatesHistoryEntity statesHistoryEntity = converterService.convert(state, StatesHistoryEntity.class); statesHistoryEntity .setCreationDate(state.getCreationDate() == null ? new Date() : state.getCreationDate()); applicationsService.saveOrUpdate(state.getApplicationDTO()); return statesHistoryRepository.saveAndFlush(statesHistoryEntity).getId(); }  @Transactional @Override void deleteStateHistoriesByApplication(ApplicationDTO applicationDTO); @Transactional @Override Long saveStateHistory(StateHistoryDTO state); @Transactional(readOnly = true) @Override List<StateHistoryDTO> getStateHistoriesByApplicationId(Long applicationId); }
StatesHistoryServiceImpl implements StatesHistoryService { @Transactional @Override public Long saveStateHistory(StateHistoryDTO state) { Assert.notNull(state); Assert.notNull(state.getStateDTO()); Assert.notNull(state.getStateDTO().getId()); StatesEntity statesEntity = statesRepository.findOne(state.getStateDTO().getId()); Assert.notNull(statesEntity); StatesHistoryEntity statesHistoryEntity = converterService.convert(state, StatesHistoryEntity.class); statesHistoryEntity .setCreationDate(state.getCreationDate() == null ? new Date() : state.getCreationDate()); applicationsService.saveOrUpdate(state.getApplicationDTO()); return statesHistoryRepository.saveAndFlush(statesHistoryEntity).getId(); }  @Transactional @Override void deleteStateHistoriesByApplication(ApplicationDTO applicationDTO); @Transactional @Override Long saveStateHistory(StateHistoryDTO state); @Transactional(readOnly = true) @Override List<StateHistoryDTO> getStateHistoriesByApplicationId(Long applicationId);  }