### Question:
YamlFileResourceProvider { public static YamlFileResource loadFromFile(File file) { try { return new YamlFileResource(file); } catch (ParserException e) { throw new YamlParseException(file.getPath(), e); } } private  YamlFileResourceProvider(); static YamlFileResource loadFromFile(File file);  }### Answer:
@Test public void shouldLoadValidFile() { File yamlFile = TestHelper.getJarFile(TestHelper.PROJECT_ROOT + "service/yaml/validYaml.yml"); YamlFileResource resource = YamlFileResourceProvider.loadFromFile(yamlFile); assertThat(resource.getString("test.jkl"), equalTo("Test test")); }
@Test public void shouldThrowForInvalidFile() { File yamlFile = TestHelper.getJarFile(TestHelper.PROJECT_ROOT + "service/yaml/invalidYaml.yml"); try { YamlFileResourceProvider.loadFromFile(yamlFile); fail("Expected exception to be thrown"); } catch (YamlParseException e) { assertThat(e.getFile(), equalTo(yamlFile.getPath())); assertThat(e.getCause(), instanceOf(ParserException.class)); } }