Search in sources :

Example 1 with BinaryDataMetaInfo

use of com.epam.ta.reportportal.commons.BinaryDataMetaInfo in project commons-dao by reportportal.

the class AttachmentCommonDataStoreServiceTest method AttachFileToExistingLogTest.

@Test
@Sql("/db/fill/data-store/data-store-fill.sql")
void AttachFileToExistingLogTest() {
    String fileID = "fileID";
    String thumbnailID = "thumbnailID";
    String contentType = "content-type";
    long fileSize = 1024;
    final LocalDateTime creationDate = LocalDateTime.of(2020, Month.JANUARY, 1, 1, 1);
    BinaryDataMetaInfo binaryDataMetaInfo = new BinaryDataMetaInfo();
    binaryDataMetaInfo.setFileId(fileID);
    binaryDataMetaInfo.setThumbnailFileId(thumbnailID);
    binaryDataMetaInfo.setContentType(contentType);
    binaryDataMetaInfo.setFileSize(fileSize);
    Long projectId = 1L;
    Long itemId = 1L;
    AttachmentMetaInfo attachmentMetaInfo = AttachmentMetaInfo.builder().withProjectId(projectId).withLaunchId(1L).withItemId(itemId).withLogId(1L).withCreationDate(creationDate).build();
    attachmentBinaryDataService.attachToLog(binaryDataMetaInfo, attachmentMetaInfo);
    Optional<Attachment> attachment = attachmentRepository.findByFileId(fileID);
    assertTrue(attachment.isPresent());
    assertEquals(projectId, attachment.get().getProjectId());
    assertEquals(itemId, attachment.get().getItemId());
    assertEquals(fileID, attachment.get().getFileId());
    assertEquals(thumbnailID, attachment.get().getThumbnailId());
    assertEquals(contentType, attachment.get().getContentType());
    assertEquals(fileSize, attachment.get().getFileSize());
    assertEquals(creationDate, attachment.get().getCreationDate());
}
Also used : LocalDateTime(java.time.LocalDateTime) Attachment(com.epam.ta.reportportal.entity.attachment.Attachment) BinaryDataMetaInfo(com.epam.ta.reportportal.commons.BinaryDataMetaInfo) AttachmentMetaInfo(com.epam.ta.reportportal.entity.attachment.AttachmentMetaInfo) BaseTest(com.epam.ta.reportportal.BaseTest) Test(org.junit.jupiter.api.Test) Sql(org.springframework.test.context.jdbc.Sql)

Aggregations

BaseTest (com.epam.ta.reportportal.BaseTest)1 BinaryDataMetaInfo (com.epam.ta.reportportal.commons.BinaryDataMetaInfo)1 Attachment (com.epam.ta.reportportal.entity.attachment.Attachment)1 AttachmentMetaInfo (com.epam.ta.reportportal.entity.attachment.AttachmentMetaInfo)1 LocalDateTime (java.time.LocalDateTime)1 Test (org.junit.jupiter.api.Test)1 Sql (org.springframework.test.context.jdbc.Sql)1