Search in sources :

Example 1 with ProxyManager

use of com.synopsys.integration.alert.common.rest.proxy.ProxyManager in project hub-alert by blackducksoftware.

the class PhoneHomeTest method runTest.

@Test
public void runTest() {
    RestApiAuditAccessor auditAccessor = Mockito.mock(RestApiAuditAccessor.class);
    Mockito.when(auditAccessor.findFirstByJobId(Mockito.any())).thenReturn(Optional.empty());
    TaskScheduler taskScheduler = Mockito.mock(TaskScheduler.class);
    ProxyManager proxyManager = Mockito.mock(ProxyManager.class);
    Mockito.when(proxyManager.createProxyInfoForHost(Mockito.anyString())).thenReturn(ProxyInfo.NO_PROXY_INFO);
    AboutReader aboutReader = Mockito.mock(AboutReader.class);
    Mockito.when(aboutReader.getProductVersion()).thenReturn(TEST_VERSION);
    JobAccessor jobAccessor = Mockito.mock(JobAccessor.class);
    // FIXME implement mocks
    DefaultConfigurationModelConfigurationAccessor configurationModelConfigurationAccessor = Mockito.mock(DefaultConfigurationModelConfigurationAccessor.class);
    ConfigurationModel config = Mockito.mock(ConfigurationModel.class);
    Mockito.when(configurationModelConfigurationAccessor.getConfigurationsByDescriptorKey(Mockito.any(DescriptorKey.class))).thenReturn(List.of(config));
    DescriptorMap descriptorMap = Mockito.mock(DescriptorMap.class);
    Descriptor descriptor = Mockito.mock(Descriptor.class);
    DescriptorKey descriptorKey = Mockito.mock(DescriptorKey.class);
    Mockito.when(descriptorKey.getUniversalKey()).thenReturn(TEST_DESCRIPTOR_NAME);
    Mockito.when(descriptorMap.getDescriptorMap()).thenReturn(Collections.singletonMap(descriptorKey, descriptor));
    List<ProviderPhoneHomeHandler> providerHandlers = List.of();
    ProviderKey providerKey = new BlackDuckProviderKey();
    PhoneHomeTask phoneHomeTask = new PhoneHomeTask(taskScheduler, aboutReader, jobAccessor, configurationModelConfigurationAccessor, null, proxyManager, new Gson(), auditAccessor, providerHandlers, providerKey);
    try {
        phoneHomeTask.run();
    } catch (Exception e) {
        fail("Unexpected exception");
    }
}
Also used : ConfigurationModel(com.synopsys.integration.alert.common.persistence.model.ConfigurationModel) BlackDuckProviderKey(com.synopsys.integration.alert.descriptor.api.BlackDuckProviderKey) PhoneHomeTask(com.synopsys.integration.alert.task.PhoneHomeTask) ProxyManager(com.synopsys.integration.alert.common.rest.proxy.ProxyManager) DescriptorKey(com.synopsys.integration.alert.descriptor.api.model.DescriptorKey) Gson(com.google.gson.Gson) TaskScheduler(org.springframework.scheduling.TaskScheduler) ProviderPhoneHomeHandler(com.synopsys.integration.alert.api.provider.ProviderPhoneHomeHandler) AboutReader(com.synopsys.integration.alert.web.api.about.AboutReader) JobAccessor(com.synopsys.integration.alert.common.persistence.accessor.JobAccessor) DescriptorMap(com.synopsys.integration.alert.common.descriptor.DescriptorMap) ProviderKey(com.synopsys.integration.alert.descriptor.api.model.ProviderKey) BlackDuckProviderKey(com.synopsys.integration.alert.descriptor.api.BlackDuckProviderKey) Descriptor(com.synopsys.integration.alert.common.descriptor.Descriptor) RestApiAuditAccessor(com.synopsys.integration.alert.common.persistence.accessor.RestApiAuditAccessor) DefaultConfigurationModelConfigurationAccessor(com.synopsys.integration.alert.database.api.DefaultConfigurationModelConfigurationAccessor) Test(org.junit.jupiter.api.Test)

Example 2 with ProxyManager

use of com.synopsys.integration.alert.common.rest.proxy.ProxyManager in project hub-alert by blackducksoftware.

the class JiraServerExternalConnectionTest method sendJiraServerMessageTest.

