use of com.synopsys.integration.alert.api.channel.issue.convert.mock.MockIssueTrackerMessageFormatter in project hub-alert by blackducksoftware.
the class ProjectIssueModelConverterTest method basicIssueCreationModelTest.
private IssueCreationModel basicIssueCreationModelTest(ProjectIssueModel projectIssueModel) {
MockIssueTrackerMessageFormatter formatter = MockIssueTrackerMessageFormatter.withIntegerMaxValueLength();
ProjectIssueModelConverter converter = new ProjectIssueModelConverter(formatter);
IssueCreationModel issueCreationModel = converter.toIssueCreationModel(projectIssueModel, "jobName");
assertEquals(projectIssueModel, issueCreationModel.getSource().orElse(null));
String issueCreationModelTitle = issueCreationModel.getTitle();
assertTrue(issueCreationModelTitle.contains(PROVIDER_DETAILS.getProvider().getValue()), "Expected provider value to be present in the title");
assertTrue(issueCreationModelTitle.contains(PROJECT_ITEM.getValue()), "Expected project value to be present in the title");
assertTrue(issueCreationModelTitle.contains(PROJECT_VERSION_ITEM.getValue()), "Expected project-version value to be present in the title");
assertTrue(issueCreationModelTitle.contains(COMPONENT_ITEM.getValue()), "Expected component value to be present in the title");
assertTrue(issueCreationModelTitle.contains(COMPONENT_VERSION_ITEM.getValue()), "Expected component-version value to be present in the title");
return issueCreationModel;
}
use of com.synopsys.integration.alert.api.channel.issue.convert.mock.MockIssueTrackerMessageFormatter in project hub-alert by blackducksoftware.
the class IssueVulnerabilityDetailsConverterTest method callCreateVulnerabilityDetailsSectionPieces.
private List<String> callCreateVulnerabilityDetailsSectionPieces() {
MockIssueTrackerMessageFormatter formatter = MockIssueTrackerMessageFormatter.withIntegerMaxValueLength();
IssueVulnerabilityDetailsConverter converter = new IssueVulnerabilityDetailsConverter(formatter);
return converter.createVulnerabilityDetailsSectionPieces(ISSUE_VULNERABILITY_DETAILS);
}
use of com.synopsys.integration.alert.api.channel.issue.convert.mock.MockIssueTrackerMessageFormatter in project hub-alert by blackducksoftware.
the class IssueTrackerModelExtractorTest method extractProjectMessageIssueModelsCreateTest.
@Test
public void extractProjectMessageIssueModelsCreateTest() throws AlertException {
ProjectMessage projectMessage = Mockito.mock(ProjectMessage.class);
IssuePolicyDetails policyDetails = new IssuePolicyDetails("A policy", ItemOperation.ADD, ComponentConcernSeverity.UNSPECIFIED_UNKNOWN);
ProjectIssueModel projectIssueModel = ProjectIssueModel.policy(PROVIDER_DETAILS, PROJECT, PROJECT_VERSION, ISSUE_BOM_COMPONENT_DETAILS, policyDetails);
ActionableIssueSearchResult<String> searchResult = new ActionableIssueSearchResult<>(null, projectIssueModel, ItemOperation.ADD);
MockIssueTrackerMessageFormatter formatter = MockIssueTrackerMessageFormatter.withIntegerMaxValueLength();
IssueTrackerSearcher<String> searcher = Mockito.mock(IssueTrackerSearcher.class);
Mockito.when(searcher.findIssues(Mockito.eq(projectMessage))).thenReturn(List.of(searchResult));
IssueTrackerModelExtractor<String> extractor = new IssueTrackerModelExtractor<>(formatter, searcher);
IssueTrackerModelHolder<String> modelHolder = extractor.extractProjectMessageIssueModels(projectMessage, "jobName");
List<IssueCreationModel> issueCreationModels = modelHolder.getIssueCreationModels();
assertEquals(1, issueCreationModels.size());
assertEquals(0, modelHolder.getIssueTransitionModels().size());
assertEquals(0, modelHolder.getIssueCommentModels().size());
IssueCreationModel issueCreationModel = issueCreationModels.get(0);
assertEquals(projectIssueModel, issueCreationModel.getSource().orElse(null));
}
use of com.synopsys.integration.alert.api.channel.issue.convert.mock.MockIssueTrackerMessageFormatter in project hub-alert by blackducksoftware.
the class IssueTrackerModelExtractorTest method extractProjectMessageIssueModelsTransitionTest.
@Test
public void extractProjectMessageIssueModelsTransitionTest() throws AlertException {
ItemOperation itemOperation = ItemOperation.DELETE;
IssueOperation issueOperation = IssueOperation.RESOLVE;
ProjectMessage projectMessage = Mockito.mock(ProjectMessage.class);
ExistingIssueDetails<String> existingIssueDetails = new ExistingIssueDetails<>("issue-id", "issue-key", "issue summary", "https://ui-link", IssueStatus.UNKNOWN, IssueCategory.POLICY);
IssuePolicyDetails policyDetails = new IssuePolicyDetails("A policy", itemOperation, ComponentConcernSeverity.UNSPECIFIED_UNKNOWN);
ProjectIssueModel projectIssueModel = ProjectIssueModel.policy(PROVIDER_DETAILS, PROJECT, PROJECT_VERSION, ISSUE_BOM_COMPONENT_DETAILS, policyDetails);
ActionableIssueSearchResult<String> searchResult = new ActionableIssueSearchResult<>(existingIssueDetails, projectIssueModel, itemOperation);
MockIssueTrackerMessageFormatter formatter = MockIssueTrackerMessageFormatter.withIntegerMaxValueLength();
IssueTrackerSearcher<String> searcher = Mockito.mock(IssueTrackerSearcher.class);
Mockito.when(searcher.findIssues(Mockito.eq(projectMessage))).thenReturn(List.of(searchResult));
IssueTrackerModelExtractor<String> extractor = new IssueTrackerModelExtractor<>(formatter, searcher);
IssueTrackerModelHolder<String> modelHolder = extractor.extractProjectMessageIssueModels(projectMessage, "jobName");
List<IssueTransitionModel<String>> issueTransitionModels = modelHolder.getIssueTransitionModels();
assertEquals(0, modelHolder.getIssueCreationModels().size());
assertEquals(1, issueTransitionModels.size());
assertEquals(0, modelHolder.getIssueCommentModels().size());
IssueTransitionModel<String> transitionModel = issueTransitionModels.get(0);
assertEquals(issueOperation, transitionModel.getIssueOperation());
}
use of com.synopsys.integration.alert.api.channel.issue.convert.mock.MockIssueTrackerMessageFormatter in project hub-alert by blackducksoftware.
the class IssueTrackerModelExtractorTest method extractSimpleMessageIssueModelsTest.
@Test
public void extractSimpleMessageIssueModelsTest() {
String testSummary = "A test summary";
String testDescription = "A description for the test";
LinkableItem additionalDetail = new LinkableItem("A label", "A value");
MockIssueTrackerMessageFormatter formatter = MockIssueTrackerMessageFormatter.withIntegerMaxValueLength();
IssueTrackerModelExtractor<String> extractor = new IssueTrackerModelExtractor<>(formatter, null);
SimpleMessage simpleMessage = SimpleMessage.original(PROVIDER_DETAILS, testSummary, testDescription, List.of(additionalDetail));
IssueTrackerModelHolder<String> modelHolder = extractor.extractSimpleMessageIssueModels(List.of(simpleMessage), "jobName");
List<IssueCreationModel> issueCreationModels = modelHolder.getIssueCreationModels();
assertEquals(1, issueCreationModels.size());
assertEquals(0, modelHolder.getIssueTransitionModels().size());
assertEquals(0, modelHolder.getIssueCommentModels().size());
IssueCreationModel issueCreationModel = issueCreationModels.get(0);
assertEquals(PROVIDER_DETAILS.getProvider(), issueCreationModel.getProvider());
assertTrue(issueCreationModel.getTitle().contains(testSummary), "Expected the issue title to contain the simple message's summary");
assertTrue(issueCreationModel.getDescription().contains(testDescription), "Expected the issue description to contain the simple message's description");
assertTrue(issueCreationModel.getDescription().contains(additionalDetail.getValue()), "Expected the issue description to contain the simple message's additional detail(s)");
}
Aggregations