use of com.synopsys.integration.alert.common.rest.model.AlertNotificationModel in project hub-alert by blackducksoftware.
the class NotificationAccessorTestIT method findByCreatedAtBefore.
@Test
public void findByCreatedAtBefore() {
OffsetDateTime time = DateUtils.createCurrentDateTimestamp();
OffsetDateTime searchDate = time.plusHours(1);
OffsetDateTime createdAt = time.minusHours(5);
AlertNotificationModel entity = createNotificationModel(createdAt);
notificationManager.saveAllNotifications(List.of(entity));
OffsetDateTime createdAtLaterThanSearch = time.plusHours(3);
entity = createNotificationModel(createdAtLaterThanSearch);
notificationManager.saveAllNotifications(List.of(entity));
List<AlertNotificationModel> foundList = notificationManager.findByCreatedAtBefore(searchDate);
assertEquals(1, foundList.size());
searchDate = time.minusHours(6);
foundList = notificationManager.findByCreatedAtBefore(searchDate);
assertTrue(foundList.isEmpty());
}
use of com.synopsys.integration.alert.common.rest.model.AlertNotificationModel in project hub-alert by blackducksoftware.
the class NotificationAccessorTestIT method testFindAll.
@Test
public void testFindAll() {
NotificationEntity notificationContent = createNotificationContent();
notificationContent = notificationContentRepository.save(notificationContent);
PageRequest pageRequest = PageRequest.of(0, 10);
Page<AlertNotificationModel> all = notificationManager.findAll(pageRequest, false);
assertFalse(all.isEmpty());
all = notificationManager.findAll(pageRequest, true);
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.findAll(pageRequest, true);
assertFalse(all.isEmpty());
}
use of com.synopsys.integration.alert.common.rest.model.AlertNotificationModel in project hub-alert by blackducksoftware.
the class NotificationAccessorTestIT method testFindByIdsInvalidIds.
@Test
public void testFindByIdsInvalidIds() {
AlertNotificationModel model = createNotificationModel();
model = notificationManager.saveAllNotifications(List.of(model)).get(0);
List<Long> notificationIds = Arrays.asList(model.getId() + 10, model.getId() + 20, model.getId() + 30);
List<AlertNotificationModel> notificationModelList = notificationManager.findByIds(notificationIds);
assertTrue(notificationModelList.isEmpty());
}
use of com.synopsys.integration.alert.common.rest.model.AlertNotificationModel in project hub-alert by blackducksoftware.
the class NotificationAccessorTestIT method findByCreatedAtBetween.
@Test
public void findByCreatedAtBetween() {
OffsetDateTime time = DateUtils.createCurrentDateTimestamp();
OffsetDateTime startDate = time.minusHours(1);
OffsetDateTime endDate = time.plusHours(1);
OffsetDateTime createdAt = time.minusHours(3);
AlertNotificationModel entity = createNotificationModel(createdAt);
notificationManager.saveAllNotifications(List.of(entity));
createdAt = time.plusMinutes(1);
AlertNotificationModel entityToFind1 = createNotificationModel(createdAt);
createdAt = time.plusMinutes(5);
AlertNotificationModel entityToFind2 = createNotificationModel(createdAt);
createdAt = time.plusHours(3);
entity = createNotificationModel(createdAt);
notificationManager.saveAllNotifications(List.of(entity));
notificationManager.saveAllNotifications(List.of(entityToFind1));
notificationManager.saveAllNotifications(List.of(entityToFind2));
List<AlertNotificationModel> foundList = notificationManager.findByCreatedAtBetween(startDate, endDate, AlertPagedModel.DEFAULT_PAGE_NUMBER, AlertPagedModel.DEFAULT_PAGE_SIZE).getModels();
assertEquals(2, foundList.size());
assertNotificationModel(entityToFind1, foundList.get(0));
assertNotificationModel(entityToFind2, foundList.get(1));
}
use of com.synopsys.integration.alert.common.rest.model.AlertNotificationModel in project hub-alert by blackducksoftware.
the class NotificationAccessorTestIT method testFindByIds.
@Test
public void testFindByIds() {
AlertNotificationModel notification = createNotificationModel();
List<AlertNotificationModel> savedModels = notificationManager.saveAllNotifications(List.of(notification));
List<Long> notificationIds = savedModels.stream().map(AlertNotificationModel::getId).collect(Collectors.toList());
List<AlertNotificationModel> notificationList = notificationManager.findByIds(notificationIds);
assertEquals(1, notificationList.size());
}
Aggregations