@Test(expected = IllegalArgumentException.class) public void getCandidatesByFilterRequestShouldThrowIllegalArgumentExceptionWhenSortNameIsNotNullButSortOrderIsNull() { CandidateFilterRequest candidateFilterRequest = CandidateFilterRequest.builder().sortName(SORT_NAME_NAME).sortOrder(null).build(); candidateService.getCandidatesByFilterRequest(candidateFilterRequest); }
@Transactional(readOnly = true) @Override public PagingResponse<CandidateDTO> getCandidatesByFilterRequest( CandidateFilterRequest candidateFilterRequest) { PageRequest pageRequest; validateCandidateFilterRequest(candidateFilterRequest); if (candidateFilterRequest.getSortName() != null && candidateFilterRequest.getSortOrder() != null) { Sort.Direction sortDirection = Sort.Direction.fromString(candidateFilterRequest.getSortOrder()); pageRequest = new PageRequest(candidateFilterRequest.getPageNumber(), candidateFilterRequest.getPageSize(), sortDirection, candidateFilterRequest.getSortName()); } else { pageRequest = new PageRequest(candidateFilterRequest.getPageNumber(), candidateFilterRequest.getPageSize()); } final String name = MoreObjects.firstNonNull(candidateFilterRequest.getCandidateName(), StringUtils.EMPTY); final String email = MoreObjects.firstNonNull(candidateFilterRequest.getCandidateEmail(), StringUtils.EMPTY); final String phone = MoreObjects.firstNonNull(candidateFilterRequest.getCandidatePhone(), StringUtils.EMPTY); final String positions = MoreObjects.firstNonNull(candidateFilterRequest.getCandiadtePositions(), StringUtils.EMPTY); final Page<CandidateEntity> candidateEntitiesPage = candidateRepository .findByCandidateFilterRequest(name, email, phone, positions, pageRequest); final List<CandidateDTO> candidateDTOs = converterService.convert(candidateEntitiesPage.getContent(), CandidateDTO.class); final PagingResponse<CandidateDTO> result = new PagingResponse<>(candidateEntitiesPage.getTotalElements(), candidateDTOs); return result; }
CandidateServiceImpl extends AbstractLogicallyDeletableService<CandidateDTO, CandidateEntity> implements CandidateService { @Transactional(readOnly = true) @Override public PagingResponse<CandidateDTO> getCandidatesByFilterRequest( CandidateFilterRequest candidateFilterRequest) { PageRequest pageRequest; validateCandidateFilterRequest(candidateFilterRequest); if (candidateFilterRequest.getSortName() != null && candidateFilterRequest.getSortOrder() != null) { Sort.Direction sortDirection = Sort.Direction.fromString(candidateFilterRequest.getSortOrder()); pageRequest = new PageRequest(candidateFilterRequest.getPageNumber(), candidateFilterRequest.getPageSize(), sortDirection, candidateFilterRequest.getSortName()); } else { pageRequest = new PageRequest(candidateFilterRequest.getPageNumber(), candidateFilterRequest.getPageSize()); } final String name = MoreObjects.firstNonNull(candidateFilterRequest.getCandidateName(), StringUtils.EMPTY); final String email = MoreObjects.firstNonNull(candidateFilterRequest.getCandidateEmail(), StringUtils.EMPTY); final String phone = MoreObjects.firstNonNull(candidateFilterRequest.getCandidatePhone(), StringUtils.EMPTY); final String positions = MoreObjects.firstNonNull(candidateFilterRequest.getCandiadtePositions(), StringUtils.EMPTY); final Page<CandidateEntity> candidateEntitiesPage = candidateRepository .findByCandidateFilterRequest(name, email, phone, positions, pageRequest); final List<CandidateDTO> candidateDTOs = converterService.convert(candidateEntitiesPage.getContent(), CandidateDTO.class); final PagingResponse<CandidateDTO> result = new PagingResponse<>(candidateEntitiesPage.getTotalElements(), candidateDTOs); return result; } }
CandidateServiceImpl extends AbstractLogicallyDeletableService<CandidateDTO, CandidateEntity> implements CandidateService { @Transactional(readOnly = true) @Override public PagingResponse<CandidateDTO> getCandidatesByFilterRequest( CandidateFilterRequest candidateFilterRequest) { PageRequest pageRequest; validateCandidateFilterRequest(candidateFilterRequest); if (candidateFilterRequest.getSortName() != null && candidateFilterRequest.getSortOrder() != null) { Sort.Direction sortDirection = Sort.Direction.fromString(candidateFilterRequest.getSortOrder()); pageRequest = new PageRequest(candidateFilterRequest.getPageNumber(), candidateFilterRequest.getPageSize(), sortDirection, candidateFilterRequest.getSortName()); } else { pageRequest = new PageRequest(candidateFilterRequest.getPageNumber(), candidateFilterRequest.getPageSize()); } final String name = MoreObjects.firstNonNull(candidateFilterRequest.getCandidateName(), StringUtils.EMPTY); final String email = MoreObjects.firstNonNull(candidateFilterRequest.getCandidateEmail(), StringUtils.EMPTY); final String phone = MoreObjects.firstNonNull(candidateFilterRequest.getCandidatePhone(), StringUtils.EMPTY); final String positions = MoreObjects.firstNonNull(candidateFilterRequest.getCandiadtePositions(), StringUtils.EMPTY); final Page<CandidateEntity> candidateEntitiesPage = candidateRepository .findByCandidateFilterRequest(name, email, phone, positions, pageRequest); final List<CandidateDTO> candidateDTOs = converterService.convert(candidateEntitiesPage.getContent(), CandidateDTO.class); final PagingResponse<CandidateDTO> result = new PagingResponse<>(candidateEntitiesPage.getTotalElements(), candidateDTOs); return result; } @Autowired  CandidateServiceImpl(CandidateRepository candidateRepository,
                              ApplicationsRepository applicationsRepository,
                              ApplicationsService applicationsService,
                              ConverterService converterService); }
