Search in sources :

Example 1 with AlertRequestUtility

use of com.synopsys.integration.alert.performance.utility.AlertRequestUtility in project hub-alert by blackducksoftware.

the class ComponentUnknownVersionNotificationSerializationTest method testNotificationSerialization.

@Test
@Ignore
@Disabled
public void testNotificationSerialization() throws IntegrationException, InterruptedException {
    LocalDateTime searchStartTime = LocalDateTime.now().minusMinutes(1);
    AlertRequestUtility alertRequestUtility = IntegrationPerformanceTestRunner.createAlertRequestUtility(webApplicationContext);
    BlackDuckProviderService blackDuckProviderService = new BlackDuckProviderService(alertRequestUtility, gson);
    configureJob(alertRequestUtility, blackDuckProviderService);
    ExternalId externalId = new ExternalId(Forge.MAVEN);
    externalId.setGroup("commons-fileupload");
    externalId.setName("commons-fileupload");
    Predicate<ProjectVersionComponentVersionView> componentFilter = (component) -> component.getComponentName().equals("Apache Commons FileUpload");
    blackDuckProviderService.triggerBlackDuckNotification(() -> externalId, componentFilter);
    try {
        WaitJobConfig waitJobConfig = new WaitJobConfig(intLogger, "notification serialization test notification wait", 300, searchStartTime.atZone(ZoneId.systemDefault()).toInstant().toEpochMilli(), 20);
        NotificationReceivedWaitJobTask notificationWaitJobTask = new NotificationReceivedWaitJobTask(notificationAccessor, searchStartTime, "Apache Commons FileUpload", null, NotificationType.COMPONENT_UNKNOWN_VERSION);
        WaitJob<Boolean> waitForNotificationToBeProcessed = WaitJob.createSimpleWait(waitJobConfig, notificationWaitJobTask);
        boolean isComplete = waitForNotificationToBeProcessed.waitFor();
        if (isComplete) {
            String notificationContent = notificationWaitJobTask.getNotificationContent().orElseThrow(() -> new IllegalStateException("Expected notification is missing."));
            BlackDuckResponseResolver resolver = blackDuckProviderService.getBlackDuckServicesFactory().getBlackDuckResponseResolver();
            ComponentUnknownVersionNotificationView notificationView = resolver.resolve(notificationContent, ComponentUnknownVersionNotificationView.class);
            assertNotNull(notificationView.getContent());
            assertTrue(StringUtils.isNotBlank(notificationView.getContent().getComponentName()));
            BlackDuckApiClient apiClient = blackDuckProviderService.getBlackDuckServicesFactory().getBlackDuckApiClient();
            Optional<HttpUrl> componentUrl = HttpUrl.createSafely(notificationView.getContent().getBomComponent());
            if (componentUrl.isPresent()) {
                apiClient.delete(componentUrl.get());
            }
        }
    } catch (InterruptedException ex) {
    // if a timeout happens that's ok we are trying to ensure deserialization is correct.
    }
}
Also used : LocalDateTime(java.time.LocalDateTime) IntegrationException(com.synopsys.integration.exception.IntegrationException) DescriptorMocker(com.synopsys.integration.alert.util.DescriptorMocker) LoggerFactory(org.slf4j.LoggerFactory) Autowired(org.springframework.beans.factory.annotation.Autowired) FrequencyType(com.synopsys.integration.alert.common.enumeration.FrequencyType) BlackDuckResponseResolver(com.synopsys.integration.blackduck.http.transform.subclass.BlackDuckResponseResolver) Disabled(org.junit.jupiter.api.Disabled) StringUtils(org.apache.commons.lang3.StringUtils) TestTags(com.synopsys.integration.alert.test.common.TestTags) HttpUrl(com.synopsys.integration.rest.HttpUrl) BeforeAll(org.junit.jupiter.api.BeforeAll) Gson(com.google.gson.Gson) Map(java.util.Map) Tag(org.junit.jupiter.api.Tag) TestPropertyKey(com.synopsys.integration.alert.test.common.TestPropertyKey) ExternalId(com.synopsys.integration.bdio.model.externalid.ExternalId) WebAppConfiguration(org.springframework.test.context.web.WebAppConfiguration) ProjectVersionComponentVersionView(com.synopsys.integration.blackduck.api.generated.view.ProjectVersionComponentVersionView) Slf4jIntLogger(com.synopsys.integration.log.Slf4jIntLogger) Predicate(java.util.function.Predicate) WebApplicationContext(org.springframework.web.context.WebApplicationContext) TestPropertySource(org.springframework.test.context.TestPropertySource) IntegrationPerformanceTestRunner(com.synopsys.integration.alert.performance.utility.IntegrationPerformanceTestRunner) ApplicationConfiguration(com.synopsys.integration.alert.configuration.ApplicationConfiguration) NotificationType(com.synopsys.integration.blackduck.api.manual.enumeration.NotificationType) ZoneId(java.time.ZoneId) WaitJob(com.synopsys.integration.wait.WaitJob) Test(org.junit.jupiter.api.Test) SlackDescriptor(com.synopsys.integration.alert.channel.slack.descriptor.SlackDescriptor) List(java.util.List) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) Optional(java.util.Optional) DatabaseDataSource(com.synopsys.integration.alert.database.DatabaseDataSource) ChannelKeys(com.synopsys.integration.alert.descriptor.api.model.ChannelKeys) TestProperties(com.synopsys.integration.alert.test.common.TestProperties) Assertions.assertNotNull(org.junit.jupiter.api.Assertions.assertNotNull) WaitJobConfig(com.synopsys.integration.wait.WaitJobConfig) Forge(com.synopsys.integration.bdio.model.Forge) LocalDateTime(java.time.LocalDateTime) HashMap(java.util.HashMap) IntLogger(com.synopsys.integration.log.IntLogger) AlertRequestUtility(com.synopsys.integration.alert.performance.utility.AlertRequestUtility) BlackDuckProviderService(com.synopsys.integration.alert.performance.utility.BlackDuckProviderService) BlackDuckApiClient(com.synopsys.integration.blackduck.service.BlackDuckApiClient) ConfigurationManager(com.synopsys.integration.alert.performance.utility.ConfigurationManager) ChannelDescriptor(com.synopsys.integration.alert.common.descriptor.ChannelDescriptor) NotificationAccessor(com.synopsys.integration.alert.common.persistence.accessor.NotificationAccessor) Application(com.synopsys.integration.alert.Application) ComponentUnknownVersionNotificationView(com.synopsys.integration.blackduck.api.manual.view.ComponentUnknownVersionNotificationView) Ignore(org.junit.Ignore) ContextConfiguration(org.springframework.test.context.ContextConfiguration) FieldValueModel(com.synopsys.integration.alert.common.rest.model.FieldValueModel) BlackDuckResponseResolver(com.synopsys.integration.blackduck.http.transform.subclass.BlackDuckResponseResolver) AlertRequestUtility(com.synopsys.integration.alert.performance.utility.AlertRequestUtility) BlackDuckProviderService(com.synopsys.integration.alert.performance.utility.BlackDuckProviderService) ExternalId(com.synopsys.integration.bdio.model.externalid.ExternalId) BlackDuckApiClient(com.synopsys.integration.blackduck.service.BlackDuckApiClient) HttpUrl(com.synopsys.integration.rest.HttpUrl) WaitJobConfig(com.synopsys.integration.wait.WaitJobConfig) ComponentUnknownVersionNotificationView(com.synopsys.integration.blackduck.api.manual.view.ComponentUnknownVersionNotificationView) ProjectVersionComponentVersionView(com.synopsys.integration.blackduck.api.generated.view.ProjectVersionComponentVersionView) Ignore(org.junit.Ignore) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Disabled(org.junit.jupiter.api.Disabled)