// This test is @Disabled since it requires a running Jira Server instance. In order to run this test, you must deploy a Jira Server and
// add the Jira Server environment values into test.properties
@Test
@Disabled
public void sendJiraServerMessageTest() throws AlertException {
    Gson gson = new Gson();
    JiraMessageFormatter jiraMessageFormatter = new JiraMessageFormatter();
    JiraServerChannelKey jiraServerChannelKey = new JiraServerChannelKey();
    JiraServerGlobalConfigAccessor jiraServerGlobalConfigAccessor = Mockito.mock(JiraServerGlobalConfigAccessor.class);
    Mockito.when(jiraServerGlobalConfigAccessor.getConfigurationByName(Mockito.anyString())).thenReturn(Optional.of(createJiraServerConfigModel()));
    ProxyManager proxyManager = Mockito.mock(ProxyManager.class);
    Mockito.when(proxyManager.createProxyInfoForHost(Mockito.anyString())).thenReturn(null);
    JobAccessor jobAccessor = Mockito.mock(JobAccessor.class);
    Mockito.when(jobAccessor.getJobById(Mockito.any())).thenReturn(Optional.of(createDistributionJobModel()));
    JiraServerPropertiesFactory jiraServerPropertiesFactory = new JiraServerPropertiesFactory(proxyManager, jiraServerGlobalConfigAccessor, jobAccessor);
    IssueTrackerCallbackInfoCreator issueTrackerCallbackInfoCreator = new IssueTrackerCallbackInfoCreator();
    IssueCategoryRetriever issueCategoryRetriever = new IssueCategoryRetriever();
    JiraServerMessageSenderFactory jiraServerMessageSenderFactory = new JiraServerMessageSenderFactory(gson, jiraServerChannelKey, jiraServerPropertiesFactory, issueTrackerCallbackInfoCreator, issueCategoryRetriever);
    ProjectMessageToIssueModelTransformer modelTransformer = new ProjectMessageToIssueModelTransformer();
    JiraServerProcessorFactory jiraServerProcessorFactory = new JiraServerProcessorFactory(gson, jiraMessageFormatter, jiraServerPropertiesFactory, jiraServerMessageSenderFactory, modelTransformer, issueCategoryRetriever);
    IssueTrackerProcessor<String> processor = jiraServerProcessorFactory.createProcessor(createDistributionDetails());
    IssueTrackerResponse<String> response = processor.processMessages(createMessage(), "jobName");
    assertEquals("Success", response.getStatusMessage());
}
Also used : JiraServerChannelKey(com.synopsys.integration.alert.descriptor.api.JiraServerChannelKey) IssueTrackerCallbackInfoCreator(com.synopsys.integration.alert.api.channel.issue.callback.IssueTrackerCallbackInfoCreator) ProxyManager(com.synopsys.integration.alert.common.rest.proxy.ProxyManager) Gson(com.google.gson.Gson) JiraServerGlobalConfigAccessor(com.synopsys.integration.alert.channel.jira.server.database.accessor.JiraServerGlobalConfigAccessor) JiraServerProcessorFactory(com.synopsys.integration.alert.channel.jira.server.distribution.JiraServerProcessorFactory) JobAccessor(com.synopsys.integration.alert.common.persistence.accessor.JobAccessor) JiraMessageFormatter(com.synopsys.integration.alert.api.channel.jira.distribution.JiraMessageFormatter) JiraServerMessageSenderFactory(com.synopsys.integration.alert.channel.jira.server.distribution.JiraServerMessageSenderFactory) ProjectMessageToIssueModelTransformer(com.synopsys.integration.alert.api.channel.issue.convert.ProjectMessageToIssueModelTransformer) IssueCategoryRetriever(com.synopsys.integration.alert.api.channel.issue.search.IssueCategoryRetriever) Test(org.junit.jupiter.api.Test) Disabled(org.junit.jupiter.api.Disabled)

Example 3 with ProxyManager

use of com.synopsys.integration.alert.common.rest.proxy.ProxyManager in project hub-alert by blackducksoftware.

the class SlackChannelTestIT method createConnectionFactory.

private ChannelRestConnectionFactory createConnectionFactory() {
    MockAlertProperties testAlertProperties = new MockAlertProperties();
    ProxyManager proxyManager = Mockito.mock(ProxyManager.class);
    Mockito.when(proxyManager.createProxyInfoForHost(Mockito.anyString())).thenReturn(ProxyInfo.NO_PROXY_INFO);
    return new ChannelRestConnectionFactory(testAlertProperties, proxyManager, gson);
}
Also used : ChannelRestConnectionFactory(com.synopsys.integration.alert.api.channel.rest.ChannelRestConnectionFactory) MockAlertProperties(com.synopsys.integration.alert.test.common.MockAlertProperties) ProxyManager(com.synopsys.integration.alert.common.rest.proxy.ProxyManager)

Example 4 with ProxyManager

