SubdirsRegressionIO extends RegressionIO { @Override public Object read(final String type, final String identifier) throws IOException { try (InputStream in = new BufferedInputStream(new FileInputStream(new File(getTypeFolder(type, false), createFilename(identifier))))) { return getFormat().read(getFormatContext(), in); } } SubdirsRegressionIO(final File baseDir, final Format format, final boolean createIfAbsent); @Override void write(final String type, final Object o, final String identifier); @Override Object read(final String type, final String identifier); @Override List<String> enumObjects(final String type);  }
@Test(expectedExceptions = FileNotFoundException.class) public void testReadFileNotFound() throws IOException { final File file = new File(tmpdir(), name()); try { final Format format = Mockito.mock(Format.class); final RegressionIO instance = new SubdirsRegressionIO(file, format, true); (new File(file, "bar")).mkdirs(); instance.beginRead(); instance.read("foo", "0"); } finally { delete(file); } }
@Test(expectedExceptions = FileNotFoundException.class) public void testReadDirectoryNotFound() throws IOException { final File file = new File(tmpdir(), name()); try { final Format format = Mockito.mock(Format.class); final RegressionIO instance = new SubdirsRegressionIO(file, format, true); instance.beginRead(); instance.read("foo", "0"); } finally { delete(file); } }