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());
}
Aggregations