### Question:
ConfigurationLoader { public Map<String, Object> loadConfiguration(File file) throws IOException { Map<String, Object> config = new HashMap<>(defaultConfig); Map<String, Object> tmpConfig; try (InputStream input = new FileInputStream(file)) { Yaml yaml = new Yaml(); tmpConfig = yaml.load(input); if (tmpConfig == null) { return config; } for (Map.Entry element : tmpConfig.entrySet()) { String key = (String) element.getKey(); if (!variableNames.contains(key)) { throw new InvalidVariableException("unknown variable: " + key); } else { config.put(key, element.getValue()); } } } return config; } ConfigurationLoader(List<Variable> variables); Map<String, Object> loadConfiguration(File file);  }### Answer:
@Test public void load() throws Exception { List<Variable> list = new ArrayList<>(); list.add(new Variable("probe")); list.add(new Variable("mode")); list.add(new Variable("should-have-default", "should have default value", "default")); ConfigurationLoader config = new ConfigurationLoader(list); Map<String, Object> result; try { result = config.loadConfiguration(testYML); } catch (IOException e) { throw new RuntimeException(e); } assertEquals(createTestingProbeList(), result.get("probe")); assertTrue(result.get("probe") instanceof ArrayList); assertEquals("continual", result.get("mode")); assertFalse(result.get("mode") instanceof ArrayList); assertTrue(result.get("mode") instanceof String); assertEquals("default", result.get("should-have-default")); assertFalse(result.get("should-have-default") instanceof ArrayList); assertTrue(result.get("should-have-default") instanceof String); }
@Test(expected = InvalidVariableException.class) public void invalidVariable() throws Exception { List<Variable> variables = Collections.singletonList(new Variable("allowed")); (new ConfigurationLoader(variables)).loadConfiguration(testYML); }