Search in sources :

Example 1 with ConfigurationValue

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

the class ConfigurationHelperTest method testGetBigDecimalRequiredPropertyValue.

@Test
public void testGetBigDecimalRequiredPropertyValue() {
    ConfigurationValue configurationValue = ConfigurationValue.EMR_CLUSTER_LOWEST_CORE_INSTANCE_PRICE_PERCENTAGE;
    MockEnvironment environment = new MockEnvironment();
    environment.setProperty(configurationValue.getKey(), "0.05");
    assertEquals(new BigDecimal("0.05"), configurationHelper.getBigDecimalRequiredProperty(configurationValue, environment));
}
Also used : ConfigurationValue(org.finra.herd.model.dto.ConfigurationValue) MockEnvironment(org.springframework.mock.env.MockEnvironment) BigDecimal(java.math.BigDecimal) AbstractCoreTest(org.finra.herd.core.AbstractCoreTest) Test(org.junit.Test)

Example 2 with ConfigurationValue

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

the class ConfigurationHelperTest method testGetBooleanPropertyValueConversionFails.

@Test
public void testGetBooleanPropertyValueConversionFails() {
    ConfigurationValue configurationValue = ConfigurationValue.USER_NAMESPACE_AUTHORIZATION_ENABLED;
    MockEnvironment environment = new MockEnvironment();
    environment.setProperty(configurationValue.getKey(), "NOT_A_BOOLEAN");
    try {
        configurationHelper.getBooleanProperty(configurationValue, environment);
        fail("Should throw an IllegalStatueException when property value is not boolean.");
    } catch (IllegalStateException e) {
        assertEquals(String.format("Configuration \"%s\" has an invalid boolean value: \"NOT_A_BOOLEAN\".", configurationValue.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 3 with ConfigurationValue

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

the class ConfigurationHelperTest method testGetRequiredProperty.

@Test
public void testGetRequiredProperty() {
    ConfigurationValue configurationValue = ConfigurationValue.HERD_ENVIRONMENT;
    String value = configurationHelper.getRequiredProperty(configurationValue);
    assertEquals(configurationValue.getDefaultValue(), value);
}
Also used : ConfigurationValue(org.finra.herd.model.dto.ConfigurationValue) AbstractCoreTest(org.finra.herd.core.AbstractCoreTest) Test(org.junit.Test)

Example 4 with ConfigurationValue

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

the class ConfigurationHelperTest method testGetPropertyReturnDefaultWhenPropertyDoesNotExists.

@Test
public void testGetPropertyReturnDefaultWhenPropertyDoesNotExists() {
    ConfigurationValue configurationValue = ConfigurationValue.HERD_ENVIRONMENT;
    String expectedValue = (String) configurationValue.getDefaultValue();
    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 5 with ConfigurationValue

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

the class ConfigurationHelperTest method testGetPropertyInstance.

@Test
public void testGetPropertyInstance() {
    ConfigurationValue configurationValue = ConfigurationValue.HERD_ENVIRONMENT;
    String value = configurationHelper.getProperty(configurationValue, String.class);
    assertEquals("value", configurationValue.getDefaultValue(), value);
}
Also used : ConfigurationValue(org.finra.herd.model.dto.ConfigurationValue) 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