Search in sources :

Example 11 with SimpleMessage

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

the class DistributionChannelMessageTestAction method createTestMessageHolder.

private ProviderMessageHolder createTestMessageHolder(DistributionJobModel testJobModel, String summary, String message) {
    // TODO determine if it's worth it to make a DB call to resolve the provider
    LinkableItem providerItem = new LinkableItem("Provider Label", "Provider Config Name");
    ProviderDetails providerDetails = new ProviderDetails(testJobModel.getBlackDuckGlobalConfigId(), providerItem);
    SimpleMessage testMessage = SimpleMessage.original(providerDetails, summary, message, List.of());
    return new ProviderMessageHolder(List.of(), List.of(testMessage));
}
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 12 with SimpleMessage

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

the class AbstractChannelMessageConverterTest method convertToChannelMessagesTest.

@Test
public void convertToChannelMessagesTest() {
    MockChannelMessageFormatter mockChannelMessageFormatter = new MockChannelMessageFormatter(Integer.MAX_VALUE);
    MockChannelMessageConverter mockChannelMessageConverter = new MockChannelMessageConverter(mockChannelMessageFormatter);
    MockDistributionJobDetailsModel jobDetails = new MockDistributionJobDetailsModel(UUID.randomUUID());
    ProviderDetails providerDetails = new ProviderDetails(0L, new LinkableItem("Provider", "Black Duck"));
    ProjectMessage projectCreateMessage = ProjectMessage.projectStatusInfo(providerDetails, new LinkableItem("Project", "A project"), ProjectOperation.CREATE);
    SimpleMessage simpleMessage = SimpleMessage.original(providerDetails, "Summary", "Description", List.of());
    ProviderMessageHolder providerMessageHolder = new ProviderMessageHolder(List.of(projectCreateMessage), List.of(simpleMessage));
    List<MockOutputModel> mockOutputModels = mockChannelMessageConverter.convertToChannelMessages(jobDetails, providerMessageHolder, "jobName");
    assertEquals(2, mockOutputModels.size());
    for (MockOutputModel mockOutputModel : mockOutputModels) {
        assertEquals(1, mockOutputModel.getMessagePieces().size());
    }
}
Also used : LinkableItem(com.synopsys.integration.alert.common.message.model.LinkableItem) ProjectMessage(com.synopsys.integration.alert.processor.api.extract.model.project.ProjectMessage) SimpleMessage(com.synopsys.integration.alert.processor.api.extract.model.SimpleMessage) MockChannelMessageFormatter(com.synopsys.integration.alert.api.channel.convert.mock.MockChannelMessageFormatter) ProviderDetails(com.synopsys.integration.alert.processor.api.extract.model.ProviderDetails) ProviderMessageHolder(com.synopsys.integration.alert.processor.api.extract.model.ProviderMessageHolder) Test(org.junit.jupiter.api.Test)

Example 13 with SimpleMessage

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

the class SimpleMessageConverterTest method callConvertToFormattedMessageChunks.

private List<String> callConvertToFormattedMessageChunks() {
    ProviderDetails providerDetails = new ProviderDetails(0L, new LinkableItem("Provider", "The provider name"));
    LinkableItem detail1 = new LinkableItem("Detail", "The first detail (unlinked)");
    LinkableItem detail2 = new LinkableItem("Detail Prime", "The second detail (linked)", "https://a-hub-url");
    SimpleMessage simpleMessage = SimpleMessage.original(providerDetails, "The Summary", "The Description", List.of(detail1, detail2));
    MockChannelMessageFormatter formatter = new MockChannelMessageFormatter(Integer.MAX_VALUE);
    SimpleMessageConverter simpleMessageConverter = new SimpleMessageConverter(formatter);
    return simpleMessageConverter.convertToFormattedMessageChunks(simpleMessage, "jobName");
}
Also used : LinkableItem(com.synopsys.integration.alert.common.message.model.LinkableItem) SimpleMessage(com.synopsys.integration.alert.processor.api.extract.model.SimpleMessage) MockChannelMessageFormatter(com.synopsys.integration.alert.api.channel.convert.mock.MockChannelMessageFormatter) ProviderDetails(com.synopsys.integration.alert.processor.api.extract.model.ProviderDetails)

