Search in sources :

Example 6 with ProcessedProviderMessage

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

the class NotificationContentProcessorTest method processNotificationContentSummaryTest.

@Test
public void processNotificationContentSummaryTest() {
    AlertNotificationModel notificationModel = createNotification(NotificationType.RULE_VIOLATION.name());
    RuleViolationUniquePolicyNotificationContent notificationContent = blackDuckResponseTestUtility.createRuleViolationUniquePolicyNotificationContent(projectName, projectVersionName);
    NotificationContentWrapper notificationContentWrapper1 = new NotificationContentWrapper(notificationModel, notificationContent, RuleViolationUniquePolicyNotificationContent.class);
    // When set to summary, project messages will be summarized into a SimpleMessage rather than ProjectMessage
    ProcessedProviderMessageHolder processedProviderMessageHolder = notificationContentProcessor.processNotificationContent(ProcessingType.SUMMARY, List.of(notificationContentWrapper1));
    List<ProcessedProviderMessage<ProjectMessage>> processedProviderMessages = processedProviderMessageHolder.getProcessedProjectMessages();
    List<ProcessedProviderMessage<SimpleMessage>> processedSimpleMessages = processedProviderMessageHolder.getProcessedSimpleMessages();
    assertTrue(processedProviderMessages.isEmpty());
    assertEquals(1, processedSimpleMessages.size());
    ProcessedProviderMessage<SimpleMessage> processedSimpleMessage = processedSimpleMessages.get(0);
    assertEquals(1, processedSimpleMessage.getNotificationIds().size());
    assertTrue(processedSimpleMessage.getNotificationIds().contains(notificationId));
    SimpleMessage simpleMessage = processedSimpleMessage.getProviderMessage();
    assertEquals(PROVIDER_DETAILS, simpleMessage.getProviderDetails());
    assertTrue(simpleMessage.getSource().isPresent());
    ProjectMessage sourceProjectMessage = simpleMessage.getSource().get();
    assertEquals(projectName, sourceProjectMessage.getProject().getValue());
    assertTrue(sourceProjectMessage.getProjectVersion().isPresent());
    assertEquals(projectVersionName, sourceProjectMessage.getProjectVersion().get().getValue());
}
Also used : AlertNotificationModel(com.synopsys.integration.alert.common.rest.model.AlertNotificationModel) ProjectMessage(com.synopsys.integration.alert.processor.api.extract.model.project.ProjectMessage) ProcessedProviderMessageHolder(com.synopsys.integration.alert.processor.api.extract.model.ProcessedProviderMessageHolder) ProcessedProviderMessage(com.synopsys.integration.alert.processor.api.extract.model.ProcessedProviderMessage) RuleViolationUniquePolicyNotificationContent(com.synopsys.integration.alert.provider.blackduck.processor.model.RuleViolationUniquePolicyNotificationContent) SimpleMessage(com.synopsys.integration.alert.processor.api.extract.model.SimpleMessage) NotificationContentWrapper(com.synopsys.integration.alert.processor.api.filter.NotificationContentWrapper) Test(org.junit.jupiter.api.Test)

Example 7 with ProcessedProviderMessage

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

the class NotificationContentProcessorTest method runProjectMessageAssertions.

private void runProjectMessageAssertions(ProcessedProviderMessageHolder processedProviderMessageHolder, String projectName, String projectVersionName) {
    List<ProcessedProviderMessage<ProjectMessage>> processedProjectMessages = processedProviderMessageHolder.getProcessedProjectMessages();
    List<ProcessedProviderMessage<SimpleMessage>> processedSimpleMessages = processedProviderMessageHolder.getProcessedSimpleMessages();
    assertTrue(processedSimpleMessages.isEmpty());
    assertEquals(1, processedProjectMessages.size());
    ProcessedProviderMessage<ProjectMessage> processedProjectMessage = processedProjectMessages.get(0);
    assertEquals(1, processedProjectMessage.getNotificationIds().size());
    assertTrue(processedProjectMessage.getNotificationIds().contains(notificationId));
    ProjectMessage projectMessage = processedProjectMessage.getProviderMessage();
    assertEquals(projectName, projectMessage.getProject().getValue());
    assertTrue(projectMessage.getProjectVersion().isPresent());
    assertEquals(projectVersionName, projectMessage.getProjectVersion().get().getValue());
    assertEquals(PROVIDER_DETAILS, projectMessage.getProviderDetails());
}
Also used : ProjectMessage(com.synopsys.integration.alert.processor.api.extract.model.project.ProjectMessage) ProcessedProviderMessage(com.synopsys.integration.alert.processor.api.extract.model.ProcessedProviderMessage)

Example 8 with ProcessedProviderMessage

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

the class ProjectMessageSummarizer method summarize.

