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));
}
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());
}
}
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");
}
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());
}
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)");
}
Aggregations