CandidateServiceImpl extends AbstractLogicallyDeletableService<CandidateDTO, CandidateEntity> implements CandidateService { @Transactional(readOnly = true) @Override public PagingResponse<CandidateDTO> getCandidatesByFilterRequest( CandidateFilterRequest candidateFilterRequest) { PageRequest pageRequest; validateCandidateFilterRequest(candidateFilterRequest); if (candidateFilterRequest.getSortName() != null && candidateFilterRequest.getSortOrder() != null) { Sort.Direction sortDirection = Sort.Direction.fromString(candidateFilterRequest.getSortOrder()); pageRequest = new PageRequest(candidateFilterRequest.getPageNumber(), candidateFilterRequest.getPageSize(), sortDirection, candidateFilterRequest.getSortName()); } else { pageRequest = new PageRequest(candidateFilterRequest.getPageNumber(), candidateFilterRequest.getPageSize()); } final String name = MoreObjects.firstNonNull(candidateFilterRequest.getCandidateName(), StringUtils.EMPTY); final String email = MoreObjects.firstNonNull(candidateFilterRequest.getCandidateEmail(), StringUtils.EMPTY); final String phone = MoreObjects.firstNonNull(candidateFilterRequest.getCandidatePhone(), StringUtils.EMPTY); final String positions = MoreObjects.firstNonNull(candidateFilterRequest.getCandiadtePositions(), StringUtils.EMPTY); final Page<CandidateEntity> candidateEntitiesPage = candidateRepository .findByCandidateFilterRequest(name, email, phone, positions, pageRequest); final List<CandidateDTO> candidateDTOs = converterService.convert(candidateEntitiesPage.getContent(), CandidateDTO.class); final PagingResponse<CandidateDTO> result = new PagingResponse<>(candidateEntitiesPage.getTotalElements(), candidateDTOs); return result; } @Autowired  CandidateServiceImpl(CandidateRepository candidateRepository,
                              ApplicationsRepository applicationsRepository,
                              ApplicationsService applicationsService,
                              ConverterService converterService); @Transactional(readOnly = true) @Override CandidateDTO getCandidate(Long id); @Transactional(readOnly = true) @Override CandidateDTO getCandidateByApplicationID(Long applicationID); @Transactional(readOnly = true) @Override PagingResponse<CandidateDTO> getCandidatesByFilterRequest(
      CandidateFilterRequest candidateFilterRequest); @Transactional @Override void deletePositionsByCandidate(CandidateDTO candidateDTO); @Transactional @Override Long saveOrUpdate(CandidateDTO candidate); @Transactional(readOnly = true) @Override CandidateDTO getCandidateDtoByEmail(String email); @Transactional(readOnly = true) @Override CandidateDTO getCandidateDtoByPhone(String phone); }
CandidateServiceImpl extends AbstractLogicallyDeletableService<CandidateDTO, CandidateEntity> implements CandidateService { @Transactional(readOnly = true) @Override public PagingResponse<CandidateDTO> getCandidatesByFilterRequest( CandidateFilterRequest candidateFilterRequest) { PageRequest pageRequest; validateCandidateFilterRequest(candidateFilterRequest); if (candidateFilterRequest.getSortName() != null && candidateFilterRequest.getSortOrder() != null) { Sort.Direction sortDirection = Sort.Direction.fromString(candidateFilterRequest.getSortOrder()); pageRequest = new PageRequest(candidateFilterRequest.getPageNumber(), candidateFilterRequest.getPageSize(), sortDirection, candidateFilterRequest.getSortName()); } else { pageRequest = new PageRequest(candidateFilterRequest.getPageNumber(), candidateFilterRequest.getPageSize()); } final String name = MoreObjects.firstNonNull(candidateFilterRequest.getCandidateName(), StringUtils.EMPTY); final String email = MoreObjects.firstNonNull(candidateFilterRequest.getCandidateEmail(), StringUtils.EMPTY); final String phone = MoreObjects.firstNonNull(candidateFilterRequest.getCandidatePhone(), StringUtils.EMPTY); final String positions = MoreObjects.firstNonNull(candidateFilterRequest.getCandiadtePositions(), StringUtils.EMPTY); final Page<CandidateEntity> candidateEntitiesPage = candidateRepository .findByCandidateFilterRequest(name, email, phone, positions, pageRequest); final List<CandidateDTO> candidateDTOs = converterService.convert(candidateEntitiesPage.getContent(), CandidateDTO.class); final PagingResponse<CandidateDTO> result = new PagingResponse<>(candidateEntitiesPage.getTotalElements(), candidateDTOs); return result; } @Autowired  CandidateServiceImpl(CandidateRepository candidateRepository,
                              ApplicationsRepository applicationsRepository,
                              ApplicationsService applicationsService,
                              ConverterService converterService); @Transactional(readOnly = true) @Override CandidateDTO getCandidate(Long id); @Transactional(readOnly = true) @Override CandidateDTO getCandidateByApplicationID(Long applicationID); @Transactional(readOnly = true) @Override PagingResponse<CandidateDTO> getCandidatesByFilterRequest(
      CandidateFilterRequest candidateFilterRequest); @Transactional @Override void deletePositionsByCandidate(CandidateDTO candidateDTO); @Transactional @Override Long saveOrUpdate(CandidateDTO candidate); @Transactional(readOnly = true) @Override CandidateDTO getCandidateDtoByEmail(String email); @Transactional(readOnly = true) @Override CandidateDTO getCandidateDtoByPhone(String phone);  }