use of com.synopsys.integration.alert.processor.api.extract.model.ProviderDetails in project hub-alert by blackducksoftware.
the class AzureBoardsAlertIssuePropertiesManagerTest method verifyValidPolicyIssuesAreCreated.
@Test
public void verifyValidPolicyIssuesAreCreated() {
AzureBoardsAlertIssuePropertiesManager azureBoardsAlertIssuePropertiesManager = new AzureBoardsAlertIssuePropertiesManager();
LinkableItem providerConfig = new LinkableItem("providerConfigLabel", "providerConfigValue");
ProviderDetails providerDetails = new ProviderDetails(1L, providerConfig);
LinkableItem project = new LinkableItem("projectLabel", "projectValue");
LinkableItem projectVersion = new LinkableItem("projectVersionLabel", "projectVersionValue");
LinkableItem component = new LinkableItem("componentLabel", "componentValue");
LinkableItem componentVersion = new LinkableItem("componentVersionLabel", "componentVersionValue");
IssueBomComponentDetails issueBomComponentDetails = IssueBomComponentDetails.fromSearchResults(component, componentVersion);
IssuePolicyDetails issuePolicyDetails = new IssuePolicyDetails("policy", ItemOperation.ADD, ComponentConcernSeverity.CRITICAL);
ProjectIssueModel policy = ProjectIssueModel.policy(providerDetails, project, projectVersion, issueBomComponentDetails, issuePolicyDetails);
List<WorkItemElementOperationModel> workItemRequestCustomFieldOperations = azureBoardsAlertIssuePropertiesManager.createWorkItemRequestCustomFieldOperations(policy);
LinkableItem provider = providerDetails.getProvider();
String providerKey = AzureBoardsSearchPropertiesUtils.createProviderKey(provider.getLabel(), provider.getUrl().orElse(null));
assertValidContents(workItemRequestCustomFieldOperations, AzureCustomFieldManager.ALERT_PROVIDER_KEY_FIELD_REFERENCE_NAME, providerKey);
String additionalInfo = AzureBoardsAlertIssuePropertiesManager.POLICY_ADDITIONAL_KEY_COMPATIBILITY_LABEL + issuePolicyDetails.getName();
assertValidContents(workItemRequestCustomFieldOperations, AzureCustomFieldManager.ALERT_ADDITIONAL_INFO_KEY_FIELD_REFERENCE_NAME, additionalInfo);
assertValidContents(workItemRequestCustomFieldOperations, AzureCustomFieldManager.ALERT_CATEGORY_KEY_FIELD_REFERENCE_NAME, AzureBoardsAlertIssuePropertiesManager.CATEGORY_TYPE_POLICY_COMPATIBILITY_LABEL);
String subTopicKey = AzureBoardsSearchPropertiesUtils.createNullableLinkableItemKey(policy.getProjectVersion().orElse(null));
assertValidContents(workItemRequestCustomFieldOperations, AzureCustomFieldManager.ALERT_SUB_TOPIC_KEY_FIELD_REFERENCE_NAME, subTopicKey);
}
use of com.synopsys.integration.alert.processor.api.extract.model.ProviderDetails in project hub-alert by blackducksoftware.
the class IssueTrackerTestAction method createPlaceholderProjectIssueModel.
private ProjectIssueModel createPlaceholderProjectIssueModel(Long blackDuckConfigId) {
LinkableItem providerItem = new LinkableItem("Provider Test Label", "Provider Config Test Name");
ProviderDetails providerDetails = new ProviderDetails(blackDuckConfigId, providerItem);
LinkableItem projectItem = new LinkableItem("Project Test Label", "Project Test Name");
LinkableItem projectVersionItem = new LinkableItem("Project-Version Test Label", "Project-Version Test Name");
LinkableItem componentItem = new LinkableItem("Component Test Label", "Component Test Value");
IssueBomComponentDetails bomComponentDetails = IssueBomComponentDetails.fromSearchResults(componentItem, null);
return ProjectIssueModel.bom(providerDetails, projectItem, projectVersionItem, bomComponentDetails);
}
use of com.synopsys.integration.alert.processor.api.extract.model.ProviderDetails 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.ProviderDetails 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.ProviderDetails 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