Search in sources :

Example 21 with IssueBomComponentDetails

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);
}
Also used : ComponentConcernType(com.synopsys.integration.alert.processor.api.extract.model.project.ComponentConcernType) ComponentConcernSeverity(com.synopsys.integration.alert.processor.api.extract.model.project.ComponentConcernSeverity) ExistingIssueDetails(com.synopsys.integration.alert.api.channel.issue.search.ExistingIssueDetails) ComponentVulnerabilities(com.synopsys.integration.alert.processor.api.extract.model.project.ComponentVulnerabilities) StringUtils(org.apache.commons.lang3.StringUtils) IssueComponentUnknownVersionDetails(com.synopsys.integration.alert.api.channel.issue.model.IssueComponentUnknownVersionDetails) IssueTransitionModel(com.synopsys.integration.alert.api.channel.issue.model.IssueTransitionModel) ChunkedStringBuilderRechunker(com.synopsys.integration.alert.common.channel.message.ChunkedStringBuilderRechunker) IssuePolicyDetails(com.synopsys.integration.alert.api.channel.issue.model.IssuePolicyDetails) BomComponentDetailConverter(com.synopsys.integration.alert.api.channel.convert.BomComponentDetailConverter) IssueVulnerabilityDetails(com.synopsys.integration.alert.api.channel.issue.model.IssueVulnerabilityDetails) RechunkedModel(com.synopsys.integration.alert.common.channel.message.RechunkedModel) ItemOperation(com.synopsys.integration.alert.common.enumeration.ItemOperation) LinkedList(java.util.LinkedList) IssueCommentModel(com.synopsys.integration.alert.api.channel.issue.model.IssueCommentModel) LinkableItem(com.synopsys.integration.alert.common.message.model.LinkableItem) IssueOperation(com.synopsys.integration.alert.common.channel.issuetracker.enumeration.IssueOperation) IssueCreationModel(com.synopsys.integration.alert.api.channel.issue.model.IssueCreationModel) Collectors(java.util.stream.Collectors) Serializable(java.io.Serializable) List(java.util.List) ChunkedStringBuilder(com.synopsys.integration.alert.common.channel.message.ChunkedStringBuilder) Optional(java.util.Optional) LinkableItemConverter(com.synopsys.integration.alert.api.channel.convert.LinkableItemConverter) ProjectIssueModel(com.synopsys.integration.alert.api.channel.issue.model.ProjectIssueModel) IssueBomComponentDetails(com.synopsys.integration.alert.api.channel.issue.model.IssueBomComponentDetails) LinkableItem(com.synopsys.integration.alert.common.message.model.LinkableItem) IssueBomComponentDetails(com.synopsys.integration.alert.api.channel.issue.model.IssueBomComponentDetails) ChunkedStringBuilder(com.synopsys.integration.alert.common.channel.message.ChunkedStringBuilder) RechunkedModel(com.synopsys.integration.alert.common.channel.message.RechunkedModel)

Example 22 with IssueBomComponentDetails

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);
}
Also used : LinkableItem(com.synopsys.integration.alert.common.message.model.LinkableItem) IssueBomComponentDetails(com.synopsys.integration.alert.api.channel.issue.model.IssueBomComponentDetails) ProviderDetails(com.synopsys.integration.alert.processor.api.extract.model.ProviderDetails)

Example 23 with IssueBomComponentDetails

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");
}
Also used : IssueBomComponentDetails(com.synopsys.integration.alert.api.channel.issue.model.IssueBomComponentDetails)

Example 24 with IssueBomComponentDetails

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);
}
Also used : LinkableItem(com.synopsys.integration.alert.common.message.model.LinkableItem) IssueBomComponentDetails(com.synopsys.integration.alert.api.channel.issue.model.IssueBomComponentDetails) JiraIssueSearchProperties(com.synopsys.integration.alert.api.channel.jira.JiraIssueSearchProperties) ProjectIssueModel(com.synopsys.integration.alert.api.channel.issue.model.ProjectIssueModel)

Aggregations

IssueBomComponentDetails (com.synopsys.integration.alert.api.channel.issue.model.IssueBomComponentDetails)24 LinkableItem (com.synopsys.integration.alert.common.message.model.LinkableItem)17 ProjectIssueModel (com.synopsys.integration.alert.api.channel.issue.model.ProjectIssueModel)15 IssuePolicyDetails (com.synopsys.integration.alert.api.channel.issue.model.IssuePolicyDetails)11 IssueVulnerabilityDetails (com.synopsys.integration.alert.api.channel.issue.model.IssueVulnerabilityDetails)9 ComponentConcernType (com.synopsys.integration.alert.processor.api.extract.model.project.ComponentConcernType)6 ComponentVulnerabilities (com.synopsys.integration.alert.processor.api.extract.model.project.ComponentVulnerabilities)6 Test (org.junit.jupiter.api.Test)6 ProviderDetails (com.synopsys.integration.alert.processor.api.extract.model.ProviderDetails)5 LinkedList (java.util.LinkedList)5 IssueComponentUnknownVersionDetails (com.synopsys.integration.alert.api.channel.issue.model.IssueComponentUnknownVersionDetails)4 IssueCreationModel (com.synopsys.integration.alert.api.channel.issue.model.IssueCreationModel)4 IssueVulnerabilityModel (com.synopsys.integration.alert.api.channel.issue.model.IssueVulnerabilityModel)4 ExistingIssueDetails (com.synopsys.integration.alert.api.channel.issue.search.ExistingIssueDetails)4 ChunkedStringBuilder (com.synopsys.integration.alert.common.channel.message.ChunkedStringBuilder)4 Optional (java.util.Optional)4 MockIssueTrackerMessageFormatter (com.synopsys.integration.alert.api.channel.issue.convert.mock.MockIssueTrackerMessageFormatter)3 IssueCommentModel (com.synopsys.integration.alert.api.channel.issue.model.IssueCommentModel)3 JiraIssueSearchProperties (com.synopsys.integration.alert.api.channel.jira.JiraIssueSearchProperties)3 ItemOperation (com.synopsys.integration.alert.common.enumeration.ItemOperation)3