Search in sources :

Example 1 with LicenseLimitNotificationContent

use of com.synopsys.integration.blackduck.api.manual.component.LicenseLimitNotificationContent in project hub-alert by blackducksoftware.

the class LicenseLimitNotificationDetailExtractorTest method extractDetailedContentTest.

@Test
public void extractDetailedContentTest() {
    LicenseLimitNotificationDetailExtractor extractor = new LicenseLimitNotificationDetailExtractor();
    LicenseLimitNotificationView notificationView = new LicenseLimitNotificationView();
    LicenseLimitNotificationContent notificationContent = new LicenseLimitNotificationContent();
    notificationView.setContent(notificationContent);
    AlertNotificationModel notification = new AlertNotificationModel(0L, 0L, "BlackDuck", "Config 1", null, null, null, null, false);
    List<DetailedNotificationContent> detailedNotificationContents = extractor.extractDetailedContent(notification, notificationView);
    assertEquals(1, detailedNotificationContents.size());
    DetailedNotificationContent detailedNotificationContent = detailedNotificationContents.get(0);
    assertTrue(detailedNotificationContent.getProjectName().isEmpty(), "Expected no project name to be present");
    assertTrue(detailedNotificationContent.getPolicyName().isEmpty(), "Expected no policy name to be present");
    assertEquals(0, detailedNotificationContent.getVulnerabilitySeverities().size());
}
Also used : AlertNotificationModel(com.synopsys.integration.alert.common.rest.model.AlertNotificationModel) LicenseLimitNotificationContent(com.synopsys.integration.blackduck.api.manual.component.LicenseLimitNotificationContent) DetailedNotificationContent(com.synopsys.integration.alert.processor.api.detail.DetailedNotificationContent) LicenseLimitNotificationView(com.synopsys.integration.blackduck.api.manual.view.LicenseLimitNotificationView) Test(org.junit.jupiter.api.Test)

Example 2 with LicenseLimitNotificationContent

use of com.synopsys.integration.blackduck.api.manual.component.LicenseLimitNotificationContent in project hub-alert by blackducksoftware.

the class LicenseLimitNotificationMessageExtractorTest method extractTest.

@Test
public void extractTest() {
    LicenseLimitNotificationContent notificationContentComponent = createLicenseLimitNotificationContent();
    NotificationContentWrapper notificationContentWrapper = createNotificationContentWrapper(notificationContentComponent);
    LicenseLimitNotificationMessageExtractor licenseLimitNotificationMessageExtractor = new LicenseLimitNotificationMessageExtractor(blackDuckProviderKey);
    ProviderMessageHolder providerMessageHolder = licenseLimitNotificationMessageExtractor.extract(notificationContentWrapper, notificationContentComponent);
    assertEquals(0, providerMessageHolder.getProjectMessages().size());
    assertEquals(1, providerMessageHolder.getSimpleMessages().size());
    SimpleMessage simpleMessage = providerMessageHolder.getSimpleMessages().get(0);
    assertEquals(summary, simpleMessage.getSummary());
    assertEquals(description, simpleMessage.getDescription());
    assertEquals(4, simpleMessage.getDetails().size());
}
Also used : LicenseLimitNotificationContent(com.synopsys.integration.blackduck.api.manual.component.LicenseLimitNotificationContent) SimpleMessage(com.synopsys.integration.alert.processor.api.extract.model.SimpleMessage) ProviderMessageHolder(com.synopsys.integration.alert.processor.api.extract.model.ProviderMessageHolder) NotificationContentWrapper(com.synopsys.integration.alert.processor.api.filter.NotificationContentWrapper) Test(org.junit.jupiter.api.Test)

Example 3 with LicenseLimitNotificationContent

use of com.synopsys.integration.blackduck.api.manual.component.LicenseLimitNotificationContent in project hub-alert by blackducksoftware.

the class LicenseLimitNotificationMessageExtractorTest method createLicenseLimitNotificationContent.

private LicenseLimitNotificationContent createLicenseLimitNotificationContent() {
    LicenseLimitNotificationContent licenseLimitNotificationContent = new LicenseLimitNotificationContent();
    licenseLimitNotificationContent.setLicenseViolationType(LicenseLimitType.MANAGED_CODEBASE_BYTES_NEW);
    licenseLimitNotificationContent.setMessage(description);
    licenseLimitNotificationContent.setMarketingPageUrl("http://someUrl");
    licenseLimitNotificationContent.setUsedCodeSize(100L);
    licenseLimitNotificationContent.setHardLimit(200L);
    licenseLimitNotificationContent.setSoftLimit(150L);
    return licenseLimitNotificationContent;
}
Also used : LicenseLimitNotificationContent(com.synopsys.integration.blackduck.api.manual.component.LicenseLimitNotificationContent)

Example 4 with LicenseLimitNotificationContent

use of com.synopsys.integration.blackduck.api.manual.component.LicenseLimitNotificationContent in project hub-alert by blackducksoftware.

the class DetailedNotificationContentTest method projectlessTest.

@Test
public void projectlessTest() {
    LicenseLimitNotificationContent licenseLimitNotificationContent = new LicenseLimitNotificationContent();
    DetailedNotificationContent detailedContent = DetailedNotificationContent.projectless(ALERT_NOTIFICATION_MODEL, licenseLimitNotificationContent);
    assertContent(detailedContent, ALERT_NOTIFICATION_MODEL.getProviderConfigId(), licenseLimitNotificationContent.getClass(), List.of());
    assertTrue(detailedContent.getProjectName().isEmpty(), "Expected no project name");
    assertTrue(detailedContent.getPolicyName().isEmpty(), EXPECTED_NO_POLICY);
}
Also used : LicenseLimitNotificationContent(com.synopsys.integration.blackduck.api.manual.component.LicenseLimitNotificationContent) Test(org.junit.jupiter.api.Test)

Aggregations

LicenseLimitNotificationContent (com.synopsys.integration.blackduck.api.manual.component.LicenseLimitNotificationContent)4 Test (org.junit.jupiter.api.Test)3 AlertNotificationModel (com.synopsys.integration.alert.common.rest.model.AlertNotificationModel)1 DetailedNotificationContent (com.synopsys.integration.alert.processor.api.detail.DetailedNotificationContent)1 ProviderMessageHolder (com.synopsys.integration.alert.processor.api.extract.model.ProviderMessageHolder)1 SimpleMessage (com.synopsys.integration.alert.processor.api.extract.model.SimpleMessage)1 NotificationContentWrapper (com.synopsys.integration.alert.processor.api.filter.NotificationContentWrapper)1 LicenseLimitNotificationView (com.synopsys.integration.blackduck.api.manual.view.LicenseLimitNotificationView)1