Example 2 with AlertRequestUtility

use of com.synopsys.integration.alert.performance.utility.AlertRequestUtility in project hub-alert by blackducksoftware.

the class JiraServerPerformanceTest method createTestRunner.

private IntegrationPerformanceTestRunner createTestRunner() {
    AlertRequestUtility alertRequestUtility = IntegrationPerformanceTestRunner.createAlertRequestUtility(webApplicationContext);
    BlackDuckProviderService blackDuckProviderService = new BlackDuckProviderService(alertRequestUtility, gson);
    ConfigurationManager configurationManager = new ConfigurationManager(gson, alertRequestUtility, blackDuckProviderService.getBlackDuckProviderKey(), CHANNEL_KEY.getUniversalKey());
    return new IntegrationPerformanceTestRunner(gson, dateTimeFormatter, alertRequestUtility, blackDuckProviderService, configurationManager);
}
Also used : AlertRequestUtility(com.synopsys.integration.alert.performance.utility.AlertRequestUtility) BlackDuckProviderService(com.synopsys.integration.alert.performance.utility.BlackDuckProviderService) IntegrationPerformanceTestRunner(com.synopsys.integration.alert.performance.utility.IntegrationPerformanceTestRunner) ConfigurationManager(com.synopsys.integration.alert.performance.utility.ConfigurationManager)

Example 3 with AlertRequestUtility

use of com.synopsys.integration.alert.performance.utility.AlertRequestUtility in project hub-alert by blackducksoftware.

the class JiraCloudPerformanceTest method createTestRunner.

