JsonConfigurationLoader implements ConfigurationLoader { @Override public Configuration loadFileConfiguration(String filePath) throws IOException { File configurationFile = new File(filePath); String configurationJson = FileUtils.readFileToString(configurationFile); return loadJsonConfiguration(configurationJson); }  @Override Configuration loadFileConfiguration(String filePath); @Override Configuration loadJsonConfiguration(String json);  }
@Test(expected = IOException.class) public void loadConfigurationFromInvalidPath() throws IOException { String configFilePath = "invalid_path/invalid.json"; JsonConfigurationLoader loader = new JsonConfigurationLoader(); loader.loadFileConfiguration(configFilePath); }
@Test public void loadOneConfiguration() throws StyleCheckerException, IOException { String configFilePath = "src/test/resources/stylechecker/MethodNameCamelCase.json"; JsonConfigurationLoader loader = new JsonConfigurationLoader(); Configuration config = loader.loadFileConfiguration(configFilePath); String methodNameFormatValue = config.getAttribute(StyleName.METHOD_NAME_FORMAT); assertEquals(methodNameFormatValue, StyleName.METHOD_NAME_FORMAT_CAMEL_CASE); }
@Test public void loadTwoConfiguration() throws StyleCheckerException, IOException { String configFilePath = "src/test/resources/stylechecker/WildCardAllow.json"; JsonConfigurationLoader loader = new JsonConfigurationLoader(); Configuration config = loader.loadFileConfiguration(configFilePath); String methodNameFormatValue = config.getAttribute(StyleName.METHOD_NAME_FORMAT); assertEquals(methodNameFormatValue, StyleName.IGNORE_STYLE); String wildCardValue = config.getAttribute(StyleName.WILD_CARD_IMPORT); assertEquals(wildCardValue, StyleName.WILD_CARD_IMPORT_OK); }