Search in sources :

Example 1 with SingularityRunnerConfigurationProvider

use of com.hubspot.singularity.runner.base.config.SingularityRunnerConfigurationProvider in project Singularity by HubSpot.

the class SingularityExecutorConfigurationTest method loadConfig.

private SingularityExecutorConfiguration loadConfig(String file) {
    try {
        ObjectMapper mapper = new SingularityRunnerBaseModule(null).providesYamlMapper();
        Validator validator = mock(Validator.class);
        Field mapperField = SingularityRunnerConfigurationProvider.class.getDeclaredField("objectMapper");
        mapperField.setAccessible(true);
        Field validatorField = SingularityRunnerConfigurationProvider.class.getDeclaredField("validator");
        validatorField.setAccessible(true);
        SingularityRunnerConfigurationProvider<SingularityExecutorConfiguration> configProvider = new SingularityRunnerConfigurationProvider<>(SingularityExecutorConfiguration.class, Optional.of(new File(getClass().getClassLoader().getResource(file).toURI()).getAbsolutePath()));
        mapperField.set(configProvider, mapper);
        validatorField.set(configProvider, validator);
        return configProvider.get();
    } catch (Exception e) {
        throw Throwables.propagate(e);
    }
}
Also used : SingularityRunnerConfigurationProvider(com.hubspot.singularity.runner.base.config.SingularityRunnerConfigurationProvider) Field(java.lang.reflect.Field) SingularityRunnerBaseModule(com.hubspot.singularity.runner.base.config.SingularityRunnerBaseModule) File(java.io.File) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Validator(javax.validation.Validator)

Aggregations

ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 SingularityRunnerBaseModule (com.hubspot.singularity.runner.base.config.SingularityRunnerBaseModule)1 SingularityRunnerConfigurationProvider (com.hubspot.singularity.runner.base.config.SingularityRunnerConfigurationProvider)1 File (java.io.File)1 Field (java.lang.reflect.Field)1 Validator (javax.validation.Validator)1