DirListingMetadata { public void remove(Path childPath) { checkChildPath(childPath); listMap.remove(childPath); } 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); void remove(Path childPath); boolean put(FileStatus childFileStatus); @Override String toString(); void prettyPrint(StringBuilder sb); String prettyPrint(); static final Collection<PathMetadata> EMPTY_DIR; }
@Test public void testRemove() { 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)); 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()); meta.remove(pathMeta1.getFileStatus().getPath()); assertFalse(meta.getListing().contains(pathMeta1)); assertNull(meta.get(pathMeta1.getFileStatus().getPath())); }
@Test public void testRemoveNull() { Path path = new Path("/path"); DirListingMetadata meta = new DirListingMetadata(path, null, false); exception.expect(NullPointerException.class); exception.expectMessage(notNullValue(String.class)); meta.remove(null); }
@Test public void testRemoveRoot() { Path path = new Path("/path"); DirListingMetadata meta = new DirListingMetadata(path, null, false); exception.expect(IllegalArgumentException.class); exception.expectMessage(notNullValue(String.class)); meta.remove(new Path("/")); }
@Test public void testRemoveNotChild() { Path path = new Path("/path"); DirListingMetadata meta = new DirListingMetadata(path, null, false); exception.expect(IllegalArgumentException.class); exception.expectMessage(notNullValue(String.class)); meta.remove(new Path("/different/ancestor")); }