Search in sources :

Example 21 with AlertNotificationModel

use of com.synopsys.integration.alert.common.rest.model.AlertNotificationModel in project hub-alert by blackducksoftware.

the class NotificationAccessorTestIT method setNotificationsProcessedTest.

@Test
public void setNotificationsProcessedTest() {
    AlertNotificationModel notificationModel = createNotificationModel();
    List<AlertNotificationModel> savedModels = notificationManager.saveAllNotifications(List.of(notificationModel));
    notificationManager.setNotificationsProcessed(savedModels);
    assertEquals(1, savedModels.size());
    Optional<AlertNotificationModel> alertNotificationModelTest = notificationManager.findById(savedModels.get(0).getId());
    assertTrue(alertNotificationModelTest.isPresent());
    assertTrue(alertNotificationModelTest.get().getProcessed());
}
Also used : AlertNotificationModel(com.synopsys.integration.alert.common.rest.model.AlertNotificationModel) AlertIntegrationTest(com.synopsys.integration.alert.util.AlertIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 22 with AlertNotificationModel

use of com.synopsys.integration.alert.common.rest.model.AlertNotificationModel in project hub-alert by blackducksoftware.

the class JobNotificationFilterUtilsTest method doesNotificationApplyToJobProjectFailureTest.

@Test
public void doesNotificationApplyToJobProjectFailureTest() {
    NotificationContentComponent notificationContent = Mockito.mock(NotificationContentComponent.class);
    AlertNotificationModel notificationModel = createAlertNotificationModel(NotificationType.VULNERABILITY);
    DetailedNotificationContent detailedNotificationContent = DetailedNotificationContent.project(notificationModel, notificationContent, PROJECT_NAME, PROJECT_VERSION_NAME);
    FilteredDistributionJobResponseModel jobResponseModel = createFilteredDistributionJobResponseModel(List.of(NotificationType.VULNERABILITY.name()), List.of("projectDoesNotExist"), List.of(), List.of(), true, "", "");
    assertFalse(JobNotificationFilterUtils.doesNotificationApplyToJob(jobResponseModel, detailedNotificationContent));
}
Also used : AlertNotificationModel(com.synopsys.integration.alert.common.rest.model.AlertNotificationModel) FilteredDistributionJobResponseModel(com.synopsys.integration.alert.common.persistence.model.job.FilteredDistributionJobResponseModel) NotificationContentComponent(com.synopsys.integration.blackduck.api.manual.component.NotificationContentComponent) DetailedNotificationContent(com.synopsys.integration.alert.processor.api.detail.DetailedNotificationContent) Test(org.junit.jupiter.api.Test)

Example 23 with AlertNotificationModel

use of com.synopsys.integration.alert.common.rest.model.AlertNotificationModel in project hub-alert by blackducksoftware.

the class JobNotificationFilterUtilsTest method doesNotificationApplyToJobVulnerabilityTest.

@Test
public void doesNotificationApplyToJobVulnerabilityTest() {
    NotificationContentComponent notificationContent = Mockito.mock(NotificationContentComponent.class);
    AlertNotificationModel notificationModel = createAlertNotificationModel(NotificationType.VULNERABILITY);
    DetailedNotificationContent detailedNotificationContent = DetailedNotificationContent.vulnerability(notificationModel, notificationContent, PROJECT_NAME, PROJECT_VERSION_NAME, List.of("vuln"));
    FilteredDistributionJobResponseModel jobResponseModel = createFilteredDistributionJobResponseModel(List.of(NotificationType.VULNERABILITY.name()), List.of(), List.of(), List.of(), false, "", "");
    assertTrue(JobNotificationFilterUtils.doesNotificationApplyToJob(jobResponseModel, detailedNotificationContent));
    FilteredDistributionJobResponseModel jobResponseModelWithFailure = createFilteredDistributionJobResponseModel(List.of(NotificationType.VULNERABILITY.name()), List.of(), List.of(), List.of("vulnDoesNotExist"), false, "", "");
    assertFalse(JobNotificationFilterUtils.doesNotificationApplyToJob(jobResponseModelWithFailure, detailedNotificationContent));
}
Also used : AlertNotificationModel(com.synopsys.integration.alert.common.rest.model.AlertNotificationModel) FilteredDistributionJobResponseModel(com.synopsys.integration.alert.common.persistence.model.job.FilteredDistributionJobResponseModel) NotificationContentComponent(com.synopsys.integration.blackduck.api.manual.component.NotificationContentComponent) DetailedNotificationContent(com.synopsys.integration.alert.processor.api.detail.DetailedNotificationContent) Test(org.junit.jupiter.api.Test)

Example 24 with AlertNotificationModel

use of com.synopsys.integration.alert.common.rest.model.AlertNotificationModel in project hub-alert by blackducksoftware.

the class JobNotificationFilterUtilsTest method doesNotificationApplyToJobPolicyOverrideTest.

@Test
public void doesNotificationApplyToJobPolicyOverrideTest() {
    testPolicyNotifications(NotificationType.POLICY_OVERRIDE);
    testPolicyNotifications(NotificationType.RULE_VIOLATION);
    testPolicyNotifications(NotificationType.RULE_VIOLATION_CLEARED);
    NotificationContentComponent notificationContent = Mockito.mock(NotificationContentComponent.class);
    AlertNotificationModel notificationModel = createAlertNotificationModel(NotificationType.POLICY_OVERRIDE);
    DetailedNotificationContent detailedNotificationContent = DetailedNotificationContent.policy(notificationModel, notificationContent, PROJECT_NAME, PROJECT_VERSION_NAME, POLICY_NAME);
    FilteredDistributionJobResponseModel jobResponseModelWithFailure = createFilteredDistributionJobResponseModel(List.of(NotificationType.POLICY_OVERRIDE.name()), List.of(), List.of("policyDoesNotExist"), List.of(), false, "", "");
    assertFalse(JobNotificationFilterUtils.doesNotificationApplyToJob(jobResponseModelWithFailure, detailedNotificationContent));
}
Also used : AlertNotificationModel(com.synopsys.integration.alert.common.rest.model.AlertNotificationModel) FilteredDistributionJobResponseModel(com.synopsys.integration.alert.common.persistence.model.job.FilteredDistributionJobResponseModel) NotificationContentComponent(com.synopsys.integration.blackduck.api.manual.component.NotificationContentComponent) DetailedNotificationContent(com.synopsys.integration.alert.processor.api.detail.DetailedNotificationContent) Test(org.junit.jupiter.api.Test)

Example 25 with AlertNotificationModel

use of com.synopsys.integration.alert.common.rest.model.AlertNotificationModel in project hub-alert by blackducksoftware.

the class JobNotificationFilterUtilsTest method doesNotificationApplyToJobNotificationTypeFailureTest.

@Test
public void doesNotificationApplyToJobNotificationTypeFailureTest() {
    NotificationContentComponent notificationContent = Mockito.mock(NotificationContentComponent.class);
    AlertNotificationModel notificationModel = createAlertNotificationModel(NotificationType.VULNERABILITY);
    DetailedNotificationContent detailedNotificationContent = DetailedNotificationContent.vulnerability(notificationModel, notificationContent, PROJECT_NAME, PROJECT_VERSION_NAME, List.of("vuln"));
    FilteredDistributionJobResponseModel jobResponseModel = createFilteredDistributionJobResponseModel(List.of(NotificationType.POLICY_OVERRIDE.name()), List.of(), List.of(), List.of(), false, "", "");
    assertFalse(JobNotificationFilterUtils.doesNotificationApplyToJob(jobResponseModel, detailedNotificationContent));
}
Also used : AlertNotificationModel(com.synopsys.integration.alert.common.rest.model.AlertNotificationModel) FilteredDistributionJobResponseModel(com.synopsys.integration.alert.common.persistence.model.job.FilteredDistributionJobResponseModel) NotificationContentComponent(com.synopsys.integration.blackduck.api.manual.component.NotificationContentComponent) DetailedNotificationContent(com.synopsys.integration.alert.processor.api.detail.DetailedNotificationContent) 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