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());
}
}
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);
}
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);
}
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());
}
}
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);
}
Aggregations