Search in sources :

Example 6 with SimpleMessage

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

the class ProjectMessageSummarizerTest method summarizeProjectVersionStatusTest.

@Test
public void summarizeProjectVersionStatusTest() {
    ProjectOperation commonOperation = ProjectOperation.CREATE;
    ProjectMessage projectMessage = ProjectMessage.projectVersionStatusInfo(providerDetails, commonProject, commonProjectVersion, 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(2, simpleMessage.getDetails().size(), "Expected 2 LinkableItems. One for project the other for project-version.");
    assertTrue(simpleMessage.getDetails().contains(commonProject));
    assertTrue(simpleMessage.getDetails().contains(commonProjectVersion));
    assertTrue(simpleMessage.getSummary().contains(commonProjectVersion.getValue()));
    assertTrue(simpleMessage.getSummary().contains(ProjectMessageSummarizer.OP_PARTICIPLE_CREATED));
    assertTrue(simpleMessage.getDescription().contains(commonProjectVersion.getValue()));
}
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)

Example 7 with SimpleMessage

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

the class JiraServerExternalConnectionTest method createMessage.

private ProviderMessageHolder createMessage() {
    ProviderDetails providerDetails = new ProviderDetails(1L, new LinkableItem("ProviderLabel", "ProviderName"));
    SimpleMessage simpleMessage = SimpleMessage.original(providerDetails, "Test Summary", "Test Description", List.of());
    return new ProviderMessageHolder(List.of(), List.of(simpleMessage));
}
Also used : LinkableItem(com.synopsys.integration.alert.common.message.model.LinkableItem) SimpleMessage(com.synopsys.integration.alert.processor.api.extract.model.SimpleMessage) ProviderDetails(com.synopsys.integration.alert.processor.api.extract.model.ProviderDetails) ProviderMessageHolder(com.synopsys.integration.alert.processor.api.extract.model.ProviderMessageHolder)

Example 8 with SimpleMessage

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

the class IssueTrackerModelExtractor method extractSimpleMessageIssueModels.

public final IssueTrackerModelHolder<T> extractSimpleMessageIssueModels(List<SimpleMessage> simpleMessages, String jobName) {
    List<IssueCreationModel> simpleMessageIssueCreationModels = new ArrayList<>(simpleMessages.size());
    for (SimpleMessage simpleMessage : simpleMessages) {
        IssueCreationModel simpleMessageIssueCreationModel = issueTrackerSimpleMessageConverter.convertToIssueCreationModel(simpleMessage, jobName);
        simpleMessageIssueCreationModels.add(simpleMessageIssueCreationModel);
    }
    return new IssueTrackerModelHolder<>(simpleMessageIssueCreationModels, List.of(), List.of());
}
Also used : IssueCreationModel(com.synopsys.integration.alert.api.channel.issue.model.IssueCreationModel) IssueTrackerModelHolder(com.synopsys.integration.alert.api.channel.issue.model.IssueTrackerModelHolder) SimpleMessage(com.synopsys.integration.alert.processor.api.extract.model.SimpleMessage) ArrayList(java.util.ArrayList)

Example 9 with SimpleMessage

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

the class LicenseLimitNotificationMessageExtractor method extract.

@Override
protected ProviderMessageHolder extract(NotificationContentWrapper notificationContentWrapper, LicenseLimitNotificationContent notificationContent) {
    AlertNotificationModel alertNotificationModel = notificationContentWrapper.getAlertNotificationModel();
    LinkableItem providerItem = new LinkableItem(blackDuckProviderKey.getDisplayName(), alertNotificationModel.getProviderConfigName());
    ProviderDetails providerDetails = new ProviderDetails(alertNotificationModel.getProviderConfigId(), providerItem);
    String summary = "License Limit Event";
    List<LinkableItem> details = new LinkedList<>();
    String marketingPageUrl = notificationContent.getMarketingPageUrl();
    if (StringUtils.isNotBlank(marketingPageUrl)) {
        LinkableItem marketingDetail = new LinkableItem("Marketing Page", "Visit", marketingPageUrl);
        details.add(marketingDetail);
    }
    Long usedCodeSize = notificationContent.getUsedCodeSize();
    if (null != usedCodeSize) {
        LinkableItem usedCodeSizeDetail = new LinkableItem("Used Code Size", usedCodeSize.toString());
        details.add(usedCodeSizeDetail);
    }
    Long hardLimit = notificationContent.getHardLimit();
    if (null != hardLimit) {
        LinkableItem hardLimitDetail = new LinkableItem("Hard Limit", hardLimit.toString());
        details.add(hardLimitDetail);
    }
    Long softLimit = notificationContent.getSoftLimit();
    if (null != softLimit) {
        LinkableItem softLimitDetail = new LinkableItem("Soft Limit", softLimit.toString());
        details.add(softLimitDetail);
    }
    SimpleMessage licenseLimitMessage = SimpleMessage.original(providerDetails, summary, notificationContent.getMessage(), details);
    return new ProviderMessageHolder(List.of(), List.of(licenseLimitMessage));
}
Also used : AlertNotificationModel(com.synopsys.integration.alert.common.rest.model.AlertNotificationModel) LinkableItem(com.synopsys.integration.alert.common.message.model.LinkableItem) SimpleMessage(com.synopsys.integration.alert.processor.api.extract.model.SimpleMessage) ProviderDetails(com.synopsys.integration.alert.processor.api.extract.model.ProviderDetails) ProviderMessageHolder(com.synopsys.integration.alert.processor.api.extract.model.ProviderMessageHolder) LinkedList(java.util.LinkedList)

Example 10 with SimpleMessage

use of com.synopsys.integration.alert.processor.api.extract.model.SimpleMessage 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)

Aggregations

SimpleMessage (com.synopsys.integration.alert.processor.api.extract.model.SimpleMessage)19 ProjectMessage (com.synopsys.integration.alert.processor.api.extract.model.project.ProjectMessage)11 Test (org.junit.jupiter.api.Test)11 LinkableItem (com.synopsys.integration.alert.common.message.model.LinkableItem)10 ProcessedProviderMessage (com.synopsys.integration.alert.processor.api.extract.model.ProcessedProviderMessage)10 ProviderDetails (com.synopsys.integration.alert.processor.api.extract.model.ProviderDetails)7 ProviderMessageHolder (com.synopsys.integration.alert.processor.api.extract.model.ProviderMessageHolder)6 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 MockChannelMessageFormatter (com.synopsys.integration.alert.api.channel.convert.mock.MockChannelMessageFormatter)2 IssueCreationModel (com.synopsys.integration.alert.api.channel.issue.model.IssueCreationModel)2 AlertNotificationModel (com.synopsys.integration.alert.common.rest.model.AlertNotificationModel)2 ProcessedProviderMessageHolder (com.synopsys.integration.alert.processor.api.extract.model.ProcessedProviderMessageHolder)2 NotificationContentWrapper (com.synopsys.integration.alert.processor.api.filter.NotificationContentWrapper)2 ArrayList (java.util.ArrayList)2 MockIssueTrackerMessageFormatter (com.synopsys.integration.alert.api.channel.issue.convert.mock.MockIssueTrackerMessageFormatter)1 IssueTrackerModelHolder (com.synopsys.integration.alert.api.channel.issue.model.IssueTrackerModelHolder)1 RuleViolationUniquePolicyNotificationContent (com.synopsys.integration.alert.provider.blackduck.processor.model.RuleViolationUniquePolicyNotificationContent)1 LicenseLimitNotificationContent (com.synopsys.integration.blackduck.api.manual.component.LicenseLimitNotificationContent)1