### Question:
DirectoryRepository implements DataRepository { @Override public <T> T get(final String key, Class<T> type) throws IOException { CompositeFilenameFilter fileFilter = new CompositeFilenameFilter(new FilenameFilter() { @Override public boolean accept(File dir, String name) { String base = Util.base(name); return base.equalsIgnoreCase(key); } }); if (exts != null) { fileFilter.and(new ExtensionFilter(exts)); } Map<String,FileGroup> files = listFiles(fileFilter); if (!files.isEmpty()) { FileGroup grp = files.values().iterator().next(); return objOrNull(grp, type); } return null; } DirectoryRepository(File baseDir, String... exts);  DirectoryRepository(File baseDir, DriverRegistry drivers, String... exts); File getDirectory(); @Override Iterable<Handle<?>> query(Filter<? super Handle<?>> filter); @Override T get(final String key, Class<T> type); @Override void close();  }### Answer:
@Test public void testGet() throws Exception { assertNotNull(repo.get("foo", Workspace.class)); assertNotNull(repo.get("bar", Workspace.class)); assertNull(repo.get("baz", Workspace.class)); }
@Test public void testMetaFileWithOtherFile() throws Exception { File root = clearRepo(); Files.touch(new File(root, "baz.abc")); Files.touch(new File(root, "baz.json")); JSONObject meta = new JSONObject(); meta.put("driver", "geojson"); JSONObject opts = new JSONObject(); opts.put("file", "baz.json"); meta.put("options", opts); writeMetaFile(meta, "baz.jeo"); final AtomicBoolean hit = new AtomicBoolean(false); final Driver<?> d = new GeoJSON() { @Override public GeoJSONDataset open(File file, Map<?, Object> opts) throws IOException { hit.set(true); assertEquals("json", Util.extension(file.getName())); return super.open(file, opts); } }; DirectoryRepository repo2 = new DirectoryRepository(root, new DriverRegistry() { @Override public Iterator<Driver<?>> list() { return (Iterator) Iterators.singletonIterator(d); } }); repo2.get("baz", Object.class); assertTrue(hit.get()); }
@Test public void testMetaFileWithNoFileOption() throws Exception { File root = clearRepo(); Files.touch(new File(root, "baz.json")); Files.touch(new File(root, "baz.jeo")); JSONObject meta = new JSONObject(); meta.put("driver", "geojson"); JSONObject opts = new JSONObject(); meta.put("options", opts); writeMetaFile(meta, "baz.jeo"); assertNotNull(repo.get("baz", Object.class)); }