Search in sources :

Example 6 with ProcessedProviderMessageHolder

use of com.synopsys.integration.alert.processor.api.extract.model.ProcessedProviderMessageHolder in project hub-alert by blackducksoftware.

the class NotificationContentProcessorTest method processNotificationContentDefaultTest.

@Test
public void processNotificationContentDefaultTest() {
    // Create a NotificationContentWrapper
    AlertNotificationModel notificationModel = createNotification(NotificationType.RULE_VIOLATION.name());
    RuleViolationUniquePolicyNotificationContent notificationContent = blackDuckResponseTestUtility.createRuleViolationUniquePolicyNotificationContent(projectName, projectVersionName);
    NotificationContentWrapper notificationContentWrapper = new NotificationContentWrapper(notificationModel, notificationContent, RuleViolationUniquePolicyNotificationContent.class);
    // Run the test
    ProcessedProviderMessageHolder processedProviderMessageHolder = notificationContentProcessor.processNotificationContent(ProcessingType.DEFAULT, List.of(notificationContentWrapper));
    runProjectMessageAssertions(processedProviderMessageHolder, projectName, projectVersionName);
}
Also used : AlertNotificationModel(com.synopsys.integration.alert.common.rest.model.AlertNotificationModel) ProcessedProviderMessageHolder(com.synopsys.integration.alert.processor.api.extract.model.ProcessedProviderMessageHolder) RuleViolationUniquePolicyNotificationContent(com.synopsys.integration.alert.provider.blackduck.processor.model.RuleViolationUniquePolicyNotificationContent) NotificationContentWrapper(com.synopsys.integration.alert.processor.api.filter.NotificationContentWrapper) Test(org.junit.jupiter.api.Test)

Example 7 with ProcessedProviderMessageHolder

use of com.synopsys.integration.alert.processor.api.extract.model.ProcessedProviderMessageHolder in project hub-alert by blackducksoftware.

the class NotificationContentProcessorTest method processNotificationContentDigestTest.

@Test
public void processNotificationContentDigestTest() {
    AlertNotificationModel notificationModel = createNotification(NotificationType.RULE_VIOLATION.name());
    RuleViolationUniquePolicyNotificationContent notificationContent = blackDuckResponseTestUtility.createRuleViolationUniquePolicyNotificationContent(projectName, projectVersionName);
    NotificationContentWrapper notificationContentWrapper1 = new NotificationContentWrapper(notificationModel, notificationContent, RuleViolationUniquePolicyNotificationContent.class);
    NotificationContentWrapper notificationContentWrapper2 = new NotificationContentWrapper(notificationModel, notificationContent, RuleViolationUniquePolicyNotificationContent.class);
    // When set to digest, the NotificationContentProcessor will combine duplicate duplicate messages created from the two NotificationContentWrappers to a single message
    ProcessedProviderMessageHolder processedProviderMessageHolder = notificationContentProcessor.processNotificationContent(ProcessingType.DIGEST, List.of(notificationContentWrapper1, notificationContentWrapper2));
    runProjectMessageAssertions(processedProviderMessageHolder, projectName, projectVersionName);
}
Also used : AlertNotificationModel(com.synopsys.integration.alert.common.rest.model.AlertNotificationModel) ProcessedProviderMessageHolder(com.synopsys.integration.alert.processor.api.extract.model.ProcessedProviderMessageHolder) RuleViolationUniquePolicyNotificationContent(com.synopsys.integration.alert.provider.blackduck.processor.model.RuleViolationUniquePolicyNotificationContent) NotificationContentWrapper(com.synopsys.integration.alert.processor.api.filter.NotificationContentWrapper) Test(org.junit.jupiter.api.Test)

Example 8 with ProcessedProviderMessageHolder

use of com.synopsys.integration.alert.processor.api.extract.model.ProcessedProviderMessageHolder in project hub-alert by blackducksoftware.

the class ProviderMessageDistributorTest method distributeTest.

@Test
public void distributeTest() {
    MockProcessingAuditAccessor processingAuditAccessor = new MockProcessingAuditAccessor();
    EventManager eventManager = Mockito.mock(EventManager.class);
    ProcessedNotificationDetails processedNotificationDetails = new ProcessedNotificationDetails(uuid, slackChannelKey.getUniversalKey(), "JobName");
    ProcessedProviderMessageHolder processedMessageHolder = createProcessedProviderMessageHolder(2, 2);
    ProviderMessageDistributor providerMessageDistributor = new ProviderMessageDistributor(processingAuditAccessor, eventManager);
    providerMessageDistributor.distribute(processedNotificationDetails, processedMessageHolder);
    Mockito.verify(eventManager, Mockito.times(4)).sendEvent(Mockito.any());
}
Also used : MockProcessingAuditAccessor(com.synopsys.integration.alert.processor.api.MockProcessingAuditAccessor) EventManager(com.synopsys.integration.alert.api.event.EventManager) ProcessedProviderMessageHolder(com.synopsys.integration.alert.processor.api.extract.model.ProcessedProviderMessageHolder) Test(org.junit.jupiter.api.Test)

Example 9 with ProcessedProviderMessageHolder

use of com.synopsys.integration.alert.processor.api.extract.model.ProcessedProviderMessageHolder in project hub-alert by blackducksoftware.

the class ProviderMessageDistributorTest method createProcessedProviderMessageHolder.

