use of com.synopsys.integration.alert.processor.api.extract.model.ProviderMessageHolder in project hub-alert by blackducksoftware.
the class SlackDistributionEventHandlerTest method createTwoMessages.
private ProviderMessageHolder createTwoMessages() {
ProviderDetails providerDetails = new ProviderDetails(1L, new LinkableItem("", ""));
SimpleMessage simpleMessage = SimpleMessage.original(providerDetails, "", "", List.of());
return new ProviderMessageHolder(List.of(), List.of(simpleMessage, simpleMessage));
}
use of com.synopsys.integration.alert.processor.api.extract.model.ProviderMessageHolder in project hub-alert by blackducksoftware.
the class JiraServerExternalConnectionTest method createMessage.
private ProviderMessageHolder createMessage() {
ProviderDetails providerDetails = new ProviderDetails(1L, new LinkableItem("ProviderLabel", "ProviderName"));
SimpleMessage simpleMessage = SimpleMessage.original(providerDetails, "Test Summary", "Test Description", List.of());
return new ProviderMessageHolder(List.of(), List.of(simpleMessage));
}
use of com.synopsys.integration.alert.processor.api.extract.model.ProviderMessageHolder 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.ProviderMessageHolder 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.ProviderMessageHolder 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());
}
Aggregations