Search in sources :

Example 76 with AlertNotificationModel

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());
}
Also used : AlertNotificationModel(com.synopsys.integration.alert.common.rest.model.AlertNotificationModel) PageRequest(org.springframework.data.domain.PageRequest) OffsetDateTime(java.time.OffsetDateTime) AuditNotificationRelation(com.synopsys.integration.alert.database.audit.AuditNotificationRelation) AuditEntryEntity(com.synopsys.integration.alert.database.audit.AuditEntryEntity) NotificationEntity(com.synopsys.integration.alert.database.notification.NotificationEntity) AlertIntegrationTest(com.synopsys.integration.alert.util.AlertIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 77 with AlertNotificationModel

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());
}
Also used : AlertNotificationModel(com.synopsys.integration.alert.common.rest.model.AlertNotificationModel) OffsetDateTime(java.time.OffsetDateTime) AlertIntegrationTest(com.synopsys.integration.alert.util.AlertIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 78 with AlertNotificationModel

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());
}
Also used : AlertNotificationModel(com.synopsys.integration.alert.common.rest.model.AlertNotificationModel) PageRequest(org.springframework.data.domain.PageRequest) AlertIntegrationTest(com.synopsys.integration.alert.util.AlertIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 79 with AlertNotificationModel

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());
}
Also used : AlertNotificationModel(com.synopsys.integration.alert.common.rest.model.AlertNotificationModel) OffsetDateTime(java.time.OffsetDateTime) AlertIntegrationTest(com.synopsys.integration.alert.util.AlertIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 80 with AlertNotificationModel

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());
}
Also used : AlertNotificationModel(com.synopsys.integration.alert.common.rest.model.AlertNotificationModel) PageRequest(org.springframework.data.domain.PageRequest) AlertIntegrationTest(com.synopsys.integration.alert.util.AlertIntegrationTest) Test(org.junit.jupiter.api.Test)

Aggregations

AlertNotificationModel (com.synopsys.integration.alert.common.rest.model.AlertNotificationModel)94 Test (org.junit.jupiter.api.Test)62 DetailedNotificationContent (com.synopsys.integration.alert.processor.api.detail.DetailedNotificationContent)21 AlertIntegrationTest (com.synopsys.integration.alert.util.AlertIntegrationTest)20 NotificationEntity (com.synopsys.integration.alert.database.notification.NotificationEntity)16 PageRequest (org.springframework.data.domain.PageRequest)16 ConfigurationModelConfigurationAccessor (com.synopsys.integration.alert.common.persistence.accessor.ConfigurationModelConfigurationAccessor)14 NotificationContentRepository (com.synopsys.integration.alert.database.notification.NotificationContentRepository)14 OffsetDateTime (java.time.OffsetDateTime)13 ConfigurationModel (com.synopsys.integration.alert.common.persistence.model.ConfigurationModel)11 ArrayList (java.util.ArrayList)10 NotificationProcessor (com.synopsys.integration.alert.processor.api.NotificationProcessor)9 NotificationReceivedEvent (com.synopsys.integration.alert.api.event.NotificationReceivedEvent)7 FilteredDistributionJobResponseModel (com.synopsys.integration.alert.common.persistence.model.job.FilteredDistributionJobResponseModel)7 DefaultNotificationAccessor (com.synopsys.integration.alert.database.api.DefaultNotificationAccessor)6 NotificationDetailExtractionDelegator (com.synopsys.integration.alert.processor.api.detail.NotificationDetailExtractionDelegator)6 NotificationContentComponent (com.synopsys.integration.blackduck.api.manual.component.NotificationContentComponent)5 PageImpl (org.springframework.data.domain.PageImpl)5 TaskManager (com.synopsys.integration.alert.api.task.TaskManager)4 LinkableItem (com.synopsys.integration.alert.common.message.model.LinkableItem)4