@Test public void testResolveConfig_withParent_badType() { try { File first = copyResourceTo("/net/morimekta/providence/config/files/base_service.cfg", temp.getRoot()); File second = copyResourceTo("/net/morimekta/providence/config/files/stage_db.cfg", temp.getRoot()); ProvidenceConfig config = new ProvidenceConfig(registry, null, true); ConfigSupplier<Service,Service._Field> firstConfig = config.resolveConfig(first); config.resolveConfig(second, firstConfig); fail("no exception"); } catch (ProvidenceConfigException e) { assertThat(e.getMessage(), is("Loaded config type config.Service does not match parent config.Database")); assertThat(e.getFile(), is("stage_db.cfg")); assertThat(e.asString(), is("Error in stage_db.cfg: Loaded config type config.Service does not match parent config.Database")); } }
@Nonnull @Override @SuppressWarnings("unchecked") public <M extends PMessage<M, F>, F extends PField> ConfigSupplier<M, F> resolveConfig(@Nonnull File configFile, @Nullable ConfigSupplier<M, F> parentConfig) throws ProvidenceConfigException { Path configPath = canonicalFileLocation(configFile.toPath()); String path = null; if (parentConfig == null) { path = configPath.toString(); if (loaded.containsKey(path)) { return (ConfigSupplier<M, F>) loaded.get(path); } } ProvidenceConfigSupplier<M, F> supplier = new ProvidenceConfigSupplier<>( configFile, parentConfig, watcher, parser, clock); if (parentConfig == null) { loaded.put(path, supplier); } return supplier; }
ProvidenceConfig implements ConfigResolver { @Nonnull @Override @SuppressWarnings("unchecked") public <M extends PMessage<M, F>, F extends PField> ConfigSupplier<M, F> resolveConfig(@Nonnull File configFile, @Nullable ConfigSupplier<M, F> parentConfig) throws ProvidenceConfigException { Path configPath = canonicalFileLocation(configFile.toPath()); String path = null; if (parentConfig == null) { path = configPath.toString(); if (loaded.containsKey(path)) { return (ConfigSupplier<M, F>) loaded.get(path); } } ProvidenceConfigSupplier<M, F> supplier = new ProvidenceConfigSupplier<>( configFile, parentConfig, watcher, parser, clock); if (parentConfig == null) { loaded.put(path, supplier); } return supplier; } }
ProvidenceConfig implements ConfigResolver { @Nonnull @Override @SuppressWarnings("unchecked") public <M extends PMessage<M, F>, F extends PField> ConfigSupplier<M, F> resolveConfig(@Nonnull File configFile, @Nullable ConfigSupplier<M, F> parentConfig) throws ProvidenceConfigException { Path configPath = canonicalFileLocation(configFile.toPath()); String path = null; if (parentConfig == null) { path = configPath.toString(); if (loaded.containsKey(path)) { return (ConfigSupplier<M, F>) loaded.get(path); } } ProvidenceConfigSupplier<M, F> supplier = new ProvidenceConfigSupplier<>( configFile, parentConfig, watcher, parser, clock); if (parentConfig == null) { loaded.put(path, supplier); } return supplier; } ProvidenceConfig(TypeRegistry registry);  ProvidenceConfig(@Nonnull TypeRegistry registry,
                            @Nullable FileWatcher watcher, boolean strict);  ProvidenceConfig(@Nonnull TypeRegistry registry,
                            @Nullable FileWatcher watcher,
                            boolean strict,
                            @Nonnull Clock clock); }
ProvidenceConfig implements ConfigResolver { @Nonnull @Override @SuppressWarnings("unchecked") public <M extends PMessage<M, F>, F extends PField> ConfigSupplier<M, F> resolveConfig(@Nonnull File configFile, @Nullable ConfigSupplier<M, F> parentConfig) throws ProvidenceConfigException { Path configPath = canonicalFileLocation(configFile.toPath()); String path = null; if (parentConfig == null) { path = configPath.toString(); if (loaded.containsKey(path)) { return (ConfigSupplier<M, F>) loaded.get(path); } } ProvidenceConfigSupplier<M, F> supplier = new ProvidenceConfigSupplier<>( configFile, parentConfig, watcher, parser, clock); if (parentConfig == null) { loaded.put(path, supplier); } return supplier; } ProvidenceConfig(TypeRegistry registry);  ProvidenceConfig(@Nonnull TypeRegistry registry,
                            @Nullable FileWatcher watcher, boolean strict);  ProvidenceConfig(@Nonnull TypeRegistry registry,
                            @Nullable FileWatcher watcher,
                            boolean strict,
                            @Nonnull Clock clock); @Nonnull @Override @SuppressWarnings("unchecked") ConfigSupplier<M, F> resolveConfig(@Nonnull File configFile,
                                       @Nullable ConfigSupplier<M, F> parentConfig); @Nonnull M getConfig(@Nonnull File configFile); @Nonnull M getConfig(@Nonnull File configFile, @Nonnull M parent); }
ProvidenceConfig implements ConfigResolver { @Nonnull @Override @SuppressWarnings("unchecked") public <M extends PMessage<M, F>, F extends PField> ConfigSupplier<M, F> resolveConfig(@Nonnull File configFile, @Nullable ConfigSupplier<M, F> parentConfig) throws ProvidenceConfigException { Path configPath = canonicalFileLocation(configFile.toPath()); String path = null; if (parentConfig == null) { path = configPath.toString(); if (loaded.containsKey(path)) { return (ConfigSupplier<M, F>) loaded.get(path); } } ProvidenceConfigSupplier<M, F> supplier = new ProvidenceConfigSupplier<>( configFile, parentConfig, watcher, parser, clock); if (parentConfig == null) { loaded.put(path, supplier); } return supplier; } ProvidenceConfig(TypeRegistry registry);  ProvidenceConfig(@Nonnull TypeRegistry registry,
                            @Nullable FileWatcher watcher, boolean strict);  ProvidenceConfig(@Nonnull TypeRegistry registry,
                            @Nullable FileWatcher watcher,
                            boolean strict,
                            @Nonnull Clock clock); @Nonnull @Override @SuppressWarnings("unchecked") ConfigSupplier<M, F> resolveConfig(@Nonnull File configFile,
                                       @Nullable ConfigSupplier<M, F> parentConfig); @Nonnull M getConfig(@Nonnull File configFile); @Nonnull M getConfig(@Nonnull File configFile, @Nonnull M parent);  }