Search in sources :

Example 16 with EnvironmentVariableHandlerFactory

use of com.synopsys.integration.alert.environment.EnvironmentVariableHandlerFactory in project hub-alert by blackducksoftware.

the class JiraServerEnvironmentHandlerFactoryTestIT method testExistingConfig.

@Test
void testExistingConfig() throws AlertConfigurationException {
    String createdAt = DateUtils.formatDate(DateUtils.createCurrentDateTimestamp(), DateUtils.UTC_DATE_FORMAT_TO_MINUTE);
    JiraServerGlobalConfigModel emailGlobalConfigModel = new JiraServerGlobalConfigModel(null, AlertRestConstants.DEFAULT_CONFIGURATION_NAME, createdAt, createdAt, TEST_URL, TEST_USER, TEST_PASSWORD, false, true);
    jiraGlobalConfigAccessor.createConfiguration(emailGlobalConfigModel);
    Environment environment = setupMockedEnvironment();
    EnvironmentVariableUtility environmentVariableUtility = new EnvironmentVariableUtility(environment);
    EnvironmentVariableHandlerFactory factory = new JiraServerEnvironmentVariableHandlerFactory(jiraGlobalConfigAccessor, environmentVariableUtility);
    EnvironmentVariableHandler handler = factory.build();
    EnvironmentProcessingResult result = handler.updateFromEnvironment();
    assertEquals(ChannelKeys.JIRA_SERVER.getDisplayName(), handler.getName());
    assertFalse(result.hasValues());
}
Also used : JiraServerEnvironmentVariableHandlerFactory(com.synopsys.integration.alert.channel.jira.server.environment.JiraServerEnvironmentVariableHandlerFactory) EnvironmentVariableHandlerFactory(com.synopsys.integration.alert.environment.EnvironmentVariableHandlerFactory) EnvironmentVariableUtility(com.synopsys.integration.alert.environment.EnvironmentVariableUtility) JiraServerGlobalConfigModel(com.synopsys.integration.alert.channel.jira.server.model.JiraServerGlobalConfigModel) Environment(org.springframework.core.env.Environment) EnvironmentVariableHandler(com.synopsys.integration.alert.environment.EnvironmentVariableHandler) JiraServerEnvironmentVariableHandlerFactory(com.synopsys.integration.alert.channel.jira.server.environment.JiraServerEnvironmentVariableHandlerFactory) EnvironmentProcessingResult(com.synopsys.integration.alert.environment.EnvironmentProcessingResult) AlertIntegrationTest(com.synopsys.integration.alert.util.AlertIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 17 with EnvironmentVariableHandlerFactory

use of com.synopsys.integration.alert.environment.EnvironmentVariableHandlerFactory in project hub-alert by blackducksoftware.

the class ProxySettingsEnvironmentHandlerFactoryTest method testProxyMissingFromEnvironment.

@Test
void testProxyMissingFromEnvironment() {
    Environment environment = Mockito.mock(Environment.class);
    SettingsProxyConfigAccessor configAccessor = Mockito.mock(SettingsProxyConfigAccessor.class);
    Mockito.when(configAccessor.getConfiguration()).thenReturn(Optional.empty());
    EnvironmentVariableUtility environmentVariableUtility = new EnvironmentVariableUtility(environment);
    EnvironmentVariableHandlerFactory factory = new ProxySettingsEnvironmentHandlerFactory(configAccessor, environmentVariableUtility, validator);
    EnvironmentVariableHandler handler = factory.build();
    EnvironmentProcessingResult result = handler.updateFromEnvironment();
    assertEquals(ProxySettingsEnvironmentHandlerFactory.HANDLER_NAME, handler.getName());
    assertFalse(result.hasValues());
}
Also used : EnvironmentVariableHandlerFactory(com.synopsys.integration.alert.environment.EnvironmentVariableHandlerFactory) EnvironmentVariableUtility(com.synopsys.integration.alert.environment.EnvironmentVariableUtility) Environment(org.springframework.core.env.Environment) SettingsProxyConfigAccessor(com.synopsys.integration.alert.component.settings.proxy.database.accessor.SettingsProxyConfigAccessor) EnvironmentVariableHandler(com.synopsys.integration.alert.environment.EnvironmentVariableHandler) EnvironmentProcessingResult(com.synopsys.integration.alert.environment.EnvironmentProcessingResult) Test(org.junit.jupiter.api.Test)

Aggregations

EnvironmentProcessingResult (com.synopsys.integration.alert.environment.EnvironmentProcessingResult)17 EnvironmentVariableHandler (com.synopsys.integration.alert.environment.EnvironmentVariableHandler)17 EnvironmentVariableHandlerFactory (com.synopsys.integration.alert.environment.EnvironmentVariableHandlerFactory)17 EnvironmentVariableUtility (com.synopsys.integration.alert.environment.EnvironmentVariableUtility)17 Test (org.junit.jupiter.api.Test)17 Environment (org.springframework.core.env.Environment)17 AlertConstants (com.synopsys.integration.alert.api.common.model.AlertConstants)5 JiraServerGlobalConfigAccessor (com.synopsys.integration.alert.channel.jira.server.database.accessor.JiraServerGlobalConfigAccessor)5 ChannelKeys (com.synopsys.integration.alert.descriptor.api.model.ChannelKeys)5 EnvironmentVariableMockingUtil (com.synopsys.integration.alert.test.common.EnvironmentVariableMockingUtil)5 Set (java.util.Set)5 Predicate (java.util.function.Predicate)5 Assertions.assertEquals (org.junit.jupiter.api.Assertions.assertEquals)5 Assertions.assertFalse (org.junit.jupiter.api.Assertions.assertFalse)5 Assertions.assertTrue (org.junit.jupiter.api.Assertions.assertTrue)5 Mockito (org.mockito.Mockito)5 EmailGlobalConfigAccessor (com.synopsys.integration.alert.channel.email.database.accessor.EmailGlobalConfigAccessor)4 AlertIntegrationTest (com.synopsys.integration.alert.util.AlertIntegrationTest)4 EmailGlobalConfigurationValidator (com.synopsys.integration.alert.channel.email.validator.EmailGlobalConfigurationValidator)2 JiraServerEnvironmentVariableHandlerFactory (com.synopsys.integration.alert.channel.jira.server.environment.JiraServerEnvironmentVariableHandlerFactory)2