private IntegrationPerformanceTestRunner createTestRunner() {
    AlertRequestUtility alertRequestUtility = IntegrationPerformanceTestRunner.createAlertRequestUtility(webApplicationContext);
    BlackDuckProviderService blackDuckProviderService = new BlackDuckProviderService(alertRequestUtility, gson);
    ConfigurationManager configurationManager = new ConfigurationManager(gson, alertRequestUtility, blackDuckProviderService.getBlackDuckProviderKey(), CHANNEL_KEY.getUniversalKey());
    return new IntegrationPerformanceTestRunner(gson, dateTimeFormatter, alertRequestUtility, blackDuckProviderService, configurationManager);
}
Also used : AlertRequestUtility(com.synopsys.integration.alert.performance.utility.AlertRequestUtility) BlackDuckProviderService(com.synopsys.integration.alert.performance.utility.BlackDuckProviderService) IntegrationPerformanceTestRunner(com.synopsys.integration.alert.performance.utility.IntegrationPerformanceTestRunner) ConfigurationManager(com.synopsys.integration.alert.performance.utility.ConfigurationManager)

Example 4 with AlertRequestUtility

use of com.synopsys.integration.alert.performance.utility.AlertRequestUtility in project hub-alert by blackducksoftware.

the class EmailPerformanceTest method testEmailJob.

@Test
@Ignore
@Disabled
public void testEmailJob() throws Exception {
    AlertRequestUtility alertRequestUtility = IntegrationPerformanceTestRunner.createAlertRequestUtility(webApplicationContext);
    BlackDuckProviderService blackDuckProviderService = new BlackDuckProviderService(alertRequestUtility, gson);
    ConfigurationManager configurationManager = new ConfigurationManager(gson, alertRequestUtility, blackDuckProviderService.getBlackDuckProviderKey(), EMAIL_CHANNEL_KEY);
    IntegrationPerformanceTestRunner integrationPerformanceTestRunner = new IntegrationPerformanceTestRunner(gson, dateTimeFormatter, alertRequestUtility, blackDuckProviderService, configurationManager);
    Map<String, FieldValueModel> emailGlobalConfigFields = new HashMap<>();
    emailGlobalConfigFields.put(EmailPropertyKeys.JAVAMAIL_HOST_KEY.getPropertyKey(), new FieldValueModel(List.of(EMAIL_SMTP_HOST), true));
    emailGlobalConfigFields.put(EmailPropertyKeys.JAVAMAIL_FROM_KEY.getPropertyKey(), new FieldValueModel(List.of(EMAIL_SMTP_FROM), true));
    emailGlobalConfigFields.put(FieldModelTestAction.KEY_DESTINATION_NAME, new FieldValueModel(List.of(EMAIL_RECIPIENT), true));
    FieldModel emailGlobalConfig = new FieldModel(EMAIL_CHANNEL_KEY, ConfigContextEnum.GLOBAL.name(), emailGlobalConfigFields);
    Map<String, FieldValueModel> emailJobFields = new HashMap<>();
    emailJobFields.put(ChannelDescriptor.KEY_ENABLED, new FieldValueModel(List.of("true"), true));
    emailJobFields.put(ChannelDescriptor.KEY_CHANNEL_NAME, new FieldValueModel(List.of(EMAIL_CHANNEL_KEY), true));
    emailJobFields.put(ChannelDescriptor.KEY_NAME, new FieldValueModel(List.of(EMAIL_PERFORMANCE_JOB_NAME), true));
    emailJobFields.put(ChannelDescriptor.KEY_FREQUENCY, new FieldValueModel(List.of(FrequencyType.REAL_TIME.name()), true));
    emailJobFields.put(ChannelDescriptor.KEY_PROVIDER_TYPE, new FieldValueModel(List.of(blackDuckProviderService.getBlackDuckProviderKey()), true));
    emailJobFields.put(EmailDescriptor.KEY_SUBJECT_LINE, new FieldValueModel(List.of(EMAIL_PERFORMANCE_JOB_NAME), true));
    emailJobFields.put(EmailDescriptor.KEY_EMAIL_ADDITIONAL_ADDRESSES_ONLY, new FieldValueModel(List.of("true"), true));
    emailJobFields.put(EmailDescriptor.KEY_EMAIL_ADDITIONAL_ADDRESSES, new FieldValueModel(List.of(EMAIL_RECIPIENT), true));
    integrationPerformanceTestRunner.runTest(emailGlobalConfig, emailJobFields, EMAIL_PERFORMANCE_JOB_NAME);
}
Also used : AlertRequestUtility(com.synopsys.integration.alert.performance.utility.AlertRequestUtility) BlackDuckProviderService(com.synopsys.integration.alert.performance.utility.BlackDuckProviderService) IntegrationPerformanceTestRunner(com.synopsys.integration.alert.performance.utility.IntegrationPerformanceTestRunner) HashMap(java.util.HashMap) FieldModel(com.synopsys.integration.alert.common.rest.model.FieldModel) ConfigurationManager(com.synopsys.integration.alert.performance.utility.ConfigurationManager) FieldValueModel(com.synopsys.integration.alert.common.rest.model.FieldValueModel) Ignore(org.junit.Ignore) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Disabled(org.junit.jupiter.api.Disabled)

