use of com.synopsys.integration.alert.channel.email.attachment.compatibility.MessageContentGroup in project hub-alert by blackducksoftware.
the class MessageContentGroupCsvCreatorTest method createCsvStringTest.
@Test
public void createCsvStringTest() throws AlertException {
MessageContentGroup messageContentGroup = new MessageContentGroup();
ProviderMessageContent.Builder providerMessageBuilder = new ProviderMessageContent.Builder();
providerMessageBuilder.applyProvider("Example Provider", 1L, "Example Config");
providerMessageBuilder.applyTopic("Example Topic Name", "Example Topic Value");
ComponentItem.Builder componentItemBuilder = new ComponentItem.Builder();
componentItemBuilder.applyNotificationId(1L);
componentItemBuilder.applyOperation(ItemOperation.INFO);
componentItemBuilder.applyCategory("Example Category");
componentItemBuilder.applyComponentData("Example Component Name", "Example Component Value", "https://google.com");
componentItemBuilder.applySubComponent("Example SubComponent Name", "Example SubComponent Value", "https://google.com");
componentItemBuilder.applyCategoryItem("Example Category Item Name", "Example Category Item Value");
componentItemBuilder.applyCategoryGroupingAttribute("Example Category Grouping Attribute Name", "Example Category Grouping Attribute Value");
providerMessageBuilder.applyComponentItem(componentItemBuilder.build());
messageContentGroup.add(providerMessageBuilder.build());
MessageContentGroupCsvCreator messageContentGroupCsvCreator = new MessageContentGroupCsvCreator();
String csvString = messageContentGroupCsvCreator.createCsvString(messageContentGroup);
assertNotNull(csvString);
}
use of com.synopsys.integration.alert.channel.email.attachment.compatibility.MessageContentGroup in project hub-alert by blackducksoftware.
the class ProjectMessageToMessageContentGroupConversionUtils method toMessageContentGroup.
public static MessageContentGroup toMessageContentGroup(ProjectMessage projectMessage) {
ProviderMessageContent.Builder providerMessageContentBuilder = new ProviderMessageContent.Builder();
LinkableItem provider = projectMessage.getProvider();
providerMessageContentBuilder.applyProvider(provider.getLabel(), -1L, provider.getValue(), provider.getUrl().orElse(null));
LinkableItem project = projectMessage.getProject();
providerMessageContentBuilder.applyTopic(project.getLabel(), project.getValue(), project.getUrl().orElse(null));
Optional<LinkableItem> optionalProjectVersion = projectMessage.getProjectVersion();
if (optionalProjectVersion.isPresent()) {
LinkableItem projectVersion = optionalProjectVersion.get();
providerMessageContentBuilder.applySubTopic(projectVersion.getLabel(), projectVersion.getValue(), projectVersion.getUrl().orElse(null));
}
projectMessage.getOperation().map(ProjectMessageToMessageContentGroupConversionUtils::convertToItemOperation).ifPresent(providerMessageContentBuilder::applyAction);
MessageContentGroup messageContentGroup = new MessageContentGroup();
List<ComponentItem> componentItems = new LinkedList<>();
for (BomComponentDetails bomComponent : projectMessage.getBomComponents()) {
List<ComponentItem> bomComponentItems = convertToComponentItems(bomComponent);
componentItems.addAll(bomComponentItems);
}
providerMessageContentBuilder.applyAllComponentItems(componentItems);
try {
ProviderMessageContent providerMessageContent = providerMessageContentBuilder.build();
messageContentGroup.add(providerMessageContent);
} catch (AlertException e) {
// Ignore for feature parity
}
return messageContentGroup;
}
Aggregations