### Question:
FileListServiceImpl implements FileListService { @Override public FileListResponse getFileList(FileListRequest request, DpsHeaders headers) { log.debug("Request file list with parameters : {}", request); validationService.validateFileListRequest(request); FileListResponse response = fileLocationRepository.findAll(request); log.debug("File list result : {}", response); return response; }  @Override FileListResponse getFileList(FileListRequest request, DpsHeaders headers);  }### Answer:
@Test void shouldReturnFileListByRequest() { LocalDateTime now = LocalDateTime.now(); FileListRequest request = FileListRequest.builder() .timeFrom(now.minusHours(1)) .timeTo(now) .pageNum(0) .items((short) 5) .userID(TEMP_USER) .build(); DpsHeaders headers = getHeaders(); given(fileLocationRepository.findAll(request)).willReturn(FileListResponse.builder() .content(Arrays.asList( getFileLocation(toDate(now.minusMinutes(10))), getFileLocation(toDate(now.minusMinutes(20))))) .number(0) .numberOfElements(2) .size(5) .build()); FileListResponse response = fileListService.getFileList(request, headers); then(response).isEqualToIgnoringGivenFields(FileListResponse.builder() .number(0) .numberOfElements(2) .size(5) .build(), "content"); then(response.getContent()).hasSize(2); InOrder inOrder = Mockito.inOrder(validationService, fileLocationRepository); inOrder.verify(validationService).validateFileListRequest(request); inOrder.verify(fileLocationRepository).findAll(request); inOrder.verifyNoMoreInteractions(); }
@Test void shouldThrowExceptionWhenGetFileListRequestIsInvalid() { FileListRequest request = FileListRequest.builder() .build(); DpsHeaders headers = getHeaders(); willThrow(ConstraintViolationException.class).given(validationService) .validateFileListRequest(request); Throwable thrown = catchThrowable(() -> fileListService.getFileList(request, headers)); then(thrown).isInstanceOf(ConstraintViolationException.class); InOrder inOrder = Mockito.inOrder(validationService, fileLocationRepository); inOrder.verify(validationService).validateFileListRequest(request); inOrder.verifyNoMoreInteractions(); }