Example 5 with AlertRequestUtility

use of com.synopsys.integration.alert.performance.utility.AlertRequestUtility in project hub-alert by blackducksoftware.

the class MsTeamsPerformanceTest method testMsTeamsJob.

@Test
@Ignore
@Disabled
public void testMsTeamsJob() throws Exception {
    AlertRequestUtility alertRequestUtility = IntegrationPerformanceTestRunner.createAlertRequestUtility(webApplicationContext);
    BlackDuckProviderService blackDuckProviderService = new BlackDuckProviderService(alertRequestUtility, gson);
    ConfigurationManager configurationManager = new ConfigurationManager(gson, alertRequestUtility, blackDuckProviderService.getBlackDuckProviderKey(), ChannelKeys.MS_TEAMS.getUniversalKey());
    IntegrationPerformanceTestRunner integrationPerformanceTestRunner = new IntegrationPerformanceTestRunner(gson, dateTimeFormatter, alertRequestUtility, blackDuckProviderService, configurationManager);
    Map<String, FieldValueModel> msTeamsJobFields = new HashMap<>();
    msTeamsJobFields.put(ChannelDescriptor.KEY_ENABLED, new FieldValueModel(List.of("true"), true));
    msTeamsJobFields.put(ChannelDescriptor.KEY_CHANNEL_NAME, new FieldValueModel(List.of(ChannelKeys.MS_TEAMS.getUniversalKey()), true));
    msTeamsJobFields.put(ChannelDescriptor.KEY_NAME, new FieldValueModel(List.of(MS_TEAMS_PERFORMANCE_JOB_NAME), true));
    msTeamsJobFields.put(ChannelDescriptor.KEY_FREQUENCY, new FieldValueModel(List.of(FrequencyType.REAL_TIME.name()), true));
    msTeamsJobFields.put(ChannelDescriptor.KEY_PROVIDER_TYPE, new FieldValueModel(List.of(blackDuckProviderService.getBlackDuckProviderKey()), true));
    msTeamsJobFields.put(MsTeamsDescriptor.KEY_WEBHOOK, new FieldValueModel(List.of(MSTEAMS_CHANNEL_WEBHOOK), true));
    integrationPerformanceTestRunner.runTest(msTeamsJobFields, MS_TEAMS_PERFORMANCE_JOB_NAME);
}
Also used : AlertRequestUtility(com.synopsys.integration.alert.performance.utility.AlertRequestUtility) BlackDuckProviderService(com.synopsys.integration.alert.performance.utility.BlackDuckProviderService) IntegrationPerformanceTestRunner(com.synopsys.integration.alert.performance.utility.IntegrationPerformanceTestRunner) HashMap(java.util.HashMap) ConfigurationManager(com.synopsys.integration.alert.performance.utility.ConfigurationManager) FieldValueModel(com.synopsys.integration.alert.common.rest.model.FieldValueModel) Ignore(org.junit.Ignore) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Disabled(org.junit.jupiter.api.Disabled)

Aggregations

AlertRequestUtility (com.synopsys.integration.alert.performance.utility.AlertRequestUtility)6 BlackDuckProviderService (com.synopsys.integration.alert.performance.utility.BlackDuckProviderService)6 ConfigurationManager (com.synopsys.integration.alert.performance.utility.ConfigurationManager)6 IntegrationPerformanceTestRunner (com.synopsys.integration.alert.performance.utility.IntegrationPerformanceTestRunner)6 FieldValueModel (com.synopsys.integration.alert.common.rest.model.FieldValueModel)4 HashMap (java.util.HashMap)4 Ignore (org.junit.Ignore)4 Disabled (org.junit.jupiter.api.Disabled)3 Test (org.junit.jupiter.api.Test)3 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)3 Gson (com.google.gson.Gson)1 Application (com.synopsys.integration.alert.Application)1 SlackDescriptor (com.synopsys.integration.alert.channel.slack.descriptor.SlackDescriptor)1 ChannelDescriptor (com.synopsys.integration.alert.common.descriptor.ChannelDescriptor)1 FrequencyType (com.synopsys.integration.alert.common.enumeration.FrequencyType)1 NotificationAccessor (com.synopsys.integration.alert.common.persistence.accessor.NotificationAccessor)1 FieldModel (com.synopsys.integration.alert.common.rest.model.FieldModel)1 ApplicationConfiguration (com.synopsys.integration.alert.configuration.ApplicationConfiguration)1 DatabaseDataSource (com.synopsys.integration.alert.database.DatabaseDataSource)1 ChannelKeys (com.synopsys.integration.alert.descriptor.api.model.ChannelKeys)1