Search in sources :

Example 11 with ConfigurationValue

use of org.finra.herd.model.dto.ConfigurationValue in project herd by FINRAOS.

the class ConfigurationHelperTest method testGetRequiredPropertyIllegalStateException.

@Test
public void testGetRequiredPropertyIllegalStateException() {
    ConfigurationValue configurationValue = ConfigurationValue.HERD_ENVIRONMENT;
    MockEnvironment environment = new MockEnvironment();
    environment.setProperty(configurationValue.getKey(), BLANK_TEXT);
    try {
        configurationHelper.getRequiredProperty(configurationValue, environment);
        fail();
    } catch (IllegalStateException e) {
        assertEquals(String.format("Configuration \"%s\" must have a value.", ConfigurationValue.HERD_ENVIRONMENT.getKey()), e.getMessage());
    }
}
Also used : ConfigurationValue(org.finra.herd.model.dto.ConfigurationValue) MockEnvironment(org.springframework.mock.env.MockEnvironment) AbstractCoreTest(org.finra.herd.core.AbstractCoreTest) Test(org.junit.Test)

Example 12 with ConfigurationValue

use of org.finra.herd.model.dto.ConfigurationValue in project herd by FINRAOS.

the class ConfigurationHelperTest method testGetPropertyReturnNullWhenPropertyDoesNotExistsAndNoDefaultsConfigured.

@Test
public void testGetPropertyReturnNullWhenPropertyDoesNotExistsAndNoDefaultsConfigured() {
    ConfigurationValue configurationValue = ConfigurationValue.HIBERNATE_DIALECT;
    MockEnvironment environment = new MockEnvironment();
    String value = ConfigurationHelper.getProperty(configurationValue, String.class, environment);
    assertNull("value", value);
}
Also used : ConfigurationValue(org.finra.herd.model.dto.ConfigurationValue) MockEnvironment(org.springframework.mock.env.MockEnvironment) AbstractCoreTest(org.finra.herd.core.AbstractCoreTest) Test(org.junit.Test)

Example 13 with ConfigurationValue

use of org.finra.herd.model.dto.ConfigurationValue in project herd by FINRAOS.

the class ConfigurationHelperTest method testGetProperty.

@Test
public void testGetProperty() {
    ConfigurationValue configurationValue = ConfigurationValue.HERD_ENVIRONMENT;
    String expectedValue = "test";
    MockEnvironment environment = new MockEnvironment();
    environment.setProperty(configurationValue.getKey(), expectedValue);
    String value = ConfigurationHelper.getProperty(configurationValue, String.class, environment);
    assertNotNull("value", value);
    assertEquals("value", expectedValue, value);
}
Also used : ConfigurationValue(org.finra.herd.model.dto.ConfigurationValue) MockEnvironment(org.springframework.mock.env.MockEnvironment) AbstractCoreTest(org.finra.herd.core.AbstractCoreTest) Test(org.junit.Test)

Example 14 with ConfigurationValue

use of org.finra.herd.model.dto.ConfigurationValue in project herd by FINRAOS.

the class ConfigurationHelperTest method testGetPropertyThrowsWhenDefaultTypeDoesNotMatch.

@Test
public void testGetPropertyThrowsWhenDefaultTypeDoesNotMatch() {
    ConfigurationValue configurationValue = ConfigurationValue.HERD_ENVIRONMENT;
    Class<?> expectedDefaultType = configurationValue.getDefaultValue().getClass();
    Class<?> givenType = Integer.class;
    MockEnvironment environment = new MockEnvironment();
    try {
        ConfigurationHelper.getProperty(configurationValue, givenType, environment);
        fail("expected IllegalArgumentException, but no exception was thrown");
    } catch (Exception e) {
        assertEquals("thrown exception type", IllegalStateException.class, e.getClass());
        assertEquals("thrown exception message", "targetType \"" + givenType + "\" is not assignable from the default value of type \"" + expectedDefaultType + "\" for configuration value " + "\"HERD_ENVIRONMENT\".", e.getMessage());
    }
}
Also used : ConfigurationValue(org.finra.herd.model.dto.ConfigurationValue) MockEnvironment(org.springframework.mock.env.MockEnvironment) AbstractCoreTest(org.finra.herd.core.AbstractCoreTest) Test(org.junit.Test)

Example 15 with ConfigurationValue

use of org.finra.herd.model.dto.ConfigurationValue in project herd by FINRAOS.

the class ConfigurationHelperTest method testGetPropertyNoTargetType.

@Test
public void testGetPropertyNoTargetType() {
    ConfigurationValue configurationValue = ConfigurationValue.HERD_ENVIRONMENT;
    MockEnvironment environment = new MockEnvironment();
    String value = ConfigurationHelper.getProperty(configurationValue, environment);
    assertEquals("value", configurationValue.getDefaultValue(), value);
}
Also used : ConfigurationValue(org.finra.herd.model.dto.ConfigurationValue) MockEnvironment(org.springframework.mock.env.MockEnvironment) AbstractCoreTest(org.finra.herd.core.AbstractCoreTest) Test(org.junit.Test)

Aggregations

ConfigurationValue (org.finra.herd.model.dto.ConfigurationValue)21 AbstractCoreTest (org.finra.herd.core.AbstractCoreTest)19 Test (org.junit.Test)19 MockEnvironment (org.springframework.mock.env.MockEnvironment)16 BigDecimal (java.math.BigDecimal)3 S3Actions (com.amazonaws.auth.policy.actions.S3Actions)1 Credentials (com.amazonaws.services.securitytoken.model.Credentials)1 HashMap (java.util.HashMap)1 AwsCredential (org.finra.herd.model.api.xml.AwsCredential)1 S3KeyPrefixInformation (org.finra.herd.model.api.xml.S3KeyPrefixInformation)1 StorageEntity (org.finra.herd.model.jpa.StorageEntity)1 AwsPolicyBuilder (org.finra.herd.service.helper.AwsPolicyBuilder)1 KmsActions (org.finra.herd.service.helper.KmsActions)1 JobDataMap (org.quartz.JobDataMap)1