Search in sources :

Example 6 with ConfigurationValue

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

the class ConfigurationHelperTest method testGetNonNegativeBigDecimalRequiredPropertyValueBlankStringValue.

@Test
public void testGetNonNegativeBigDecimalRequiredPropertyValueBlankStringValue() {
    ConfigurationValue configurationValue = ConfigurationValue.EMR_CLUSTER_LOWEST_CORE_INSTANCE_PRICE_PERCENTAGE;
    MockEnvironment environment = new MockEnvironment();
    environment.setProperty(configurationValue.getKey(), " ");
    try {
        configurationHelper.getNonNegativeBigDecimalRequiredProperty(configurationValue, environment);
        fail("Should throw an IllegalStatueException when property value is not BigDecimal.");
    } catch (IllegalStateException e) {
        assertEquals(String.format("Configuration \"%s\" must have a value.", 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 7 with ConfigurationValue

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

the class ConfigurationHelperTest method testGetBooleanPropertyValue.

@Test
public void testGetBooleanPropertyValue() {
    ConfigurationValue configurationValue = ConfigurationValue.USER_NAMESPACE_AUTHORIZATION_ENABLED;
    MockEnvironment environment = new MockEnvironment();
    environment.setProperty(configurationValue.getKey(), "true");
    assertEquals(Boolean.TRUE, configurationHelper.getBooleanProperty(configurationValue, environment));
}
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 8 with ConfigurationValue

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

the class ConfigurationHelperTest method testGetPropertyInstanceNoTargetType.

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

Example 9 with ConfigurationValue

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

the class ConfigurationHelperTest method testGetPropertyReturnDefaultWhenValueConversionFails.

@Test
public void testGetPropertyReturnDefaultWhenValueConversionFails() throws Exception {
    ConfigurationValue configurationValue = ConfigurationValue.BUSINESS_OBJECT_DATA_SEARCH_MAX_RESULTS;
    Integer expectedValue = (Integer) configurationValue.getDefaultValue();
    MockEnvironment environment = new MockEnvironment();
    environment.setProperty(configurationValue.getKey(), "NOT_AN_INTEGER");
    executeWithoutLogging(ConfigurationHelper.class, () -> {
        Integer value = ConfigurationHelper.getProperty(configurationValue, Integer.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 10 with ConfigurationValue

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

the class ConfigurationHelperTest method testGetBigDecimalRequiredPropertyValueBlankStringValue.

@Test
public void testGetBigDecimalRequiredPropertyValueBlankStringValue() {
    ConfigurationValue configurationValue = ConfigurationValue.EMR_CLUSTER_LOWEST_CORE_INSTANCE_PRICE_PERCENTAGE;
    MockEnvironment environment = new MockEnvironment();
    environment.setProperty(configurationValue.getKey(), " ");
    try {
        configurationHelper.getBigDecimalRequiredProperty(configurationValue, environment);
        fail("Should throw an IllegalStatueException when property value is not BigDecimal.");
    } catch (IllegalStateException e) {
        assertEquals(String.format("Configuration \"%s\" must have a value.", 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)

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