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