use of com.synopsys.integration.alert.api.channel.issue.model.IssueBomComponentDetails in project hub-alert by blackducksoftware.
the class ProjectIssueModelConverter method toIssueCreationModel.
public IssueCreationModel toIssueCreationModel(ProjectIssueModel projectIssueModel, String jobName) {
String title = createTruncatedTitle(projectIssueModel);
ChunkedStringBuilder descriptionBuilder = new ChunkedStringBuilder(formatter.getMaxDescriptionLength());
String nonBreakingSpace = formatter.getNonBreakingSpace();
String jobLine = String.format("Job%sname:%s%s", nonBreakingSpace, nonBreakingSpace, jobName);
String formattedJobName = formatter.emphasize(jobLine);
descriptionBuilder.append(formattedJobName);
descriptionBuilder.append(formatter.getLineSeparator());
String projectString = linkableItemConverter.convertToString(projectIssueModel.getProject(), true);
descriptionBuilder.append(projectString);
descriptionBuilder.append(formatter.getLineSeparator());
LinkableItem projectVersion = projectIssueModel.getProjectVersion().orElse(MISSING_PROJECT_VERSION_PLACEHOLDER);
String projectVersionString = linkableItemConverter.convertToString(projectVersion, true);
descriptionBuilder.append(projectVersionString);
descriptionBuilder.append(formatter.getLineSeparator());
descriptionBuilder.append(formatter.getSectionSeparator());
descriptionBuilder.append(formatter.getLineSeparator());
IssueBomComponentDetails bomComponent = projectIssueModel.getBomComponentDetails();
List<String> bomComponentPieces = bomComponentDetailConverter.gatherAbstractBomComponentSectionPieces(bomComponent);
bomComponentPieces.forEach(descriptionBuilder::append);
createVulnerabilitySeverityStatusSectionPieces(projectIssueModel).forEach(descriptionBuilder::append);
descriptionBuilder.append(formatter.getLineSeparator());
createProjectIssueModelConcernSectionPieces(projectIssueModel, false).forEach(descriptionBuilder::append);
int newChunkSize = formatter.getMaxCommentLength() - DESCRIPTION_CONTINUED_TEXT.length() - formatter.getLineSeparator().length();
RechunkedModel rechunkedDescription = ChunkedStringBuilderRechunker.rechunk(descriptionBuilder, "No description", newChunkSize);
List<String> postCreateComments = rechunkedDescription.getRemainingChunks().stream().map(comment -> String.format("%s%s%s", DESCRIPTION_CONTINUED_TEXT, formatter.getLineSeparator(), comment)).collect(Collectors.toList());
return IssueCreationModel.project(title, rechunkedDescription.getFirstChunk(), postCreateComments, projectIssueModel);
}
use of com.synopsys.integration.alert.api.channel.issue.model.IssueBomComponentDetails 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.api.channel.issue.model.IssueBomComponentDetails in project hub-alert by blackducksoftware.
the class ProjectMessageToIssueModelTransformerTest method assertRequiredDetails.
private static void assertRequiredDetails(ProjectIssueModel projectIssueModel) {
assertEquals(PROVIDER_DETAILS, projectIssueModel.getProviderDetails());
assertEquals(PROJECT, projectIssueModel.getProject());
assertEquals(PROJECT_VERSION, projectIssueModel.getProjectVersion().orElse(null));
IssueBomComponentDetails issueBomComponentDetails = projectIssueModel.getBomComponentDetails();
assertEquals(COMPONENT, issueBomComponentDetails.getComponent());
assertEquals(COMPONENT_VERSION, issueBomComponentDetails.getComponentVersion().orElse(null));
assertEquals(COMPONENT_VULNERABILITIES, issueBomComponentDetails.getComponentVulnerabilities());
assertEquals(COMPONENT_POLICIES, issueBomComponentDetails.getRelevantPolicies());
assertEquals(LICENSE, issueBomComponentDetails.getLicense());
assertEquals(USAGE, issueBomComponentDetails.getUsage());
assertEquals(ISSUES_URL, issueBomComponentDetails.getBlackDuckIssuesUrl());
assertEquals(UPGRADE_GUIDANCE, issueBomComponentDetails.getComponentUpgradeGuidance());
assertTrue(issueBomComponentDetails.getAdditionalAttributes().contains(ADDITIONAL_ATTRIBUTE), "Expected issue BOM component details to contain an additional attribute");
}
use of com.synopsys.integration.alert.api.channel.issue.model.IssueBomComponentDetails in project hub-alert by blackducksoftware.
the class JiraIssueSearchResultCreator method createResultFromProjectIssue.
public ProjectIssueSearchResult<String> createResultFromProjectIssue(JiraSearcherResponseModel issue, ProviderDetails providerDetails, LinkableItem project) throws AlertException {
JiraIssueSearchProperties issueProperties = issuePropertiesManager.retrieveIssueProperties(issue.getIssueKey());
String nullableSubComponentName = issueProperties.getSubComponentName();
String nullableSubComponentValue = issueProperties.getSubComponentValue();
LinkableItem componentVersion = null;
if (StringUtils.isNotBlank(nullableSubComponentName) && StringUtils.isNotBlank(nullableSubComponentValue)) {
componentVersion = new LinkableItem(nullableSubComponentName, nullableSubComponentValue);
}
LinkableItem projectVersion = new LinkableItem(issueProperties.getSubTopicName(), issueProperties.getSubTopicValue());
IssueBomComponentDetails bomComponentDetails = IssueBomComponentDetails.fromSearchResults(new LinkableItem(issueProperties.getComponentName(), issueProperties.getComponentValue()), componentVersion);
ProjectIssueModel projectIssueModel = ProjectIssueModel.bom(providerDetails, project, projectVersion, bomComponentDetails);
return createIssueResult(issue, projectIssueModel);
}
Aggregations