use of com.epam.ta.reportportal.entity.attachment.Attachment in project commons-dao by reportportal.
the class CreateLogAttachmentServiceTest method createAttachmentPositive.
@Test
void createAttachmentPositive() {
Log log = getLogWithoutAttachment();
Attachment attachment = getAttachment();
when(logRepository.findById(1L)).thenReturn(Optional.of(log));
createLogAttachmentService.create(attachment, 1L);
verify(logRepository, times(1)).save(log);
assertEquals(log.getAttachment().getFileId(), attachment.getFileId());
assertEquals(log.getAttachment().getThumbnailId(), attachment.getThumbnailId());
assertEquals(log.getAttachment().getContentType(), attachment.getContentType());
}
use of com.epam.ta.reportportal.entity.attachment.Attachment in project commons-dao by reportportal.
the class AttachmentRepositoryTest method shouldNotFindByLaunchIdsWhenLessThenPeriod.
@Test
void shouldNotFindByLaunchIdsWhenLessThenPeriod() {
Duration duration = Duration.ofDays(14).plusHours(23);
final Long launchId = 3L;
List<Attachment> attachments = attachmentRepository.findByLaunchIdsAndLogTimeBefore(Collections.singletonList(launchId), LocalDateTime.now(ZoneOffset.UTC).minus(duration));
assertTrue(CollectionUtils.isEmpty(attachments), "Attachments should be empty");
}
use of com.epam.ta.reportportal.entity.attachment.Attachment in project commons-dao by reportportal.
the class AttachmentRepositoryTest method findByLaunchIdsAndPeriodTest.
@Test
void findByLaunchIdsAndPeriodTest() {
Duration duration = Duration.ofDays(6).plusHours(23);
final Long launchId = 3L;
List<Attachment> attachments = attachmentRepository.findByLaunchIdsAndLogTimeBefore(Collections.singletonList(launchId), LocalDateTime.now(ZoneOffset.UTC).minus(duration));
assertTrue(CollectionUtils.isNotEmpty(attachments), "Attachments should not be empty");
assertEquals(1, attachments.size(), "Incorrect count of attachments");
attachments.stream().map(it -> null != it.getFileId() || null != it.getThumbnailId()).forEach(Assertions::assertTrue);
attachments.stream().map(Attachment::getFileSize).forEach(size -> assertEquals(1024, size));
}
use of com.epam.ta.reportportal.entity.attachment.Attachment in project commons-dao by reportportal.
the class LogRepositoryTest method findAllWithAttachmentOfRetries.
@Test
void findAllWithAttachmentOfRetries() {
Filter logWithAttachmentsFilter = Filter.builder().withTarget(Log.class).withCondition(FilterCondition.builder().withCondition(Condition.EXISTS).withSearchCriteria(CRITERIA_LOG_BINARY_CONTENT).withValue("1").build()).withCondition(new CompositeFilterCondition(Lists.newArrayList(FilterCondition.builder().eq(CRITERIA_RETRY_PARENT_LAUNCH_ID, String.valueOf(1L)).build(), FilterCondition.builder().eq(CRITERIA_ITEM_LAUNCH_ID, String.valueOf(1L)).withOperator(Operator.OR).build()))).build();
Page<Log> logPage = logRepository.findByFilter(logWithAttachmentsFilter, PageRequest.of(0, 10));
List<Log> logs = logPage.getContent();
assertFalse(logs.isEmpty());
logs.forEach(log -> {
Attachment attachment = log.getAttachment();
assertNotNull(attachment);
assertNotNull(attachment.getId());
assertNotNull(attachment.getFileId());
assertNotNull(attachment.getContentType());
assertNotNull(attachment.getThumbnailId());
});
assertEquals(7, logs.size());
}
use of com.epam.ta.reportportal.entity.attachment.Attachment in project commons-dao by reportportal.
the class LogRepositoryTest method findAllWithAttachment.
@Test
void findAllWithAttachment() {
Filter logWithAttachmentsFilter = Filter.builder().withTarget(Log.class).withCondition(FilterCondition.builder().withCondition(Condition.EXISTS).withSearchCriteria(CRITERIA_LOG_BINARY_CONTENT).withValue("1").build()).build();
Page<Log> logPage = logRepository.findByFilter(logWithAttachmentsFilter, PageRequest.of(0, 10));
List<Log> logs = logPage.getContent();
assertFalse(logs.isEmpty());
logs.forEach(log -> {
Attachment attachment = log.getAttachment();
assertNotNull(attachment);
assertNotNull(attachment.getId());
assertNotNull(attachment.getFileId());
assertNotNull(attachment.getContentType());
assertNotNull(attachment.getThumbnailId());
});
assertEquals(10, logs.size());
}
Aggregations