use of com.synopsys.integration.alert.channel.jira.server.database.accessor.JiraServerGlobalConfigAccessor in project hub-alert by blackducksoftware.
the class JiraServerEnvironmentVariableHandlerFactoryTest method testConfigPresent.
@Test
void testConfigPresent() {
Environment environment = Mockito.mock(Environment.class);
JiraServerGlobalConfigAccessor configAccessor = Mockito.mock(JiraServerGlobalConfigAccessor.class);
Mockito.when(configAccessor.getConfigurationCount()).thenReturn(1L);
EnvironmentVariableUtility environmentVariableUtility = new EnvironmentVariableUtility(environment);
EnvironmentVariableHandlerFactory factory = new JiraServerEnvironmentVariableHandlerFactory(configAccessor, environmentVariableUtility);
EnvironmentVariableHandler handler = factory.build();
EnvironmentProcessingResult result = handler.updateFromEnvironment();
assertEquals(ChannelKeys.JIRA_SERVER.getDisplayName(), handler.getName());
assertFalse(result.hasValues());
}
use of com.synopsys.integration.alert.channel.jira.server.database.accessor.JiraServerGlobalConfigAccessor in project hub-alert by blackducksoftware.
the class JiraServerEnvironmentVariableHandlerFactoryTest method testMissingFromEnvironment.
@Test
void testMissingFromEnvironment() {
Environment environment = Mockito.mock(Environment.class);
JiraServerGlobalConfigAccessor configAccessor = Mockito.mock(JiraServerGlobalConfigAccessor.class);
Mockito.when(configAccessor.getConfigurationCount()).thenReturn(0L);
EnvironmentVariableUtility environmentVariableUtility = new EnvironmentVariableUtility(environment);
EnvironmentVariableHandlerFactory factory = new JiraServerEnvironmentVariableHandlerFactory(configAccessor, environmentVariableUtility);
EnvironmentVariableHandler handler = factory.build();
EnvironmentProcessingResult result = handler.updateFromEnvironment();
assertEquals(ChannelKeys.JIRA_SERVER.getDisplayName(), handler.getName());
assertFalse(result.hasValues());
}
use of com.synopsys.integration.alert.channel.jira.server.database.accessor.JiraServerGlobalConfigAccessor in project hub-alert by blackducksoftware.
the class JiraServerEnvironmentVariableHandlerFactoryTest method testSetInEnvironmentURLMissing.
@Test
void testSetInEnvironmentURLMissing() {
Environment environment = Mockito.mock(Environment.class);
JiraServerGlobalConfigAccessor configAccessor = Mockito.mock(JiraServerGlobalConfigAccessor.class);
Mockito.when(configAccessor.getConfigurationCount()).thenReturn(0L);
Set<String> expectedVariableNames = JiraServerEnvironmentVariableHandlerFactory.VARIABLE_NAMES;
String disablePluginCheck = "true";
String passwordValue = "a test value";
String username = "testuser";
Predicate<String> hasEnvVarCheck = (variableName) -> !JiraServerEnvironmentVariableHandlerFactory.VARIABLE_NAMES.contains(variableName);
Mockito.when(environment.containsProperty(Mockito.anyString())).thenReturn(Boolean.TRUE);
EnvironmentVariableMockingUtil.addEnvironmentVariableValueToMock(environment, hasEnvVarCheck, JiraServerEnvironmentVariableHandlerFactory.DISABLE_PLUGIN_KEY, disablePluginCheck);
EnvironmentVariableMockingUtil.addEnvironmentVariableValueToMock(environment, hasEnvVarCheck, JiraServerEnvironmentVariableHandlerFactory.PASSWORD_KEY, passwordValue);
EnvironmentVariableMockingUtil.addEnvironmentVariableValueToMock(environment, hasEnvVarCheck, JiraServerEnvironmentVariableHandlerFactory.USERNAME_KEY, username);
EnvironmentVariableUtility environmentVariableUtility = new EnvironmentVariableUtility(environment);
EnvironmentVariableHandlerFactory factory = new JiraServerEnvironmentVariableHandlerFactory(configAccessor, environmentVariableUtility);
EnvironmentVariableHandler handler = factory.build();
EnvironmentProcessingResult result = handler.updateFromEnvironment();
assertEquals(ChannelKeys.JIRA_SERVER.getDisplayName(), handler.getName());
assertEquals(expectedVariableNames, handler.getVariableNames());
assertFalse(result.hasValues());
}
Aggregations