Search in sources :

Example 1 with FileInfoDTO

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);
}
Also used : User(com.ncedu.fooddelivery.api.v1.entities.User) File(com.ncedu.fooddelivery.api.v1.entities.File) MockMultipartFile(org.springframework.mock.web.MockMultipartFile) MultipartFile(org.springframework.web.multipart.MultipartFile) FileInfoDTO(com.ncedu.fooddelivery.api.v1.dto.file.FileInfoDTO) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

FileInfoDTO (com.ncedu.fooddelivery.api.v1.dto.file.FileInfoDTO)1 File (com.ncedu.fooddelivery.api.v1.entities.File)1 User (com.ncedu.fooddelivery.api.v1.entities.User)1 Test (org.junit.jupiter.api.Test)1 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)1 MockMultipartFile (org.springframework.mock.web.MockMultipartFile)1 MultipartFile (org.springframework.web.multipart.MultipartFile)1