@Test public void testParseWithUnknown_strict() throws IOException { copyResourceTo("/net/morimekta/providence/config/files/unknown.cfg", temp.getRoot()); File file = copyResourceTo("/net/morimekta/providence/config/files/unknown_include.cfg", temp.getRoot()); ProvidenceConfigParser config = new ProvidenceConfigParser(registry, true); try { config.parseConfig(file.toPath(), null); fail("no exception"); } catch (ProvidenceConfigException e) { assertEquals("Unknown declared type: unknown.OtherConfig", e.getMessage()); } file = copyResourceTo("/net/morimekta/providence/config/files/unknown_field.cfg", temp.getRoot()); try { config.parseConfig(file.toPath(), null); fail("no exception"); } catch (ProvidenceConfigException e) { assertEquals("No such field unknown_field in config.Database", e.getMessage()); } file = copyResourceTo("/net/morimekta/providence/config/files/unknown_enum_value.cfg", temp.getRoot()); try { config.parseConfig(file.toPath(), null); fail("no exception"); } catch (ProvidenceConfigException e) { assertEquals("No such enum value 'LAST' for config.Value.", e.getMessage()); } file = copyResourceTo("/net/morimekta/providence/config/files/unknown_enum_value2.cfg", temp.getRoot()); try { config.parseConfig(file.toPath(), null); fail("no exception"); } catch (ProvidenceConfigException e) { assertEquals("No such enum value 'second' for config.Value, did you mean 'SECOND'?", e.getMessage()); } }
@Nonnull <M extends PMessage<M, F>, F extends PField> Pair<M, Set<String>> parseConfig(@Nonnull Path configFile, @Nullable M parent) throws ProvidenceConfigException { try { configFile = canonicalFileLocation(configFile); } catch (IOException e) { throw new ProvidenceConfigException(e, "Unable to resolve config file " + configFile) .setFile(configFile.getFileName() .toString()); } Pair<M, Set<String>> result = checkAndParseInternal(configFile, parent); if (result == null) { throw new ProvidenceConfigException("No config: " + configFile.toString()) .setFile(configFile.getFileName() .toString()); } return result; }
ProvidenceConfigParser { @Nonnull <M extends PMessage<M, F>, F extends PField> Pair<M, Set<String>> parseConfig(@Nonnull Path configFile, @Nullable M parent) throws ProvidenceConfigException { try { configFile = canonicalFileLocation(configFile); } catch (IOException e) { throw new ProvidenceConfigException(e, "Unable to resolve config file " + configFile) .setFile(configFile.getFileName() .toString()); } Pair<M, Set<String>> result = checkAndParseInternal(configFile, parent); if (result == null) { throw new ProvidenceConfigException("No config: " + configFile.toString()) .setFile(configFile.getFileName() .toString()); } return result; } }
ProvidenceConfigParser { @Nonnull <M extends PMessage<M, F>, F extends PField> Pair<M, Set<String>> parseConfig(@Nonnull Path configFile, @Nullable M parent) throws ProvidenceConfigException { try { configFile = canonicalFileLocation(configFile); } catch (IOException e) { throw new ProvidenceConfigException(e, "Unable to resolve config file " + configFile) .setFile(configFile.getFileName() .toString()); } Pair<M, Set<String>> result = checkAndParseInternal(configFile, parent); if (result == null) { throw new ProvidenceConfigException("No config: " + configFile.toString()) .setFile(configFile.getFileName() .toString()); } return result; } ProvidenceConfigParser(TypeRegistry registry, boolean strict); }
ProvidenceConfigParser { @Nonnull <M extends PMessage<M, F>, F extends PField> Pair<M, Set<String>> parseConfig(@Nonnull Path configFile, @Nullable M parent) throws ProvidenceConfigException { try { configFile = canonicalFileLocation(configFile); } catch (IOException e) { throw new ProvidenceConfigException(e, "Unable to resolve config file " + configFile) .setFile(configFile.getFileName() .toString()); } Pair<M, Set<String>> result = checkAndParseInternal(configFile, parent); if (result == null) { throw new ProvidenceConfigException("No config: " + configFile.toString()) .setFile(configFile.getFileName() .toString()); } return result; } ProvidenceConfigParser(TypeRegistry registry, boolean strict);  }
ProvidenceConfigParser { @Nonnull <M extends PMessage<M, F>, F extends PField> Pair<M, Set<String>> parseConfig(@Nonnull Path configFile, @Nullable M parent) throws ProvidenceConfigException { try { configFile = canonicalFileLocation(configFile); } catch (IOException e) { throw new ProvidenceConfigException(e, "Unable to resolve config file " + configFile) .setFile(configFile.getFileName() .toString()); } Pair<M, Set<String>> result = checkAndParseInternal(configFile, parent); if (result == null) { throw new ProvidenceConfigException("No config: " + configFile.toString()) .setFile(configFile.getFileName() .toString()); } return result; } ProvidenceConfigParser(TypeRegistry registry, boolean strict);   }