Search in sources :

Example 6 with ProjectOperation

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);
}
Also used : LinkableItem(com.synopsys.integration.alert.common.message.model.LinkableItem) ProjectMessage(com.synopsys.integration.alert.processor.api.extract.model.project.ProjectMessage) ProjectOperation(com.synopsys.integration.alert.processor.api.extract.model.project.ProjectOperation) Test(org.junit.jupiter.api.Test)

Example 7 with ProjectOperation

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);
}
Also used : LinkableItem(com.synopsys.integration.alert.common.message.model.LinkableItem) ProjectMessage(com.synopsys.integration.alert.processor.api.extract.model.project.ProjectMessage) ProjectOperation(com.synopsys.integration.alert.processor.api.extract.model.project.ProjectOperation) Test(org.junit.jupiter.api.Test)

Example 8 with ProjectOperation

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());
}
Also used : AlertNotificationModel(com.synopsys.integration.alert.common.rest.model.AlertNotificationModel) LinkableItem(com.synopsys.integration.alert.common.message.model.LinkableItem) ProjectMessage(com.synopsys.integration.alert.processor.api.extract.model.project.ProjectMessage) ProviderDetails(com.synopsys.integration.alert.processor.api.extract.model.ProviderDetails) BlackDuckServicesFactory(com.synopsys.integration.blackduck.service.BlackDuckServicesFactory) ProviderMessageHolder(com.synopsys.integration.alert.processor.api.extract.model.ProviderMessageHolder) AlertConfigurationException(com.synopsys.integration.alert.api.common.model.exception.AlertConfigurationException) ProjectOperation(com.synopsys.integration.alert.processor.api.extract.model.project.ProjectOperation)

Example 9 with ProjectOperation

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());
}
Also used : AlertNotificationModel(com.synopsys.integration.alert.common.rest.model.AlertNotificationModel) LinkableItem(com.synopsys.integration.alert.common.message.model.LinkableItem) ProjectMessage(com.synopsys.integration.alert.processor.api.extract.model.project.ProjectMessage) ProviderDetails(com.synopsys.integration.alert.processor.api.extract.model.ProviderDetails) BlackDuckServicesFactory(com.synopsys.integration.blackduck.service.BlackDuckServicesFactory) ProviderMessageHolder(com.synopsys.integration.alert.processor.api.extract.model.ProviderMessageHolder) AlertConfigurationException(com.synopsys.integration.alert.api.common.model.exception.AlertConfigurationException) ProjectOperation(com.synopsys.integration.alert.processor.api.extract.model.project.ProjectOperation)

Example 10 with ProjectOperation

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));
}
Also used : ProjectMessage(com.synopsys.integration.alert.processor.api.extract.model.project.ProjectMessage) ProcessedProviderMessage(com.synopsys.integration.alert.processor.api.extract.model.ProcessedProviderMessage) SimpleMessage(com.synopsys.integration.alert.processor.api.extract.model.SimpleMessage) ProjectOperation(com.synopsys.integration.alert.processor.api.extract.model.project.ProjectOperation) Test(org.junit.jupiter.api.Test)

Aggregations

ProjectMessage (com.synopsys.integration.alert.processor.api.extract.model.project.ProjectMessage)12 ProjectOperation (com.synopsys.integration.alert.processor.api.extract.model.project.ProjectOperation)12 LinkableItem (com.synopsys.integration.alert.common.message.model.LinkableItem)9 Test (org.junit.jupiter.api.Test)9 ProcessedProviderMessage (com.synopsys.integration.alert.processor.api.extract.model.ProcessedProviderMessage)4 SimpleMessage (com.synopsys.integration.alert.processor.api.extract.model.SimpleMessage)4 ProviderDetails (com.synopsys.integration.alert.processor.api.extract.model.ProviderDetails)3 AlertConfigurationException (com.synopsys.integration.alert.api.common.model.exception.AlertConfigurationException)2 AlertNotificationModel (com.synopsys.integration.alert.common.rest.model.AlertNotificationModel)2 ProviderMessageHolder (com.synopsys.integration.alert.processor.api.extract.model.ProviderMessageHolder)2 BlackDuckServicesFactory (com.synopsys.integration.blackduck.service.BlackDuckServicesFactory)2 ProcessedProviderMessageHolder (com.synopsys.integration.alert.processor.api.extract.model.ProcessedProviderMessageHolder)1 ArrayList (java.util.ArrayList)1