@Test public void givenAValidYAMLConfigFileContainingEnvVarThatCannotBeFound_whenGetConfigInvoked_thenValidPOJOReturnedWithDefault() { ConfigLoader<DummyConfiguration> dummyConfigurationConfigLoader = new ConfigLoader<>( DummyConfiguration.class, CONFIG_FILE, varNotFound ); assertThat(dummyConfigurationConfigLoader.getTestConfig().getSomeDummyEnvAttribute(), CoreMatchers.is("defaultValue")); }
public T getTestConfig() { try { LOGGER.info(String.format("Loading config from: %s", configFileName)); final String substitutedString = substitutor.replace(new String( ByteStreams.toByteArray(this.getClass().getClassLoader().getResourceAsStream(configFileName)), StandardCharsets.UTF_8) ); return reader.readValue(substitutedString); } catch(Exception e) { throw new RuntimeException(e); } }
ConfigLoader { public T getTestConfig() { try { LOGGER.info(String.format("Loading config from: %s", configFileName)); final String substitutedString = substitutor.replace(new String( ByteStreams.toByteArray(this.getClass().getClassLoader().getResourceAsStream(configFileName)), StandardCharsets.UTF_8) ); return reader.readValue(substitutedString); } catch(Exception e) { throw new RuntimeException(e); } } }
ConfigLoader { public T getTestConfig() { try { LOGGER.info(String.format("Loading config from: %s", configFileName)); final String substitutedString = substitutor.replace(new String( ByteStreams.toByteArray(this.getClass().getClassLoader().getResourceAsStream(configFileName)), StandardCharsets.UTF_8) ); return reader.readValue(substitutedString); } catch(Exception e) { throw new RuntimeException(e); } } ConfigLoader(Class<T> configClass, String configFileName);  ConfigLoader(Class<T> configClass, String configFileName, StrLookup<Object> stringLookup); }
ConfigLoader { public T getTestConfig() { try { LOGGER.info(String.format("Loading config from: %s", configFileName)); final String substitutedString = substitutor.replace(new String( ByteStreams.toByteArray(this.getClass().getClassLoader().getResourceAsStream(configFileName)), StandardCharsets.UTF_8) ); return reader.readValue(substitutedString); } catch(Exception e) { throw new RuntimeException(e); } } ConfigLoader(Class<T> configClass, String configFileName);  ConfigLoader(Class<T> configClass, String configFileName, StrLookup<Object> stringLookup); T getTestConfig(); String getConfigFileName(); Class<T> getConfigClass(); }
ConfigLoader { public T getTestConfig() { try { LOGGER.info(String.format("Loading config from: %s", configFileName)); final String substitutedString = substitutor.replace(new String( ByteStreams.toByteArray(this.getClass().getClassLoader().getResourceAsStream(configFileName)), StandardCharsets.UTF_8) ); return reader.readValue(substitutedString); } catch(Exception e) { throw new RuntimeException(e); } } ConfigLoader(Class<T> configClass, String configFileName);  ConfigLoader(Class<T> configClass, String configFileName, StrLookup<Object> stringLookup); T getTestConfig(); String getConfigFileName(); Class<T> getConfigClass();  }