DirectoryEntry extends Entry { @Override public DirectoryEntry copy() { DirectoryEntry result = copyEntry(); for (Entry child : myChildren) { result.unsafeAddChild(child.copy()); } return result; } DirectoryEntry(int id, String name);  DirectoryEntry(Stream s); @Override void write(Stream s); @Override boolean isDirectory(); @Override void addChild(Entry child); @Override void removeChild(Entry child); @Override List<Entry> getChildren(); @Override boolean hasUnavailableContent(List<Entry> entriesWithUnavailableContent); @Override DirectoryEntry copy(); @Override void collectDifferencesWith(Entry right, List<Difference> result);  }
@Test public void testCopyingWithContent() { Entry dir = new DirectoryEntry(42, "name"); Entry copy = dir.copy(); assertEquals(42, copy.getId()); assertEquals("name", copy.getPath()); }