use of com.ncedu.fooddelivery.api.v1.dto.file.FileInfoDTO in project 2021-msk-food-delivery by netcracker-edu.
the class FileServiceTest method getFileList.
@Test
public void getFileList() {
Long ownerId = 1L;
User howardOwner = UserUtils.courierHowardWolowitz(ownerId);
File file1 = new File(UUID.randomUUID(), FileType.JPEG, "test", 0L, Timestamp.valueOf(LocalDateTime.now()), howardOwner);
File file2 = new File(UUID.randomUUID(), FileType.JPEG, "test2", 0L, Timestamp.valueOf(LocalDateTime.now()), howardOwner);
List<File> fileList = new ArrayList<>();
fileList.add(file1);
fileList.add(file2);
Pageable pageable = PageRequest.of(0, 2);
Page page = new PageImpl(fileList, pageable, fileList.size());
when(fileRepoMock.findAll(pageable)).thenReturn(page);
List<FileInfoDTO> resultDTOs = fileService.getAllFiles(pageable);
List<FileInfoDTO> perfectDTOs = new ArrayList<>();
for (File file : fileList) {
perfectDTOs.add(createFileDTO(file));
}
assertEquals(perfectDTOs.size(), resultDTOs.size());
assertEquals(perfectDTOs, resultDTOs);
}
Aggregations