private ProcessedProviderMessageHolder createProcessedProviderMessageHolder(int numberOfProjectMessages, int numberOfSimpleMessages) {
    List<ProcessedProviderMessage<ProjectMessage>> processedProjectMessages = new ArrayList<>();
    List<ProcessedProviderMessage<SimpleMessage>> processedSimpleMessages = new ArrayList<>();
    LinkableItem commonProject = new LinkableItem("Project", "Common Project");
    ProjectOperation commonOperation = ProjectOperation.CREATE;
    for (long i = 1; i < numberOfProjectMessages + 1; i++) {
        LinkableItem provider = new LinkableItem("Provider", "Provider " + i);
        ProviderDetails providerDetails = new ProviderDetails(i, provider);
        ProjectMessage projectMessage = ProjectMessage.projectStatusInfo(providerDetails, commonProject, commonOperation);
        ProcessedProviderMessage<ProjectMessage> processedProviderMessage = ProcessedProviderMessage.singleSource(i, projectMessage);
        processedProjectMessages.add(processedProviderMessage);
    }
    for (long i = 1; i < numberOfSimpleMessages + 1; i++) {
        LinkableItem provider = new LinkableItem("Details", "Detail " + i);
        ProviderDetails providerDetails = new ProviderDetails(i, provider);
        SimpleMessage simpleMessage = SimpleMessage.original(providerDetails, "Summary " + i, "Description " + i, List.of(commonProject));
        ProcessedProviderMessage<SimpleMessage> processedSimpleMessage = ProcessedProviderMessage.singleSource(i, simpleMessage);
        processedSimpleMessages.add(processedSimpleMessage);
    }
    return new ProcessedProviderMessageHolder(processedProjectMessages, processedSimpleMessages);
}
Also used : LinkableItem(com.synopsys.integration.alert.common.message.model.LinkableItem) ProcessedProviderMessageHolder(com.synopsys.integration.alert.processor.api.extract.model.ProcessedProviderMessageHolder) ProcessedProviderMessage(com.synopsys.integration.alert.processor.api.extract.model.ProcessedProviderMessage) SimpleMessage(com.synopsys.integration.alert.processor.api.extract.model.SimpleMessage) ArrayList(java.util.ArrayList) ProviderDetails(com.synopsys.integration.alert.processor.api.extract.model.ProviderDetails) ProjectMessage(com.synopsys.integration.alert.processor.api.extract.model.project.ProjectMessage) ProjectOperation(com.synopsys.integration.alert.processor.api.extract.model.project.ProjectOperation)

Example 10 with ProcessedProviderMessageHolder

use of com.synopsys.integration.alert.processor.api.extract.model.ProcessedProviderMessageHolder in project hub-alert by blackducksoftware.

the class NotificationProcessor method processAndDistribute.

private void processAndDistribute(FilteredJobNotificationWrapper jobNotificationWrapper) {
    List<NotificationContentWrapper> filteredNotifications = jobNotificationWrapper.getJobNotifications();
    ProcessedNotificationDetails processedNotificationDetails = new ProcessedNotificationDetails(jobNotificationWrapper.getJobId(), jobNotificationWrapper.getChannelName(), jobNotificationWrapper.getJobName());
    ProcessedProviderMessageHolder processedMessageHolder = notificationContentProcessor.processNotificationContent(jobNotificationWrapper.getProcessingType(), filteredNotifications);
    providerMessageDistributor.distribute(processedNotificationDetails, processedMessageHolder);
}
Also used : ProcessedProviderMessageHolder(com.synopsys.integration.alert.processor.api.extract.model.ProcessedProviderMessageHolder) ProcessedNotificationDetails(com.synopsys.integration.alert.processor.api.distribute.ProcessedNotificationDetails) NotificationContentWrapper(com.synopsys.integration.alert.processor.api.filter.NotificationContentWrapper)

Aggregations

ProcessedProviderMessageHolder (com.synopsys.integration.alert.processor.api.extract.model.ProcessedProviderMessageHolder)10 NotificationContentWrapper (com.synopsys.integration.alert.processor.api.filter.NotificationContentWrapper)5 Test (org.junit.jupiter.api.Test)5 AlertNotificationModel (com.synopsys.integration.alert.common.rest.model.AlertNotificationModel)3 RuleViolationUniquePolicyNotificationContent (com.synopsys.integration.alert.provider.blackduck.processor.model.RuleViolationUniquePolicyNotificationContent)3 EventManager (com.synopsys.integration.alert.api.event.EventManager)2 MockProcessingAuditAccessor (com.synopsys.integration.alert.processor.api.MockProcessingAuditAccessor)2 ProcessedProviderMessage (com.synopsys.integration.alert.processor.api.extract.model.ProcessedProviderMessage)2 SimpleMessage (com.synopsys.integration.alert.processor.api.extract.model.SimpleMessage)2 ProjectMessage (com.synopsys.integration.alert.processor.api.extract.model.project.ProjectMessage)2 LinkableItem (com.synopsys.integration.alert.common.message.model.LinkableItem)1 ChannelKey (com.synopsys.integration.alert.descriptor.api.model.ChannelKey)1 ProcessedNotificationDetails (com.synopsys.integration.alert.processor.api.distribute.ProcessedNotificationDetails)1 ProviderDetails (com.synopsys.integration.alert.processor.api.extract.model.ProviderDetails)1 ProviderMessageHolder (com.synopsys.integration.alert.processor.api.extract.model.ProviderMessageHolder)1 ProjectOperation (com.synopsys.integration.alert.processor.api.extract.model.project.ProjectOperation)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1