use of com.synopsys.integration.alert.api.channel.issue.model.IssueEstimatedRiskModel in project hub-alert by blackducksoftware.
the class ProjectMessageToIssueModelTransformerTest method convertToIssueModelsForComponentUnknownVersionTest.
@Test
public void convertToIssueModelsForComponentUnknownVersionTest() {
ComponentConcern unknownComponentConcern = ComponentConcern.unknownComponentVersion(ItemOperation.ADD, "Component01", ComponentConcernSeverity.MAJOR_HIGH, 2, "https://synopsys.com");
BomComponentDetails bomComponentDetails = createBomComponentDetails(unknownComponentConcern);
ProjectMessage projectMessage = ProjectMessage.componentConcern(PROVIDER_DETAILS, PROJECT, PROJECT_VERSION, List.of(bomComponentDetails));
ProjectMessageToIssueModelTransformer modelTransformer = new ProjectMessageToIssueModelTransformer();
List<ProjectIssueModel> policyIssueModels = modelTransformer.convertToIssueModels(projectMessage);
assertEquals(1, policyIssueModels.size());
ProjectIssueModel unknownVersionIssueModel = policyIssueModels.get(0);
assertRequiredDetails(unknownVersionIssueModel);
Optional<IssueComponentUnknownVersionDetails> optionalDetails = unknownVersionIssueModel.getComponentUnknownVersionDetails();
assertTrue(optionalDetails.isPresent(), "Expected unknown component details to be present");
IssueComponentUnknownVersionDetails details = optionalDetails.get();
assertEquals(ItemOperation.ADD, details.getItemOperation());
assertEquals(1, details.getEstimatedRiskModelList().size());
IssueEstimatedRiskModel estimatedRiskModel = details.getEstimatedRiskModelList().get(0);
assertEquals(ComponentConcernSeverity.MAJOR_HIGH, estimatedRiskModel.getSeverity());
assertEquals("Component01", estimatedRiskModel.getName());
assertEquals(2, estimatedRiskModel.getCount());
assertTrue(estimatedRiskModel.getComponentVersionUrl().isPresent());
}
use of com.synopsys.integration.alert.api.channel.issue.model.IssueEstimatedRiskModel in project hub-alert by blackducksoftware.
the class IssueComponentUnknownVersionDetailsConverter method createEstimatedRiskDetailsSectionPieces.
public List<String> createEstimatedRiskDetailsSectionPieces(IssueComponentUnknownVersionDetails unknownVersionDetails) {
List<String> estimatedRiskSectionPieces = new LinkedList<>();
if (ItemOperation.DELETE.equals(unknownVersionDetails.getItemOperation())) {
estimatedRiskSectionPieces.add(formatter.encode(TEXT_COMPONENT_DELETE));
estimatedRiskSectionPieces.add(formatter.getLineSeparator());
} else {
estimatedRiskSectionPieces.add(formatter.encode(SECTION_LABEL_VULNERABILITY_COUNTS));
estimatedRiskSectionPieces.add(formatter.getLineSeparator());
estimatedRiskSectionPieces.add(formatter.getLineSeparator());
for (IssueEstimatedRiskModel estimatedRiskModel : unknownVersionDetails.getEstimatedRiskModelList()) {
estimatedRiskSectionPieces.add(createEstimatedRiskString(estimatedRiskModel));
estimatedRiskSectionPieces.add(formatter.getLineSeparator());
}
}
return estimatedRiskSectionPieces;
}
use of com.synopsys.integration.alert.api.channel.issue.model.IssueEstimatedRiskModel in project hub-alert by blackducksoftware.
the class ProjectMessageToIssueModelTransformer method createEstimatedRiskProjectIssueModel.
private ProjectIssueModel createEstimatedRiskProjectIssueModel(ProjectMessage projectMessage, IssueBomComponentDetails issueBomComponent, List<ComponentConcern> estimatedRiskConcerns) {
List<IssueEstimatedRiskModel> estimatedRiskModels = new LinkedList<>();
ItemOperation itemOperation = estimatedRiskConcerns.stream().map(ComponentConcern::getOperation).findFirst().orElse(ItemOperation.ADD);
// all component concerns for this type have the same operation.
for (ComponentConcern componentConcern : estimatedRiskConcerns) {
estimatedRiskModels.add(IssueEstimatedRiskModel.fromComponentConcern(componentConcern));
}
IssueComponentUnknownVersionDetails unknownVersionDetails = new IssueComponentUnknownVersionDetails(itemOperation, estimatedRiskModels);
return ProjectIssueModel.componentUnknownVersion(projectMessage.getProviderDetails(), projectMessage.getProject(), projectMessage.getProjectVersion().orElse(null), issueBomComponent, unknownVersionDetails);
}
Aggregations