DataSetLoaderProvider implements LoaderProvider<Document> { @Override public DataSetLoader<Document> jsonLoader() { return (final File path) -> Document.parse(new String(Files.readAllBytes(path.toPath()), StandardCharsets.UTF_8)); }  @Override DataSetLoader<Document> xmlLoader(); @Override DataSetLoader<Document> yamlLoader(); @Override DataSetLoader<Document> jsonLoader(); @Override DataSetLoader<Document> csvLoader(); @Override DataSetLoader<Document> xlsLoader();  }
@Test public void testJsonLoaderLoadUsingProperResource() throws Exception { final DataSetLoader<Document> loader = LOADER_PROVIDER.jsonLoader(); assertThat(loader, notNullValue()); final Document document = loader.load(getFile("test-data.json")); assertThat(document, notNullValue()); final Set<String> tableNames = document.keySet(); assertThat(tableNames.size(), equalTo(2)); assertThat(tableNames, hasItems("JSON_COLLECTION_1", "JSON_COLLECTION_2")); final List<Document> collection1 = document.get("JSON_COLLECTION_1", List.class); assertThat(collection1.size(), equalTo(3)); final List<Document> collection2 = document.get("JSON_COLLECTION_2", List.class); assertThat(collection2.size(), equalTo(1)); }
@Test(expected = NullPointerException.class) public void testJsonLoaderLoadUsingNullFileName() throws IOException { final DataSetLoader<Document> loader = LOADER_PROVIDER.jsonLoader(); assertThat(loader, notNullValue()); loader.load(null); }
@Test(expected = Exception.class) public void testJsonLoaderLoadUsingWrongResource() throws Exception { final DataSetLoader<Document> loader = LOADER_PROVIDER.jsonLoader(); assertThat(loader, notNullValue()); loader.load(getFile("test-data.yaml")); }