use of com.synopsys.integration.alert.processor.api.extract.model.project.ProjectMessage in project hub-alert by blackducksoftware.
the class ProcessedProviderMessageTest method combineProjectOperationsDontMatchTest.
@Test
public void combineProjectOperationsDontMatchTest() {
LinkableItem provider = new LinkableItem("Provider", "Provider Config Name");
ProviderDetails providerDetails = new ProviderDetails(1L, provider);
LinkableItem commonProject = new LinkableItem("Project", "Project 1");
ProjectMessage projectMessage1 = ProjectMessage.projectStatusInfo(providerDetails, commonProject, ProjectOperation.CREATE);
ProjectMessage projectMessage2 = ProjectMessage.projectStatusInfo(providerDetails, commonProject, ProjectOperation.DELETE);
ProcessedProviderMessage<ProjectMessage> processedProviderMessage1 = ProcessedProviderMessage.singleSource(10L, projectMessage1);
ProcessedProviderMessage<ProjectMessage> processedProviderMessage2 = ProcessedProviderMessage.singleSource(20L, projectMessage2);
// Create then delete
List<ProcessedProviderMessage<ProjectMessage>> combinedProjectMessages1 = processedProviderMessage1.combine(processedProviderMessage2);
assertEquals(0, combinedProjectMessages1.size());
// Delete then create
List<ProcessedProviderMessage<ProjectMessage>> combinedProjectMessages2 = processedProviderMessage2.combine(processedProviderMessage1);
assertEquals(1, combinedProjectMessages2.size());
assertEquals(processedProviderMessage1.getProviderMessage(), combinedProjectMessages2.get(0).getProviderMessage());
}
use of com.synopsys.integration.alert.processor.api.extract.model.project.ProjectMessage in project hub-alert by blackducksoftware.
the class ProcessedProviderMessageTest method combineProjectVersionOperationsMatchTest.
@Test
public void combineProjectVersionOperationsMatchTest() {
LinkableItem provider = new LinkableItem("Provider", "Provider Config Name");
ProviderDetails providerDetails = new ProviderDetails(1L, provider);
LinkableItem commonProject = new LinkableItem("Project", "Project 1");
LinkableItem commonProjectVersion = new LinkableItem("Project Version", "Project Version 1");
ProjectOperation commonOperation = ProjectOperation.CREATE;
ProjectMessage projectMessage1 = ProjectMessage.projectVersionStatusInfo(providerDetails, commonProject, commonProjectVersion, commonOperation);
ProjectMessage projectMessage2 = ProjectMessage.projectVersionStatusInfo(providerDetails, commonProject, commonProjectVersion, commonOperation);
ProcessedProviderMessage<ProjectMessage> processedProviderMessage1 = ProcessedProviderMessage.singleSource(10L, projectMessage1);
ProcessedProviderMessage<ProjectMessage> processedProviderMessage2 = ProcessedProviderMessage.singleSource(20L, projectMessage2);
assertCombined(processedProviderMessage1, processedProviderMessage2);
}
use of com.synopsys.integration.alert.processor.api.extract.model.project.ProjectMessage in project hub-alert by blackducksoftware.
the class ProjectVersionNotificationMessageExtractorTest method extractTest.
@Test
public void extractTest() throws IntegrationException {
NotificationExtractorBlackDuckServicesFactoryCache servicesFactoryCache = Mockito.mock(NotificationExtractorBlackDuckServicesFactoryCache.class);
BlackDuckServicesFactory blackDuckServicesFactory = Mockito.mock(BlackDuckServicesFactory.class);
BlackDuckHttpClient blackDuckHttpClient = Mockito.mock(BlackDuckHttpClient.class);
Mockito.when(blackDuckHttpClient.getBlackDuckUrl()).thenReturn(new HttpUrl("https://a.blackduck.server.example.com"));
Mockito.when(blackDuckServicesFactory.getBlackDuckHttpClient()).thenReturn(blackDuckHttpClient);
Mockito.when(servicesFactoryCache.retrieveBlackDuckServicesFactory(Mockito.anyLong())).thenReturn(blackDuckServicesFactory);
ProjectVersionNotificationContent projectVersionNotificationContent = createProjectVersionNotificationContent();
NotificationContentWrapper notificationContentWrapper = createNotificationContentWrapper(projectVersionNotificationContent);
ProjectVersionNotificationMessageExtractor extractor = new ProjectVersionNotificationMessageExtractor(providerKey, servicesFactoryCache);
ProviderMessageHolder providerMessageHolder = extractor.extract(notificationContentWrapper, projectVersionNotificationContent);
assertEquals(1, providerMessageHolder.getProjectMessages().size());
assertEquals(0, providerMessageHolder.getSimpleMessages().size());
ProjectMessage projectMessage = providerMessageHolder.getProjectMessages().get(0);
assertEquals(MessageReason.PROJECT_VERSION_STATUS, projectMessage.getMessageReason());
assertTrue(projectMessage.getOperation().isPresent());
assertEquals(ProjectOperation.CREATE, projectMessage.getOperation().get());
assertTrue(projectMessage.getBomComponents().isEmpty());
assertEquals(PROJECT, projectMessage.getProject().getValue());
assertTrue(projectMessage.getProject().getUrl().isPresent());
assertEquals(PROJECT_URL, projectMessage.getProject().getUrl().get());
assertTrue(projectMessage.getProjectVersion().isPresent());
LinkableItem projectVersion = projectMessage.getProjectVersion().get();
assertEquals(PROJECT_VERSION, projectVersion.getValue());
assertTrue(projectVersion.getUrl().isPresent());
assertEquals(PROJECT_VERSION_URL, projectVersion.getUrl().get());
}
use of com.synopsys.integration.alert.processor.api.extract.model.project.ProjectMessage in project hub-alert by blackducksoftware.
the class IssueTrackerSearcherTest method findIssuesProject.
@Test
public void findIssuesProject() throws AlertException {
ProjectMessage projectMessage = ProjectMessage.projectStatusInfo(PROVIDER_DETAILS, PROJECT_ITEM, ProjectOperation.CREATE);
IssueTrackerSearcher<String> searcher = new IssueTrackerSearcher<>(null, null, null, null, modelTransformer);
List<ActionableIssueSearchResult<String>> foundIssues = searcher.findIssues(projectMessage);
assertEquals(0, foundIssues.size());
}
use of com.synopsys.integration.alert.processor.api.extract.model.project.ProjectMessage in project hub-alert by blackducksoftware.
the class IssueTrackerModelExtractorTest method extractProjectMessageIssueModelsCommentTest.
@Test
public void extractProjectMessageIssueModelsCommentTest() throws AlertException {
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.UPDATE, 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.UPDATE);
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");
assertEquals(0, modelHolder.getIssueCreationModels().size());
assertEquals(0, modelHolder.getIssueTransitionModels().size());
assertEquals(1, modelHolder.getIssueCommentModels().size());
}
Aggregations