use of com.synopsys.integration.alert.performance.utility.BlackDuckProviderService 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.
}
}
use of com.synopsys.integration.alert.performance.utility.BlackDuckProviderService 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);
}
use of com.synopsys.integration.alert.performance.utility.BlackDuckProviderService 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);
}
use of com.synopsys.integration.alert.performance.utility.BlackDuckProviderService 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);
}
use of com.synopsys.integration.alert.performance.utility.BlackDuckProviderService in project hub-alert by blackducksoftware.
the class CopyJobPerformanceTest method copyJobTest.
@Test
@Ignore
@Disabled
public void copyJobTest() throws IntegrationException {
ExternalAlertRequestUtility alertRequestUtility = new ExternalAlertRequestUtility(intLogger, client, alertURL);
// Create an authenticated connection to Alert
alertRequestUtility.loginToExternalAlert();
BlackDuckProviderService blackDuckProviderService = new BlackDuckProviderService(alertRequestUtility, gson);
ConfigurationManager configurationManager = new ConfigurationManager(gson, alertRequestUtility, blackDuckProviderService.getBlackDuckProviderKey(), ChannelKeys.SLACK.getUniversalKey());
int count = 1000;
String jobName = URLEncoder.encode("Jira Server", Charset.defaultCharset());
for (int index = 1; index <= count; index++) {
String newJobName = String.format("%s_%d", jobName, index);
configurationManager.copyJob(jobName, newJobName);
}
}
Aggregations