@Test( expected = SingularityConfigurationMergeException.class ) public void testNonObjectFails() throws Exception { buildConfigurationSourceProvider(DEFAULT_PATH).open(JUST_A_STRING_PATH); }
@Override public InputStream open(String path) throws IOException { final JsonNode originalNode = objectMapper.readTree(yamlFactory.createParser(delegate.open(defaultConfigurationPath))); final JsonNode overrideNode = objectMapper.readTree(yamlFactory.createParser(delegate.open(path))); if (!(originalNode instanceof ObjectNode && overrideNode instanceof ObjectNode)) { throw new SingularityConfigurationMergeException(String.format("Both %s and %s need to be YAML objects", defaultConfigurationPath, path)); } merge((ObjectNode)originalNode, (ObjectNode)overrideNode); final ByteArrayOutputStream baos = new ByteArrayOutputStream(); objectMapper.writeTree(yamlFactory.createGenerator(baos), originalNode); return new ByteArrayInputStream(baos.toByteArray()); }
MergingSourceProvider implements ConfigurationSourceProvider { @Override public InputStream open(String path) throws IOException { final JsonNode originalNode = objectMapper.readTree(yamlFactory.createParser(delegate.open(defaultConfigurationPath))); final JsonNode overrideNode = objectMapper.readTree(yamlFactory.createParser(delegate.open(path))); if (!(originalNode instanceof ObjectNode && overrideNode instanceof ObjectNode)) { throw new SingularityConfigurationMergeException(String.format("Both %s and %s need to be YAML objects", defaultConfigurationPath, path)); } merge((ObjectNode)originalNode, (ObjectNode)overrideNode); final ByteArrayOutputStream baos = new ByteArrayOutputStream(); objectMapper.writeTree(yamlFactory.createGenerator(baos), originalNode); return new ByteArrayInputStream(baos.toByteArray()); } }
MergingSourceProvider implements ConfigurationSourceProvider { @Override public InputStream open(String path) throws IOException { final JsonNode originalNode = objectMapper.readTree(yamlFactory.createParser(delegate.open(defaultConfigurationPath))); final JsonNode overrideNode = objectMapper.readTree(yamlFactory.createParser(delegate.open(path))); if (!(originalNode instanceof ObjectNode && overrideNode instanceof ObjectNode)) { throw new SingularityConfigurationMergeException(String.format("Both %s and %s need to be YAML objects", defaultConfigurationPath, path)); } merge((ObjectNode)originalNode, (ObjectNode)overrideNode); final ByteArrayOutputStream baos = new ByteArrayOutputStream(); objectMapper.writeTree(yamlFactory.createGenerator(baos), originalNode); return new ByteArrayInputStream(baos.toByteArray()); } MergingSourceProvider(ConfigurationSourceProvider delegate, String defaultConfigurationPath, ObjectMapper objectMapper, YAMLFactory yamlFactory); }
MergingSourceProvider implements ConfigurationSourceProvider { @Override public InputStream open(String path) throws IOException { final JsonNode originalNode = objectMapper.readTree(yamlFactory.createParser(delegate.open(defaultConfigurationPath))); final JsonNode overrideNode = objectMapper.readTree(yamlFactory.createParser(delegate.open(path))); if (!(originalNode instanceof ObjectNode && overrideNode instanceof ObjectNode)) { throw new SingularityConfigurationMergeException(String.format("Both %s and %s need to be YAML objects", defaultConfigurationPath, path)); } merge((ObjectNode)originalNode, (ObjectNode)overrideNode); final ByteArrayOutputStream baos = new ByteArrayOutputStream(); objectMapper.writeTree(yamlFactory.createGenerator(baos), originalNode); return new ByteArrayInputStream(baos.toByteArray()); } MergingSourceProvider(ConfigurationSourceProvider delegate, String defaultConfigurationPath, ObjectMapper objectMapper, YAMLFactory yamlFactory); @Override InputStream open(String path); }
MergingSourceProvider implements ConfigurationSourceProvider { @Override public InputStream open(String path) throws IOException { final JsonNode originalNode = objectMapper.readTree(yamlFactory.createParser(delegate.open(defaultConfigurationPath))); final JsonNode overrideNode = objectMapper.readTree(yamlFactory.createParser(delegate.open(path))); if (!(originalNode instanceof ObjectNode && overrideNode instanceof ObjectNode)) { throw new SingularityConfigurationMergeException(String.format("Both %s and %s need to be YAML objects", defaultConfigurationPath, path)); } merge((ObjectNode)originalNode, (ObjectNode)overrideNode); final ByteArrayOutputStream baos = new ByteArrayOutputStream(); objectMapper.writeTree(yamlFactory.createGenerator(baos), originalNode); return new ByteArrayInputStream(baos.toByteArray()); } MergingSourceProvider(ConfigurationSourceProvider delegate, String defaultConfigurationPath, ObjectMapper objectMapper, YAMLFactory yamlFactory); @Override InputStream open(String path);  }