Example 14 with SimpleMessage

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

the class LicenseLimitNotificationMessageExtractorTest method extractTest.

@Test
public void extractTest() {
    LicenseLimitNotificationContent notificationContentComponent = createLicenseLimitNotificationContent();
    NotificationContentWrapper notificationContentWrapper = createNotificationContentWrapper(notificationContentComponent);
    LicenseLimitNotificationMessageExtractor licenseLimitNotificationMessageExtractor = new LicenseLimitNotificationMessageExtractor(blackDuckProviderKey);
    ProviderMessageHolder providerMessageHolder = licenseLimitNotificationMessageExtractor.extract(notificationContentWrapper, notificationContentComponent);
    assertEquals(0, providerMessageHolder.getProjectMessages().size());
    assertEquals(1, providerMessageHolder.getSimpleMessages().size());
    SimpleMessage simpleMessage = providerMessageHolder.getSimpleMessages().get(0);
    assertEquals(summary, simpleMessage.getSummary());
    assertEquals(description, simpleMessage.getDescription());
    assertEquals(4, simpleMessage.getDetails().size());
}
Also used : LicenseLimitNotificationContent(com.synopsys.integration.blackduck.api.manual.component.LicenseLimitNotificationContent) SimpleMessage(com.synopsys.integration.alert.processor.api.extract.model.SimpleMessage) ProviderMessageHolder(com.synopsys.integration.alert.processor.api.extract.model.ProviderMessageHolder) NotificationContentWrapper(com.synopsys.integration.alert.processor.api.filter.NotificationContentWrapper) Test(org.junit.jupiter.api.Test)

Example 15 with SimpleMessage

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

the class IssueTrackerModelExtractorTest method extractSimpleMessageIssueModelsTest.

@Test
public void extractSimpleMessageIssueModelsTest() {
    String testSummary = "A test summary";
    String testDescription = "A description for the test";
    LinkableItem additionalDetail = new LinkableItem("A label", "A value");
    MockIssueTrackerMessageFormatter formatter = MockIssueTrackerMessageFormatter.withIntegerMaxValueLength();
    IssueTrackerModelExtractor<String> extractor = new IssueTrackerModelExtractor<>(formatter, null);
    SimpleMessage simpleMessage = SimpleMessage.original(PROVIDER_DETAILS, testSummary, testDescription, List.of(additionalDetail));
    IssueTrackerModelHolder<String> modelHolder = extractor.extractSimpleMessageIssueModels(List.of(simpleMessage), "jobName");
    List<IssueCreationModel> issueCreationModels = modelHolder.getIssueCreationModels();
    assertEquals(1, issueCreationModels.size());
    assertEquals(0, modelHolder.getIssueTransitionModels().size());
    assertEquals(0, modelHolder.getIssueCommentModels().size());
    IssueCreationModel issueCreationModel = issueCreationModels.get(0);
    assertEquals(PROVIDER_DETAILS.getProvider(), issueCreationModel.getProvider());
    assertTrue(issueCreationModel.getTitle().contains(testSummary), "Expected the issue title to contain the simple message's summary");
    assertTrue(issueCreationModel.getDescription().contains(testDescription), "Expected the issue description to contain the simple message's description");
    assertTrue(issueCreationModel.getDescription().contains(additionalDetail.getValue()), "Expected the issue description to contain the simple message's additional detail(s)");
}
Also used : LinkableItem(com.synopsys.integration.alert.common.message.model.LinkableItem) IssueCreationModel(com.synopsys.integration.alert.api.channel.issue.model.IssueCreationModel) SimpleMessage(com.synopsys.integration.alert.processor.api.extract.model.SimpleMessage) MockIssueTrackerMessageFormatter(com.synopsys.integration.alert.api.channel.issue.convert.mock.MockIssueTrackerMessageFormatter) 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