@SuppressWarnings({ "rawtypes", "unchecked" }) @Test public void loadsValidConfigFiles() throws Exception { final Pair<ExampleConfig, Map> result = factory.build(validFile); ExampleConfig example = result.getKey(); assertThat(example.getName()).isEqualTo("GJEX"); assertThat(example.getAge()).isEqualTo(12); assertThat(example.getProperties()) .contains(MapEntry.entry("k1", "v1"), MapEntry.entry("settings.enabled", "true")); Map<String, Object> configMap = (Map<String, Object>) result.getValue(); assertThat(configMap.size()).isEqualTo(7); }
@Override public Pair<T, U> build(ConfigurationSourceProvider provider, String path) throws IOException, ConfigurationException { try (InputStream input = provider.open(requireNonNull(path))) { final JsonNode node = objectMapper.readTree(createParser(input)); if (node == null) { throw ConfigurationParsingException .builder("GJEXConfiguration at " + path + " must not be empty") .build(path); } return build(node, path); } catch (JsonParseException e) { throw ConfigurationParsingException .builder("Malformed " + formatName) .setCause(e) .setLocation(e.getLocation()) .setDetail(e.getMessage()) .build(path); } }
BaseConfigurationFactory implements ConfigurationFactory<T, U> { @Override public Pair<T, U> build(ConfigurationSourceProvider provider, String path) throws IOException, ConfigurationException { try (InputStream input = provider.open(requireNonNull(path))) { final JsonNode node = objectMapper.readTree(createParser(input)); if (node == null) { throw ConfigurationParsingException .builder("GJEXConfiguration at " + path + " must not be empty") .build(path); } return build(node, path); } catch (JsonParseException e) { throw ConfigurationParsingException .builder("Malformed " + formatName) .setCause(e) .setLocation(e.getLocation()) .setDetail(e.getMessage()) .build(path); } } }
BaseConfigurationFactory implements ConfigurationFactory<T, U> { @Override public Pair<T, U> build(ConfigurationSourceProvider provider, String path) throws IOException, ConfigurationException { try (InputStream input = provider.open(requireNonNull(path))) { final JsonNode node = objectMapper.readTree(createParser(input)); if (node == null) { throw ConfigurationParsingException .builder("GJEXConfiguration at " + path + " must not be empty") .build(path); } return build(node, path); } catch (JsonParseException e) { throw ConfigurationParsingException .builder("Malformed " + formatName) .setCause(e) .setLocation(e.getLocation()) .setDetail(e.getMessage()) .build(path); } } BaseConfigurationFactory(JsonFactory parserFactory,
                                    String formatName,
                                    Class<T> klass,
                                    Validator validator,
                                    ObjectMapper objectMapper); }
BaseConfigurationFactory implements ConfigurationFactory<T, U> { @Override public Pair<T, U> build(ConfigurationSourceProvider provider, String path) throws IOException, ConfigurationException { try (InputStream input = provider.open(requireNonNull(path))) { final JsonNode node = objectMapper.readTree(createParser(input)); if (node == null) { throw ConfigurationParsingException .builder("GJEXConfiguration at " + path + " must not be empty") .build(path); } return build(node, path); } catch (JsonParseException e) { throw ConfigurationParsingException .builder("Malformed " + formatName) .setCause(e) .setLocation(e.getLocation()) .setDetail(e.getMessage()) .build(path); } } BaseConfigurationFactory(JsonFactory parserFactory,
                                    String formatName,
                                    Class<T> klass,
                                    Validator validator,
                                    ObjectMapper objectMapper); @Override Pair<T, U> build(ConfigurationSourceProvider provider, String path); @Override Pair<T, U> build(); }
BaseConfigurationFactory implements ConfigurationFactory<T, U> { @Override public Pair<T, U> build(ConfigurationSourceProvider provider, String path) throws IOException, ConfigurationException { try (InputStream input = provider.open(requireNonNull(path))) { final JsonNode node = objectMapper.readTree(createParser(input)); if (node == null) { throw ConfigurationParsingException .builder("GJEXConfiguration at " + path + " must not be empty") .build(path); } return build(node, path); } catch (JsonParseException e) { throw ConfigurationParsingException .builder("Malformed " + formatName) .setCause(e) .setLocation(e.getLocation()) .setDetail(e.getMessage()) .build(path); } } BaseConfigurationFactory(JsonFactory parserFactory,
                                    String formatName,
                                    Class<T> klass,
                                    Validator validator,
                                    ObjectMapper objectMapper); @Override Pair<T, U> build(ConfigurationSourceProvider provider, String path); @Override Pair<T, U> build();  }