SubdirsRegressionIO extends RegressionIO { @Override public List<String> enumObjects(final String type) throws IOException { final File subDir = getTypeFolder(type, false); if (!subDir.exists()) { s_logger.info("Directory {} doesn't exist", subDir); return Collections.<String>emptyList(); } s_logger.info("Scanning {}", subDir.getAbsolutePath()); final File[] files = subDir.listFiles(); if (files == null) { throw new OpenGammaRuntimeException("No files found in " + subDir); } final List<String> identifiers = new ArrayList<String>(files.length); for (File file : files) { if (file.isFile()) { final String name = file.getName(); if (isIdentifierIncluded(name)) { String identifier = stripIdentifierExtension(name); identifiers.add(identifier); } } } s_logger.debug("Found {} objects", identifiers.size()); return identifiers; } 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 = IllegalArgumentException.class) public void testEnumObjectsNotDirectory() 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, "foo")).createNewFile(); instance.beginRead(); instance.enumObjects("foo"); } finally { delete(file); } }