FolderPath { public void setName(String newName) { if (!isRoot()) { path[path.length - 1] = newName; } } FolderPath(String... path);  FolderPath(FolderPath parent, String... path); FolderPath getParent(); boolean isRoot(); String getName(); void setName(String newName); String serializeAsString(); static FolderPath deserializeFromString(String pathAsString); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString();  }
@Test public void setName() throws Exception { String oldName = "beer"; FolderPath folderPath = new FolderPath("foo", "bar", oldName); assertEquals(oldName, folderPath.getName()); String newName = "tom"; folderPath.setName(newName); assertEquals(newName, folderPath.getName()); }