use of com.synopsys.integration.alert.common.rest.proxy.ProxyManager in project hub-alert by blackducksoftware.

the class BlackDuckNotificationRetrieverFactoryTest method createBlackDuckProperties.

private BlackDuckProperties createBlackDuckProperties(String blackDuckUrl) {
    ConfigurationModel configurationModel = createConfigurationModel(blackDuckUrl);
    ProxyManager proxyManager = new ProxyManager(new MockSettingsUtility());
    return new BlackDuckProperties(1L, new Gson(), BlackDuckServicesFactory.createDefaultObjectMapper(), new MockAlertProperties(), proxyManager, configurationModel);
}
Also used : ConfigurationModel(com.synopsys.integration.alert.common.persistence.model.ConfigurationModel) BlackDuckProperties(com.synopsys.integration.alert.provider.blackduck.BlackDuckProperties) ProxyManager(com.synopsys.integration.alert.common.rest.proxy.ProxyManager) MockAlertProperties(com.synopsys.integration.alert.test.common.MockAlertProperties) Gson(com.google.gson.Gson)

Example 5 with ProxyManager

use of com.synopsys.integration.alert.common.rest.proxy.ProxyManager in project hub-alert by blackducksoftware.

the class JobNotificationProcessorTest method createNotificationExtractorBlackDuckServicesFactoryCache.

private NotificationExtractorBlackDuckServicesFactoryCache createNotificationExtractorBlackDuckServicesFactoryCache() {
    ConfigurationModelConfigurationAccessor configurationModelConfigurationAccessor = Mockito.mock(ConfigurationModelConfigurationAccessor.class);
    AlertProperties properties = new AlertProperties();
    ProxyManager proxyManager = Mockito.mock(ProxyManager.class);
    BlackDuckPropertiesFactory blackDuckPropertiesFactory = new BlackDuckPropertiesFactory(configurationModelConfigurationAccessor, GSON, properties, proxyManager);
    return new NotificationExtractorBlackDuckServicesFactoryCache(blackDuckPropertiesFactory);
}
Also used : ProxyManager(com.synopsys.integration.alert.common.rest.proxy.ProxyManager) NotificationExtractorBlackDuckServicesFactoryCache(com.synopsys.integration.alert.provider.blackduck.processor.NotificationExtractorBlackDuckServicesFactoryCache) BlackDuckPropertiesFactory(com.synopsys.integration.alert.provider.blackduck.factory.BlackDuckPropertiesFactory) AlertProperties(com.synopsys.integration.alert.common.AlertProperties) ConfigurationModelConfigurationAccessor(com.synopsys.integration.alert.common.persistence.accessor.ConfigurationModelConfigurationAccessor)

Aggregations

ProxyManager (com.synopsys.integration.alert.common.rest.proxy.ProxyManager)16 Test (org.junit.jupiter.api.Test)9 MockAlertProperties (com.synopsys.integration.alert.test.common.MockAlertProperties)7 BlackDuckProperties (com.synopsys.integration.alert.provider.blackduck.BlackDuckProperties)6 Gson (com.google.gson.Gson)4 StatefulProvider (com.synopsys.integration.alert.api.provider.state.StatefulProvider)4 DefaultSystemMessageAccessor (com.synopsys.integration.alert.database.system.DefaultSystemMessageAccessor)4 BlackDuckProvider (com.synopsys.integration.alert.provider.blackduck.BlackDuckProvider)4 BlackDuckSystemValidator (com.synopsys.integration.alert.provider.blackduck.validator.BlackDuckSystemValidator)4 BlackDuckServerConfig (com.synopsys.integration.blackduck.configuration.BlackDuckServerConfig)4 IntLogger (com.synopsys.integration.log.IntLogger)4 ChannelRestConnectionFactory (com.synopsys.integration.alert.api.channel.rest.ChannelRestConnectionFactory)3 ProxyInfo (com.synopsys.integration.rest.proxy.ProxyInfo)3 AlertProperties (com.synopsys.integration.alert.common.AlertProperties)2 SystemMessageSeverity (com.synopsys.integration.alert.common.enumeration.SystemMessageSeverity)2 SystemMessageType (com.synopsys.integration.alert.common.enumeration.SystemMessageType)2 JobAccessor (com.synopsys.integration.alert.common.persistence.accessor.JobAccessor)2 ConfigurationModel (com.synopsys.integration.alert.common.persistence.model.ConfigurationModel)2 Credentials (com.synopsys.integration.rest.credentials.Credentials)2 CredentialsBuilder (com.synopsys.integration.rest.credentials.CredentialsBuilder)2