Source:
<code>public void getCandidatesByFilterRequestShouldFindDummyCandidateDTOInAscendingOrderByNameWhenThereIsARightCandidateFilterRequest() { CandidateFilterRequest candidateFilterRequest = CandidateFilterRequest.builder().pageNumber(DEFAULT_PAGE_NUMBER).pageSize(DEFAULT_PAGE_SIZE) .sortName(SORT_NAME_NAME).sortOrder(SORT_ORDER_ASC).candidateName(NAME).build(); PageRequest pageRequest = new PageRequest(candidateFilterRequest.getPageNumber(), candidateFilterRequest.getPageSize(), Sort.Direction.fromString(candidateFilterRequest.getSortOrder()), candidateFilterRequest.getSortName()); String name = candidateFilterRequest.getCandidateName(); String email = candidateFilterRequest.getCandidateEmail(); String phone = candidateFilterRequest.getCandidatePhone(); <START> String positions = candidateFilterRequest.getCandiadtePositions(); <END> Page<CandidateEntity> dummyCandidateEntityPage = new PageImpl<>(Arrays.asList(dummyCandidateEntity)); List<CandidateDTO> dummyCandidateDTOs = Arrays.asList(dummyCandidateDto); given(candidateRepository .findByCandidateFilterRequest(name, email, phone, positions, pageRequest)) .willReturn(dummyCandidateEntityPage); given(converterService.convert(dummyCandidateEntityPage.getContent(), CandidateDTO.class)) .willReturn(dummyCandidateDTOs); PagingResponse<CandidateDTO> expectedPagingResponse = new PagingResponse<>(dummyCandidateEntityPage.getTotalElements(), dummyCandidateDTOs); PagingResponse<CandidateDTO> actualPagingResponse = candidateService.getCandidatesByFilterRequest(candidateFilterRequest); assertEquals(actualPagingResponse, expectedPagingResponse); then(converterService).should(times(1)) .convert(dummyCandidateEntityPage.getContent(), CandidateDTO.class); then(candidateRepository).should(times(1)) .findByCandidateFilterRequest(name, email, phone, positions, pageRequest); }</code><technical_language>Minor improvement suggestion: local variables (pageRequest, name, email, phone, positions) final</technical_language>

Target:
public void getCandidatesByFilterRequestShouldFindDummyCandidateDTOInAscendingOrderByNameWhenThereIsARightCandidateFilterRequest() { final CandidateFilterRequest candidateFilterRequest = CandidateFilterRequest.builder().pageNumber(DEFAULT_PAGE_NUMBER).pageSize(DEFAULT_PAGE_SIZE) .sortName(SORT_NAME_NAME).sortOrder(SORT_ORDER_ASC).candidateName(NAME).build(); final PageRequest pageRequest = new PageRequest(candidateFilterRequest.getPageNumber(), candidateFilterRequest.getPageSize(), Sort.Direction.fromString(candidateFilterRequest.getSortOrder()), candidateFilterRequest.getSortName()); final String name = candidateFilterRequest.getCandidateName(); final String email = StringUtils.EMPTY; final String phone = StringUtils.EMPTY; final String positions = StringUtils.EMPTY; final Page<CandidateEntity> dummyCandidateEntityPage = new PageImpl<>(Arrays.asList(dummyCandidateEntity)); final List<CandidateDTO> dummyCandidateDTOs = Arrays.asList(dummyCandidateDto); given(candidateRepository .findByCandidateFilterRequest(name, email, phone, positions, pageRequest)) .willReturn(dummyCandidateEntityPage); given(converterService.convert(dummyCandidateEntityPage.getContent(), CandidateDTO.class)) .willReturn(dummyCandidateDTOs); final PagingResponse<CandidateDTO> expectedPagingResponse = new PagingResponse<>(dummyCandidateEntityPage.getTotalElements(), dummyCandidateDTOs); final PagingResponse<CandidateDTO> actualPagingResponse = candidateService.getCandidatesByFilterRequest(candidateFilterRequest); assertEquals(actualPagingResponse, expectedPagingResponse); then(converterService).should(times(1)) .convert(dummyCandidateEntityPage.getContent(), CandidateDTO.class); then(candidateRepository).should(times(1)) .findByCandidateFilterRequest(name, email, phone, positions, pageRequest); }