use of com.blackducksoftware.integration.hub.alert.digest.model.ItemData in project hub-alert by blackducksoftware.
the class SlackChannelTestIT method createCategoryData.
private CategoryData createCategoryData() {
final Map<String, Object> itemDataDataSet = new HashMap<>();
itemDataDataSet.put(ProjectDataFactory.VULNERABILITY_COUNT_KEY_ADDED, 1);
itemDataDataSet.put(ProjectDataFactory.VULNERABILITY_COUNT_KEY_UPDATED, 1);
itemDataDataSet.put(ProjectDataFactory.VULNERABILITY_COUNT_KEY_DELETED, 1);
final CategoryData categoryData = new CategoryData("key", Arrays.asList(new ItemData(itemDataDataSet)), 0);
return categoryData;
}
use of com.blackducksoftware.integration.hub.alert.digest.model.ItemData in project hub-alert by blackducksoftware.
the class SlackChannel method createHtmlMessage.
private String createHtmlMessage(final ProjectData projectData) {
final StringBuilder messageBuilder = new StringBuilder();
messageBuilder.append(projectData.getProjectName());
messageBuilder.append(" > ");
messageBuilder.append(projectData.getProjectVersion());
messageBuilder.append(System.lineSeparator());
final Map<NotificationCategoryEnum, CategoryData> categoryMap = projectData.getCategoryMap();
if (categoryMap != null) {
for (final NotificationCategoryEnum category : NotificationCategoryEnum.values()) {
final CategoryData data = categoryMap.get(category);
if (data != null) {
messageBuilder.append("- - - - - - - - - - - - - - - - - - - -");
messageBuilder.append(System.lineSeparator());
messageBuilder.append("Type: ");
messageBuilder.append(data.getCategoryKey());
messageBuilder.append(System.lineSeparator());
messageBuilder.append("Number of Changes: ");
messageBuilder.append(data.getItemCount());
for (final ItemData item : data.getItemList()) {
messageBuilder.append(System.lineSeparator());
final Map<String, Object> dataSet = item.getDataSet();
final String ruleKey = ItemTypeEnum.RULE.toString();
if (dataSet.containsKey(ruleKey) && StringUtils.isNotBlank(dataSet.get(ruleKey).toString())) {
messageBuilder.append("Rule: " + dataSet.get(ItemTypeEnum.RULE.toString()));
messageBuilder.append(System.lineSeparator());
}
if (dataSet.containsKey(ProjectDataFactory.VULNERABILITY_COUNT_KEY_ADDED)) {
final Number numericValue = (Number) dataSet.get(ProjectDataFactory.VULNERABILITY_COUNT_KEY_ADDED);
messageBuilder.append("Vulnerability Count Added: " + numericValue.intValue());
messageBuilder.append(System.lineSeparator());
}
if (dataSet.containsKey(ProjectDataFactory.VULNERABILITY_COUNT_KEY_UPDATED)) {
final Number numericValue = (Number) dataSet.get(ProjectDataFactory.VULNERABILITY_COUNT_KEY_UPDATED);
messageBuilder.append("Vulnerability Count Updated: " + numericValue.intValue());
messageBuilder.append(System.lineSeparator());
}
if (dataSet.containsKey(ProjectDataFactory.VULNERABILITY_COUNT_KEY_DELETED)) {
final Number numericValue = (Number) dataSet.get(ProjectDataFactory.VULNERABILITY_COUNT_KEY_DELETED);
messageBuilder.append("Vulnerability Count Deleted: " + numericValue.intValue());
messageBuilder.append(System.lineSeparator());
}
messageBuilder.append("Component: " + dataSet.get(ItemTypeEnum.COMPONENT.toString()));
messageBuilder.append(" [" + dataSet.get(ItemTypeEnum.VERSION.toString()) + "]");
}
messageBuilder.append(System.lineSeparator());
}
}
} else {
messageBuilder.append(" A notification was received, but it was empty.");
}
return messageBuilder.toString();
}
Aggregations