Search in sources :

Example 11 with MockIssueTrackerMessageFormatter

use of com.synopsys.integration.alert.api.channel.issue.convert.mock.MockIssueTrackerMessageFormatter in project hub-alert by blackducksoftware.

the class IssueComponentUnknownDetailsConverterTest method callCreateSectionPieces.

private List<String> callCreateSectionPieces(IssueComponentUnknownVersionDetails details) {
    MockIssueTrackerMessageFormatter formatter = MockIssueTrackerMessageFormatter.withIntegerMaxValueLength();
    IssueComponentUnknownVersionDetailsConverter converter = new IssueComponentUnknownVersionDetailsConverter(formatter);
    return converter.createEstimatedRiskDetailsSectionPieces(details);
}
Also used : MockIssueTrackerMessageFormatter(com.synopsys.integration.alert.api.channel.issue.convert.mock.MockIssueTrackerMessageFormatter)

Example 12 with MockIssueTrackerMessageFormatter

use of com.synopsys.integration.alert.api.channel.issue.convert.mock.MockIssueTrackerMessageFormatter in project hub-alert by blackducksoftware.

the class ComponentVulnerabilitiesConverterTest method callCreateComponentVulnerabilitiesSectionPieces.

private List<String> callCreateComponentVulnerabilitiesSectionPieces(ComponentVulnerabilities componentVulnerabilities) {
    MockIssueTrackerMessageFormatter formatter = MockIssueTrackerMessageFormatter.withIntegerMaxValueLength();
    ComponentVulnerabilitiesConverter converter = new ComponentVulnerabilitiesConverter(formatter);
    return converter.createComponentVulnerabilitiesSectionPieces(componentVulnerabilities);
}
Also used : MockIssueTrackerMessageFormatter(com.synopsys.integration.alert.api.channel.issue.convert.mock.MockIssueTrackerMessageFormatter)

Example 13 with MockIssueTrackerMessageFormatter

use of com.synopsys.integration.alert.api.channel.issue.convert.mock.MockIssueTrackerMessageFormatter in project hub-alert by blackducksoftware.

the class IssuePolicyDetailsConverterTest method callCreatePolicyDetailsSectionPieces.

private List<String> callCreatePolicyDetailsSectionPieces(IssuePolicyDetails policyDetails) {
    MockIssueTrackerMessageFormatter formatter = MockIssueTrackerMessageFormatter.withIntegerMaxValueLength();
    IssuePolicyDetailsConverter converter = new IssuePolicyDetailsConverter(formatter);
    return converter.createPolicyDetailsSectionPieces(ISSUE_BOM_COMPONENT_DETAILS, policyDetails);
}
Also used : MockIssueTrackerMessageFormatter(com.synopsys.integration.alert.api.channel.issue.convert.mock.MockIssueTrackerMessageFormatter)

Example 14 with MockIssueTrackerMessageFormatter

use of com.synopsys.integration.alert.api.channel.issue.convert.mock.MockIssueTrackerMessageFormatter in project hub-alert by blackducksoftware.

the class IssueTrackerSimpleMessageConverterTest method convertToIssueCreationModelTruncateTitleTest.

@Test
void convertToIssueCreationModelTruncateTitleTest() {
    int maxTitleLength = 10;
    int maxDescriptionLength = 12;
    MockIssueTrackerMessageFormatter formatter = new MockIssueTrackerMessageFormatter(maxTitleLength, maxDescriptionLength, 1000);
    IssueTrackerSimpleMessageConverter converter = new IssueTrackerSimpleMessageConverter(formatter);
    IssueCreationModel issueCreationModel = converter.convertToIssueCreationModel(SIMPLE_MESSAGE, "jobName");
    assertEquals(maxTitleLength, issueCreationModel.getTitle().length());
    assertTrue(maxDescriptionLength >= issueCreationModel.getDescription().length(), "Expected max description length to be greater than or equal to the created description");
    assertTrue(issueCreationModel.getPostCreateComments().size() > 0, "Expected truncated title/description to continue in comments");
}
Also used : IssueCreationModel(com.synopsys.integration.alert.api.channel.issue.model.IssueCreationModel) MockIssueTrackerMessageFormatter(com.synopsys.integration.alert.api.channel.issue.convert.mock.MockIssueTrackerMessageFormatter) Test(org.junit.jupiter.api.Test)

