DirListingMetadata extends ExpirableMetadata { public PathMetadata get(Path childPath) { checkChildPath(childPath); return listMap.get(childPath); } DirListingMetadata(Path path, Collection<PathMetadata> listing,
      boolean isAuthoritative, long lastUpdated);  DirListingMetadata(Path path, Collection<PathMetadata> listing,
      boolean isAuthoritative);  DirListingMetadata(DirListingMetadata d); Path getPath(); Collection<PathMetadata> getListing(); Set<Path> listTombstones(); DirListingMetadata withoutTombstones(); int numEntries(); boolean isAuthoritative(); Tristate isEmpty(); void setAuthoritative(boolean authoritative); PathMetadata get(Path childPath); void markDeleted(Path childPath, long lastUpdated); void remove(Path childPath); boolean put(PathMetadata childPathMetadata); @Override String toString(); synchronized List<PathMetadata> removeExpiredEntriesFromListing(
      long ttl, long now); void prettyPrint(StringBuilder sb); String prettyPrint(); static final Collection<PathMetadata> EMPTY_DIR; }
@Test public void testGet() { Path path = new Path("/path"); PathMetadata pathMeta1 = new PathMetadata( new S3AFileStatus(true, new Path(path, "dir1"), TEST_OWNER)); PathMetadata pathMeta2 = new PathMetadata( new S3AFileStatus(true, new Path(path, "dir2"), TEST_OWNER)); PathMetadata pathMeta3 = new PathMetadata( new S3AFileStatus(123, 456, new Path(path, "file1"), 8192, TEST_OWNER, TEST_ETAG, TEST_VERSION_ID)); List<PathMetadata> listing = Arrays.asList(pathMeta1, pathMeta2, pathMeta3); DirListingMetadata meta = new DirListingMetadata(path, listing, false); assertEquals(path, meta.getPath()); assertNotNull(meta.getListing()); assertFalse(meta.getListing().isEmpty()); assertTrue(meta.getListing().contains(pathMeta1)); assertTrue(meta.getListing().contains(pathMeta2)); assertTrue(meta.getListing().contains(pathMeta3)); assertFalse(meta.isAuthoritative()); assertEquals(pathMeta1, meta.get(pathMeta1.getFileStatus().getPath())); assertEquals(pathMeta2, meta.get(pathMeta2.getFileStatus().getPath())); assertEquals(pathMeta3, meta.get(pathMeta3.getFileStatus().getPath())); assertNull(meta.get(new Path(path, "notfound"))); }
@Test public void testGetNull() { Path path = new Path("/path"); DirListingMetadata meta = new DirListingMetadata(path, null, false); exception.expect(NullPointerException.class); exception.expectMessage(notNullValue(String.class)); meta.get(null); }
@Test public void testGetRoot() { Path path = new Path("/path"); DirListingMetadata meta = new DirListingMetadata(path, null, false); exception.expect(IllegalArgumentException.class); exception.expectMessage(notNullValue(String.class)); meta.get(new Path("/")); }
@Test public void testGetNotChild() { Path path = new Path("/path"); DirListingMetadata meta = new DirListingMetadata(path, null, false); exception.expect(IllegalArgumentException.class); exception.expectMessage(notNullValue(String.class)); meta.get(new Path("/different/ancestor")); }