use of com.synopsys.integration.alert.common.message.model.LinkableItem in project hub-alert by blackducksoftware.
the class ProjectMessageConverterTest method createComponentVulnerabilities.
private static ComponentVulnerabilities createComponentVulnerabilities() {
LinkableItem vuln1 = createComponentVulnerability("CVE-123");
LinkableItem vuln2 = createComponentVulnerability("CVE-135");
LinkableItem vuln3 = createComponentVulnerability("CVE-007");
LinkableItem vuln4 = createComponentVulnerability("CVE-099");
LinkableItem vuln5 = createComponentVulnerability("CVE-230");
return new ComponentVulnerabilities(List.of(vuln1), List.of(vuln3, vuln4), List.of(), List.of(vuln2, vuln5));
}
use of com.synopsys.integration.alert.common.message.model.LinkableItem 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));
}
use of com.synopsys.integration.alert.common.message.model.LinkableItem in project hub-alert by blackducksoftware.
the class SimpleMessageConverter method convertToFormattedMessageChunks.
@Override
public List<String> convertToFormattedMessageChunks(SimpleMessage simpleMessage, String jobName) {
ChunkedStringBuilder chunkedStringBuilder = new ChunkedStringBuilder(messageFormatter.getMaxMessageLength());
String nonBreakingSpace = messageFormatter.getNonBreakingSpace();
String jobLine = String.format("Job%sname:%s%s", nonBreakingSpace, nonBreakingSpace, jobName);
String formattedJob = messageFormatter.emphasize(jobLine);
appendSection(chunkedStringBuilder, formattedJob);
appendSection(chunkedStringBuilder, simpleMessage.getSummary());
appendSection(chunkedStringBuilder, simpleMessage.getDescription());
appendLinkableItem(chunkedStringBuilder, simpleMessage.getProvider(), false);
for (LinkableItem detail : simpleMessage.getDetails()) {
appendLinkableItem(chunkedStringBuilder, detail, false);
}
return chunkedStringBuilder.collectCurrentChunks();
}
use of com.synopsys.integration.alert.common.message.model.LinkableItem 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());
}
}
use of com.synopsys.integration.alert.common.message.model.LinkableItem 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");
}
Aggregations