FileAppConfigStore implements AppConfigStore { @Override public AppConfig read(ObjectMapper objectMapper, AppConfig defaultConfig) throws UnableToReadAppConfigException { try { log.info("Reading app configuration from path: {}", appConfigPath); File appConfigFile = Paths.get(appConfigPath).toFile(); if (!appConfigFile.exists()) { log.info("App configuration not exist, creating default [path={}]", appConfigPath); store(objectMapper, defaultConfig); } return objectMapper.readValue(Paths.get(appConfigPath).toFile(), AppConfig.class); } catch (IOException | UnableToStoreAppConfigException e) { throw new UnableToReadAppConfigException(e); } }  @Override AppConfig read(ObjectMapper objectMapper, AppConfig defaultConfig); @Override void store(ObjectMapper objectMapper, AppConfig appConfig);  }
@Test public void shouldCreateDefaultConfig() throws UnableToReadAppConfigException, UnableToStoreAppConfigException { File configFile = Paths.get(folder.getRoot().getAbsolutePath(), "test").toFile(); assertThat(configFile).doesNotExist(); appConfigStore = new FileAppConfigStore(configFile.toString()); AppConfig appConfig = appConfigStore.read(new ObjectMapper(), defaultConfig()); assertThat(configFile).exists(); assertThat(appConfig.getGroup("test")).isNotNull(); }