use of com.synopsys.integration.alert.processor.api.extract.model.project.ProjectOperation in project hub-alert by blackducksoftware.
the class ProcessedProviderMessageTest method combineProviderDetailsDontMatchTest.
@Test
public void combineProviderDetailsDontMatchTest() {
LinkableItem commonProject = new LinkableItem("Project", "Common Project");
ProjectOperation commonOperation = ProjectOperation.CREATE;
LinkableItem provider1 = new LinkableItem("Provider", "Provider 1");
ProviderDetails providerDetails1 = new ProviderDetails(1L, provider1);
ProjectMessage projectMessage1 = ProjectMessage.projectStatusInfo(providerDetails1, commonProject, commonOperation);
LinkableItem provider2 = new LinkableItem("Provider", "Provider 2");
ProviderDetails providerDetails2 = new ProviderDetails(2L, provider2);
ProjectMessage projectMessage2 = ProjectMessage.projectStatusInfo(providerDetails2, commonProject, commonOperation);
ProcessedProviderMessage<ProjectMessage> processedProviderMessage1 = ProcessedProviderMessage.singleSource(10L, projectMessage1);
ProcessedProviderMessage<ProjectMessage> processedProviderMessage2 = ProcessedProviderMessage.singleSource(20L, projectMessage2);
assertNotCombined(processedProviderMessage1, processedProviderMessage2);
}
use of com.synopsys.integration.alert.processor.api.extract.model.project.ProjectOperation 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.ProjectOperation in project hub-alert by blackducksoftware.
the class ProjectVersionNotificationMessageExtractor method extract.
@Override
protected ProviderMessageHolder extract(NotificationContentWrapper notificationContentWrapper, ProjectVersionNotificationContent notificationContent) {
AlertNotificationModel alertNotificationModel = notificationContentWrapper.getAlertNotificationModel();
Long providerConfigId = alertNotificationModel.getProviderConfigId();
String providerUrl;
try {
BlackDuckServicesFactory blackDuckServicesFactory = servicesFactoryCache.retrieveBlackDuckServicesFactory(providerConfigId);
providerUrl = blackDuckServicesFactory.getBlackDuckHttpClient().getBlackDuckUrl().string();
} catch (AlertConfigurationException e) {
logger.warn("Invalid BlackDuck configuration for notification. ID: {}. Name: {}", providerConfigId, alertNotificationModel.getProviderConfigName(), e);
return ProviderMessageHolder.empty();
}
LinkableItem providerItem = new LinkableItem(blackDuckProviderKey.getDisplayName(), alertNotificationModel.getProviderConfigName(), providerUrl);
ProviderDetails providerDetails = new ProviderDetails(alertNotificationModel.getProviderConfigId(), providerItem);
LinkableItem project = new LinkableItem(BlackDuckMessageLabels.LABEL_PROJECT, notificationContent.getProjectName(), notificationContent.getProject());
LinkableItem projectVersion = new LinkableItem(BlackDuckMessageLabels.LABEL_PROJECT_VERSION, notificationContent.getProjectVersionName(), notificationContent.getProjectVersion());
ProjectOperation operation = ProjectOperation.fromOperationType(notificationContent.getOperationType());
ProjectMessage projectVersionMessage = ProjectMessage.projectVersionStatusInfo(providerDetails, project, projectVersion, operation);
return new ProviderMessageHolder(List.of(projectVersionMessage), List.of());
}
use of com.synopsys.integration.alert.processor.api.extract.model.project.ProjectOperation in project hub-alert by blackducksoftware.
the class ProjectNotificationMessageExtractor method extract.
@Override
protected ProviderMessageHolder extract(NotificationContentWrapper notificationContentWrapper, ProjectNotificationContent notificationContent) {
AlertNotificationModel alertNotificationModel = notificationContentWrapper.getAlertNotificationModel();
Long providerConfigId = alertNotificationModel.getProviderConfigId();
String providerUrl;
try {
BlackDuckServicesFactory blackDuckServicesFactory = servicesFactoryCache.retrieveBlackDuckServicesFactory(providerConfigId);
providerUrl = blackDuckServicesFactory.getBlackDuckHttpClient().getBlackDuckUrl().string();
} catch (AlertConfigurationException e) {
logger.warn("Invalid BlackDuck configuration for notification. ID: {}. Name: {}", providerConfigId, alertNotificationModel.getProviderConfigName(), e);
return ProviderMessageHolder.empty();
}
LinkableItem providerItem = new LinkableItem(blackDuckProviderKey.getDisplayName(), alertNotificationModel.getProviderConfigName(), providerUrl);
ProviderDetails providerDetails = new ProviderDetails(alertNotificationModel.getProviderConfigId(), providerItem);
LinkableItem project = new LinkableItem(BlackDuckMessageLabels.LABEL_PROJECT, notificationContent.getProjectName(), notificationContent.getProject());
ProjectOperation operation = ProjectOperation.fromOperationType(notificationContent.getOperationType());
ProjectMessage projectMessage = ProjectMessage.projectStatusInfo(providerDetails, project, operation);
return new ProviderMessageHolder(List.of(projectMessage), List.of());
}
use of com.synopsys.integration.alert.processor.api.extract.model.project.ProjectOperation in project hub-alert by blackducksoftware.
the class ProjectMessageSummarizerTest method summarizeProjectStatusDeletedTest.
@Test
public void summarizeProjectStatusDeletedTest() {
ProjectOperation commonOperation = ProjectOperation.DELETE;
ProjectMessage projectMessage = ProjectMessage.projectStatusInfo(providerDetails, commonProject, commonOperation);
ProcessedProviderMessage<ProjectMessage> processedProviderMessage = new ProcessedProviderMessage<>(Set.of(1L), projectMessage);
ProcessedProviderMessage<SimpleMessage> summarizedSimpleMessage = projectMessageSummarizer.summarize(processedProviderMessage);
SimpleMessage simpleMessage = summarizedSimpleMessage.getProviderMessage();
printSimpleMessage(simpleMessage);
testProjectStatus(simpleMessage);
assertEquals(1, simpleMessage.getDetails().size());
assertTrue(simpleMessage.getDetails().contains(commonProject));
assertTrue(simpleMessage.getSummary().contains(ProjectMessageSummarizer.OP_PARTICIPLE_DELETED));
}
Aggregations