use of com.synopsys.integration.alert.database.audit.AuditEntryEntity in project hub-alert by blackducksoftware.
the class NotificationAccessorTestIT method testFindAllWithSearch.
@Test
public void testFindAllWithSearch() {
NotificationEntity notificationContent = createNotificationContent();
notificationContent = notificationContentRepository.save(notificationContent);
PageRequest pageRequest = PageRequest.of(0, 10);
Page<AlertNotificationModel> all = notificationManager.findAllWithSearch(ChannelKeys.EMAIL.getUniversalKey(), pageRequest, false);
// Search term should not match anything in the saved notifications
assertTrue(all.isEmpty());
all = notificationManager.findAllWithSearch(NOTIFICATION_TYPE, pageRequest, false);
// Search term should match the notification type of the saved notification
assertFalse(all.isEmpty());
all = notificationManager.findAllWithSearch(NOTIFICATION_TYPE, pageRequest, true);
// Search term should match the notification type but it was never sent so no match
assertTrue(all.isEmpty());
OffsetDateTime now = DateUtils.createCurrentDateTimestamp();
AuditEntryEntity auditEntryEntity = new AuditEntryEntity(UUID.randomUUID(), now, now, AuditEntryStatus.PENDING.name(), null, null);
AuditEntryEntity saveAuditEntry = auditEntryRepository.save(auditEntryEntity);
AuditNotificationRelation auditNotificationRelation = new AuditNotificationRelation(saveAuditEntry.getId(), notificationContent.getId());
auditNotificationRepository.save(auditNotificationRelation);
all = notificationManager.findAllWithSearch(NOTIFICATION_TYPE, pageRequest, true);
// Search term should match the notification type and the notification was sent so we get a match
assertFalse(all.isEmpty());
}
Aggregations