Search in sources :

Example 16 with JiraServerGlobalConfigAccessor

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());
}
Also used : EnvironmentVariableHandlerFactory(com.synopsys.integration.alert.environment.EnvironmentVariableHandlerFactory) EnvironmentVariableUtility(com.synopsys.integration.alert.environment.EnvironmentVariableUtility) Environment(org.springframework.core.env.Environment) EnvironmentVariableHandler(com.synopsys.integration.alert.environment.EnvironmentVariableHandler) JiraServerGlobalConfigAccessor(com.synopsys.integration.alert.channel.jira.server.database.accessor.JiraServerGlobalConfigAccessor) EnvironmentProcessingResult(com.synopsys.integration.alert.environment.EnvironmentProcessingResult) Test(org.junit.jupiter.api.Test)

Example 17 with JiraServerGlobalConfigAccessor

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());
}
Also used : EnvironmentVariableHandlerFactory(com.synopsys.integration.alert.environment.EnvironmentVariableHandlerFactory) EnvironmentVariableUtility(com.synopsys.integration.alert.environment.EnvironmentVariableUtility) Environment(org.springframework.core.env.Environment) EnvironmentVariableHandler(com.synopsys.integration.alert.environment.EnvironmentVariableHandler) JiraServerGlobalConfigAccessor(com.synopsys.integration.alert.channel.jira.server.database.accessor.JiraServerGlobalConfigAccessor) EnvironmentProcessingResult(com.synopsys.integration.alert.environment.EnvironmentProcessingResult) Test(org.junit.jupiter.api.Test)

Example 18 with JiraServerGlobalConfigAccessor

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());
}
Also used : EnvironmentVariableUtility(com.synopsys.integration.alert.environment.EnvironmentVariableUtility) Predicate(java.util.function.Predicate) Set(java.util.Set) EnvironmentVariableMockingUtil(com.synopsys.integration.alert.test.common.EnvironmentVariableMockingUtil) JiraServerGlobalConfigAccessor(com.synopsys.integration.alert.channel.jira.server.database.accessor.JiraServerGlobalConfigAccessor) Test(org.junit.jupiter.api.Test) Mockito(org.mockito.Mockito) EnvironmentProcessingResult(com.synopsys.integration.alert.environment.EnvironmentProcessingResult) EnvironmentVariableHandlerFactory(com.synopsys.integration.alert.environment.EnvironmentVariableHandlerFactory) Assertions.assertFalse(org.junit.jupiter.api.Assertions.assertFalse) Environment(org.springframework.core.env.Environment) EnvironmentVariableHandler(com.synopsys.integration.alert.environment.EnvironmentVariableHandler) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) ChannelKeys(com.synopsys.integration.alert.descriptor.api.model.ChannelKeys) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) AlertConstants(com.synopsys.integration.alert.api.common.model.AlertConstants) EnvironmentVariableHandlerFactory(com.synopsys.integration.alert.environment.EnvironmentVariableHandlerFactory) EnvironmentVariableUtility(com.synopsys.integration.alert.environment.EnvironmentVariableUtility) Environment(org.springframework.core.env.Environment) EnvironmentVariableHandler(com.synopsys.integration.alert.environment.EnvironmentVariableHandler) JiraServerGlobalConfigAccessor(com.synopsys.integration.alert.channel.jira.server.database.accessor.JiraServerGlobalConfigAccessor) EnvironmentProcessingResult(com.synopsys.integration.alert.environment.EnvironmentProcessingResult) Test(org.junit.jupiter.api.Test)

Aggregations

JiraServerGlobalConfigAccessor (com.synopsys.integration.alert.channel.jira.server.database.accessor.JiraServerGlobalConfigAccessor)18 Test (org.junit.jupiter.api.Test)18 JiraServerGlobalCrudActions (com.synopsys.integration.alert.channel.jira.server.action.JiraServerGlobalCrudActions)6 JiraServerConfigurationEntity (com.synopsys.integration.alert.channel.jira.server.database.configuration.JiraServerConfigurationEntity)6 JiraServerConfigurationRepository (com.synopsys.integration.alert.channel.jira.server.database.configuration.JiraServerConfigurationRepository)6 JiraServerGlobalConfigModel (com.synopsys.integration.alert.channel.jira.server.model.JiraServerGlobalConfigModel)6 AtomicReference (java.util.concurrent.atomic.AtomicReference)6 ConfigurationModel (com.synopsys.integration.alert.common.persistence.model.ConfigurationModel)5 EnvironmentProcessingResult (com.synopsys.integration.alert.environment.EnvironmentProcessingResult)5 EnvironmentVariableHandler (com.synopsys.integration.alert.environment.EnvironmentVariableHandler)5 EnvironmentVariableHandlerFactory (com.synopsys.integration.alert.environment.EnvironmentVariableHandlerFactory)5 EnvironmentVariableUtility (com.synopsys.integration.alert.environment.EnvironmentVariableUtility)5 Environment (org.springframework.core.env.Environment)5 UUID (java.util.UUID)4 AlertConstants (com.synopsys.integration.alert.api.common.model.AlertConstants)3 ChannelKeys (com.synopsys.integration.alert.descriptor.api.model.ChannelKeys)3 EnvironmentVariableMockingUtil (com.synopsys.integration.alert.test.common.EnvironmentVariableMockingUtil)3 Set (java.util.Set)3 Predicate (java.util.function.Predicate)3 Assertions.assertEquals (org.junit.jupiter.api.Assertions.assertEquals)3