ApplicationsServiceImpl extends AbstractLogicallyDeletableService<ApplicationDTO, ApplicationEntity> implements ApplicationsService { @Transactional @Override public void deleteApplicationsByCandidateDTO(CandidateDTO candidateDTO) { Assert.notNull(candidateDTO); Assert.notNull(candidateDTO.getId()); List<ApplicationEntity> applicationEntities = converterService .convert(getApplicationsByCandidateDTO(candidateDTO), ApplicationEntity.class); for (ApplicationEntity applicationEntity : applicationEntities) { statesHistoryService.deleteStateHistoriesByApplication( converterService.convert(applicationEntity, ApplicationDTO.class)); applicationsRepository.delete(applicationEntity); } } @Autowired  ApplicationsServiceImpl(
      ApplicationsRepository applicationRepository,
      StatesHistoryService statesHistoryService,
      CandidateRepository candidateRepository,
      ConverterService converterService); @Transactional(readOnly = true) @Override List<ApplicationDTO> getApplicationsByCandidateDTO(CandidateDTO candidateDTO); @Transactional(readOnly = true) @Override PagingResponse<CandidateApplicationDTO> getApplicationsByCandidateId(
      Long candidateId,
      int page,
      int size); @Transactional @Override void deleteApplicationsByCandidateDTO(CandidateDTO candidateDTO); @Transactional(readOnly = true) @Override ApplicationDTO getApplicationDtoById(Long applicationId); @Transactional @Override Long saveOrUpdate(ApplicationDTO applicationDTO); @Transactional @Override Long saveApplication(ApplicationDTO applicationDTO, StateHistoryDTO stateHistoryDTO);  }
@Test(expected = IllegalArgumentException.class) public void deleteApplicationsByCandidateDTOShouldThrowIllegalArgumentExceptionWhenCandidateDTOIsNull() { applicationsService.deleteApplicationsByCandidateDTO(null); }
@Test(expected = IllegalArgumentException.class) public void deleteApplicationsByCandidateDTOShouldThrowIllegalArgumentExceptionWhenCandidateDTOsIdIsNull() { CandidateDTO candidateDTO = CandidateDTO.builder().id(null).build(); applicationsService.deleteApplicationsByCandidateDTO(candidateDTO); }