@Test public void resolvesPropertyFromExternalProperties() throws IOException { Map<String, String> externalProperties = singletonMap("CONFIG_LOCATION", "foo"); JsonNode root = parseYaml("{ \"include\" : \"${CONFIG_LOCATION:classpath:}/conf/environment/default.yaml\" }"); PlaceholderResolver.resolvePlaceholders(root, externalProperties); assertThat(root.get("include").textValue(), is("foo/conf/environment/default.yaml")); }
public static Collection<UnresolvedPlaceholder> resolvePlaceholders(JsonNode rootNode, Map<String, String> externalProperties) { if (rootNode.isObject()) { return new PlaceholderResolver((ObjectNode) rootNode, externalProperties).resolve(); } return Collections.emptyList(); }
PlaceholderResolver { public static Collection<UnresolvedPlaceholder> resolvePlaceholders(JsonNode rootNode, Map<String, String> externalProperties) { if (rootNode.isObject()) { return new PlaceholderResolver((ObjectNode) rootNode, externalProperties).resolve(); } return Collections.emptyList(); } }
PlaceholderResolver { public static Collection<UnresolvedPlaceholder> resolvePlaceholders(JsonNode rootNode, Map<String, String> externalProperties) { if (rootNode.isObject()) { return new PlaceholderResolver((ObjectNode) rootNode, externalProperties).resolve(); } return Collections.emptyList(); } PlaceholderResolver(ObjectNode rootNode, Map<String, String> externalProperties); }
PlaceholderResolver { public static Collection<UnresolvedPlaceholder> resolvePlaceholders(JsonNode rootNode, Map<String, String> externalProperties) { if (rootNode.isObject()) { return new PlaceholderResolver((ObjectNode) rootNode, externalProperties).resolve(); } return Collections.emptyList(); } PlaceholderResolver(ObjectNode rootNode, Map<String, String> externalProperties); static Collection<UnresolvedPlaceholder> resolvePlaceholders(JsonNode rootNode, Map<String, String> externalProperties); static Collection<UnresolvedPlaceholder> resolvePlaceholders(JsonNode rootNode, Properties properties); Collection<UnresolvedPlaceholder> resolve(); @VisibleForTesting static String replacePlaceholder(String originalString, String placeholderName, String placeholderValue); @VisibleForTesting static List<Placeholder> extractPlaceholders(String value); }
PlaceholderResolver { public static Collection<UnresolvedPlaceholder> resolvePlaceholders(JsonNode rootNode, Map<String, String> externalProperties) { if (rootNode.isObject()) { return new PlaceholderResolver((ObjectNode) rootNode, externalProperties).resolve(); } return Collections.emptyList(); } PlaceholderResolver(ObjectNode rootNode, Map<String, String> externalProperties); static Collection<UnresolvedPlaceholder> resolvePlaceholders(JsonNode rootNode, Map<String, String> externalProperties); static Collection<UnresolvedPlaceholder> resolvePlaceholders(JsonNode rootNode, Properties properties); Collection<UnresolvedPlaceholder> resolve(); @VisibleForTesting static String replacePlaceholder(String originalString, String placeholderName, String placeholderValue); @VisibleForTesting static List<Placeholder> extractPlaceholders(String value);  }