DataSetLoaderProvider implements LoaderProvider<IDataSet> { @Override public DataSetLoader<IDataSet> csvLoader() { return (final File path) -> { try { return defineReplaceableExpressions(new CsvDataSet(path)); } catch (final DataSetException e) { throw new IOException(e); } }; }  @Override DataSetLoader<IDataSet> xmlLoader(); @Override DataSetLoader<IDataSet> yamlLoader(); @Override DataSetLoader<IDataSet> jsonLoader(); @Override DataSetLoader<IDataSet> csvLoader(); @Override DataSetLoader<IDataSet> xlsLoader();  }
@Test(expected = IOException.class) public void testCsvLoaderLoadUsingWrongFileResource() throws Exception { final DataSetLoader<IDataSet> loader = LOADER_PROVIDER.csvLoader(); assertThat(loader, notNullValue()); loader.load(getFile("test-data.json")); }
@Test(expected = IOException.class) public void testCsvLoaderLoadUsingWrongDirectoryResource() throws Exception { final DataSetLoader<IDataSet> loader = LOADER_PROVIDER.csvLoader(); assertThat(loader, notNullValue()); loader.load(getFile("./META-INF")); }
@Test public void testCsvLoaderLoadUsingProperResource() throws Exception { final DataSetLoader<IDataSet> loader = LOADER_PROVIDER.csvLoader(); assertThat(loader, notNullValue()); final IDataSet dataSet = loader.load(getFile("test-data")); assertThat(dataSet, notNullValue()); final List<String> tableNames = Arrays.asList(dataSet.getTableNames()); assertThat(tableNames.size(), equalTo(2)); assertThat(tableNames, hasItems("CSV_TABLE_1", "CSV_TABLE_2")); final ITable table1 = dataSet.getTable("CSV_TABLE_1"); assertThat(table1.getRowCount(), equalTo(3)); final ITable table2 = dataSet.getTable("CSV_TABLE_2"); assertThat(table2.getRowCount(), equalTo(1)); }
@Test(expected = NullPointerException.class) public void testCsvLoaderLoadUsingNullFileName() throws IOException, DataSetException { final DataSetLoader<IDataSet> loader = LOADER_PROVIDER.csvLoader(); assertThat(loader, notNullValue()); loader.load(null); }