use of com.synopsys.integration.alert.common.rest.model.AlertNotificationModel 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());
}
use of com.synopsys.integration.alert.common.rest.model.AlertNotificationModel in project hub-alert by blackducksoftware.
the class NotificationAccessorTestIT method findByCreatedAtBetweenInvalidDate.
@Test
public void findByCreatedAtBetweenInvalidDate() {
OffsetDateTime time = DateUtils.createCurrentDateTimestamp();
OffsetDateTime startDate = time.minusHours(1);
OffsetDateTime endDate = time.plusHours(1);
OffsetDateTime createdAtEarlier = time.minusHours(5);
AlertNotificationModel entity = createNotificationModel(createdAtEarlier);
notificationManager.saveAllNotifications(List.of(entity));
OffsetDateTime createdAtLater = time.plusHours(3);
entity = createNotificationModel(createdAtLater);
notificationManager.saveAllNotifications(List.of(entity));
List<AlertNotificationModel> foundList = notificationManager.findByCreatedAtBetween(startDate, endDate, AlertPagedModel.DEFAULT_PAGE_NUMBER, AlertPagedModel.DEFAULT_PAGE_SIZE).getModels();
assertTrue(foundList.isEmpty());
}
use of com.synopsys.integration.alert.common.rest.model.AlertNotificationModel in project hub-alert by blackducksoftware.
the class NotificationAccessorTestIT method testFindAllWithSearchEmpty.
@Test
public void testFindAllWithSearchEmpty() {
PageRequest pageRequest = PageRequest.of(0, 10);
Page<AlertNotificationModel> all = notificationManager.findAllWithSearch(ChannelKeys.EMAIL.getUniversalKey(), pageRequest, false);
assertTrue(all.isEmpty());
all = notificationManager.findAllWithSearch(ChannelKeys.EMAIL.getUniversalKey(), pageRequest, true);
assertTrue(all.isEmpty());
}
use of com.synopsys.integration.alert.common.rest.model.AlertNotificationModel in project hub-alert by blackducksoftware.
the class NotificationAccessorTestIT method findByCreatedAtBeforeDayOffset.
@Test
public void findByCreatedAtBeforeDayOffset() {
OffsetDateTime time = DateUtils.createCurrentDateTimestamp();
OffsetDateTime createdAt = time.minusDays(5);
AlertNotificationModel entity = createNotificationModel(createdAt);
notificationManager.saveAllNotifications(List.of(entity));
OffsetDateTime createdAtLaterThanSearch = time.plusDays(3);
entity = createNotificationModel(createdAtLaterThanSearch);
notificationManager.saveAllNotifications(List.of(entity));
List<AlertNotificationModel> foundList = notificationManager.findByCreatedAtBeforeDayOffset(2);
assertEquals(1, foundList.size());
foundList = notificationManager.findByCreatedAtBeforeDayOffset(6);
assertTrue(foundList.isEmpty());
}
use of com.synopsys.integration.alert.common.rest.model.AlertNotificationModel in project hub-alert by blackducksoftware.
the class NotificationAccessorTestIT method testFindAllEmpty.
@Test
public void testFindAllEmpty() {
PageRequest pageRequest = PageRequest.of(0, 10);
Page<AlertNotificationModel> all = notificationManager.findAll(pageRequest, false);
assertTrue(all.isEmpty());
all = notificationManager.findAll(pageRequest, true);
assertTrue(all.isEmpty());
}
Aggregations