Example 15 with MockIssueTrackerMessageFormatter

use of com.synopsys.integration.alert.api.channel.issue.convert.mock.MockIssueTrackerMessageFormatter in project hub-alert by blackducksoftware.

the class IssueTrackerSimpleMessageConverterTest method convertToIssueCreationModelUnboundedTest.

@Test
void convertToIssueCreationModelUnboundedTest() {
    MockIssueTrackerMessageFormatter formatter = MockIssueTrackerMessageFormatter.withIntegerMaxValueLength();
    IssueTrackerSimpleMessageConverter converter = new IssueTrackerSimpleMessageConverter(formatter);
    IssueCreationModel issueCreationModel = converter.convertToIssueCreationModel(SIMPLE_MESSAGE, "jobName");
    assertTrue(issueCreationModel.getTitle().contains(SIMPLE_MESSAGE.getSummary()), "Expected title to contain the simple message's summary");
    String issueCreationModelDescription = issueCreationModel.getDescription();
    assertTrue(issueCreationModelDescription.contains(SIMPLE_MESSAGE.getDescription()), "Expected description to contain the simple message's description");
    for (LinkableItem detail : SIMPLE_MESSAGE.getDetails()) {
        assertTrue(issueCreationModelDescription.contains(detail.getLabel()) && issueCreationModelDescription.contains(detail.getValue()), "Expected description to contain the simple message's details");
    }
}
Also used : IssueCreationModel(com.synopsys.integration.alert.api.channel.issue.model.IssueCreationModel) LinkableItem(com.synopsys.integration.alert.common.message.model.LinkableItem) MockIssueTrackerMessageFormatter(com.synopsys.integration.alert.api.channel.issue.convert.mock.MockIssueTrackerMessageFormatter) Test(org.junit.jupiter.api.Test)

Aggregations

MockIssueTrackerMessageFormatter (com.synopsys.integration.alert.api.channel.issue.convert.mock.MockIssueTrackerMessageFormatter)16 Test (org.junit.jupiter.api.Test)10 ProjectIssueModel (com.synopsys.integration.alert.api.channel.issue.model.ProjectIssueModel)8 IssueCreationModel (com.synopsys.integration.alert.api.channel.issue.model.IssueCreationModel)6 LinkableItem (com.synopsys.integration.alert.common.message.model.LinkableItem)4 IssueBomComponentDetails (com.synopsys.integration.alert.api.channel.issue.model.IssueBomComponentDetails)3 IssuePolicyDetails (com.synopsys.integration.alert.api.channel.issue.model.IssuePolicyDetails)3 IssueVulnerabilityDetails (com.synopsys.integration.alert.api.channel.issue.model.IssueVulnerabilityDetails)3 IssueVulnerabilityModel (com.synopsys.integration.alert.api.channel.issue.model.IssueVulnerabilityModel)3 ActionableIssueSearchResult (com.synopsys.integration.alert.api.channel.issue.search.ActionableIssueSearchResult)3 AbstractBomComponentDetails (com.synopsys.integration.alert.processor.api.extract.model.project.AbstractBomComponentDetails)3 ComponentVulnerabilities (com.synopsys.integration.alert.processor.api.extract.model.project.ComponentVulnerabilities)3 ProjectMessage (com.synopsys.integration.alert.processor.api.extract.model.project.ProjectMessage)3 ExistingIssueDetails (com.synopsys.integration.alert.api.channel.issue.search.ExistingIssueDetails)2 IssueTransitionModel (com.synopsys.integration.alert.api.channel.issue.model.IssueTransitionModel)1 IssueOperation (com.synopsys.integration.alert.common.channel.issuetracker.enumeration.IssueOperation)1 ItemOperation (com.synopsys.integration.alert.common.enumeration.ItemOperation)1 SimpleMessage (com.synopsys.integration.alert.processor.api.extract.model.SimpleMessage)1