public ProcessedProviderMessage<SimpleMessage> summarize(ProcessedProviderMessage<ProjectMessage> digestedProjectMessage) {
    ProjectMessage projectMessage = digestedProjectMessage.getProviderMessage();
    Pair<String, String> summaryAndDescription = constructSummaryAndDescription(projectMessage);
    List<LinkableItem> details = constructMessageDetails(projectMessage);
    SimpleMessage derivedSimpleMessage = SimpleMessage.derived(summaryAndDescription.getLeft(), summaryAndDescription.getRight(), details, projectMessage);
    return new ProcessedProviderMessage<>(digestedProjectMessage.getNotificationIds(), derivedSimpleMessage);
}
Also used : LinkableItem(com.synopsys.integration.alert.common.message.model.LinkableItem) ProjectMessage(com.synopsys.integration.alert.processor.api.extract.model.project.ProjectMessage) ProcessedProviderMessage(com.synopsys.integration.alert.processor.api.extract.model.ProcessedProviderMessage) SimpleMessage(com.synopsys.integration.alert.processor.api.extract.model.SimpleMessage)

Example 9 with ProcessedProviderMessage

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

the class ProjectMessageDigesterTest method createProcessedProviderMessage.

private ProcessedProviderMessage<ProjectMessage> createProcessedProviderMessage(String projectName, ProjectOperation operation) {
    LinkableItem project1 = new LinkableItem("proj", projectName, "https://" + projectName);
    ProjectMessage projectMessage1 = ProjectMessage.projectStatusInfo(PROVIDER_DETAILS, project1, operation);
    return new ProcessedProviderMessage<>(Set.of(), projectMessage1);
}
Also used : LinkableItem(com.synopsys.integration.alert.common.message.model.LinkableItem) ProjectMessage(com.synopsys.integration.alert.processor.api.extract.model.project.ProjectMessage) ProcessedProviderMessage(com.synopsys.integration.alert.processor.api.extract.model.ProcessedProviderMessage)

Example 10 with ProcessedProviderMessage

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

the class ProjectMessageSummarizerTest method summarizeProjectStatusDeletedTest.

@Test
public void summarizeProjectStatusDeletedTest() {
    ProjectOperation commonOperation = ProjectOperation.DELETE;
    ProjectMessage projectMessage = ProjectMessage.projectStatusInfo(providerDetails, commonProject, commonOperation);
    ProcessedProviderMessage<ProjectMessage> processedProviderMessage = new ProcessedProviderMessage<>(Set.of(1L), projectMessage);
    ProcessedProviderMessage<SimpleMessage> summarizedSimpleMessage = projectMessageSummarizer.summarize(processedProviderMessage);
    SimpleMessage simpleMessage = summarizedSimpleMessage.getProviderMessage();
    printSimpleMessage(simpleMessage);
    testProjectStatus(simpleMessage);
    assertEquals(1, simpleMessage.getDetails().size());
    assertTrue(simpleMessage.getDetails().contains(commonProject));
    assertTrue(simpleMessage.getSummary().contains(ProjectMessageSummarizer.OP_PARTICIPLE_DELETED));
}
Also used : ProjectMessage(com.synopsys.integration.alert.processor.api.extract.model.project.ProjectMessage) ProcessedProviderMessage(com.synopsys.integration.alert.processor.api.extract.model.ProcessedProviderMessage) SimpleMessage(com.synopsys.integration.alert.processor.api.extract.model.SimpleMessage) ProjectOperation(com.synopsys.integration.alert.processor.api.extract.model.project.ProjectOperation) Test(org.junit.jupiter.api.Test)

Aggregations

ProcessedProviderMessage (com.synopsys.integration.alert.processor.api.extract.model.ProcessedProviderMessage)12 ProjectMessage (com.synopsys.integration.alert.processor.api.extract.model.project.ProjectMessage)12 SimpleMessage (com.synopsys.integration.alert.processor.api.extract.model.SimpleMessage)10 Test (org.junit.jupiter.api.Test)8 LinkableItem (com.synopsys.integration.alert.common.message.model.LinkableItem)4 BomComponentDetails (com.synopsys.integration.alert.processor.api.extract.model.project.BomComponentDetails)4 ComponentConcern (com.synopsys.integration.alert.processor.api.extract.model.project.ComponentConcern)4 ProjectOperation (com.synopsys.integration.alert.processor.api.extract.model.project.ProjectOperation)4 ProcessedProviderMessageHolder (com.synopsys.integration.alert.processor.api.extract.model.ProcessedProviderMessageHolder)2 AlertNotificationModel (com.synopsys.integration.alert.common.rest.model.AlertNotificationModel)1 ProviderDetails (com.synopsys.integration.alert.processor.api.extract.model.ProviderDetails)1 NotificationContentWrapper (com.synopsys.integration.alert.processor.api.filter.NotificationContentWrapper)1 RuleViolationUniquePolicyNotificationContent (com.synopsys.integration.alert.provider.blackduck.processor.model.RuleViolationUniquePolicyNotificationContent)1 ArrayList (java.util.ArrayList)1