use of org.locationtech.geogig.api.plumbing.diff.DepthTreeIterator in project GeoGig by boundlessgeo.
the class RevTreeBuilderTest method testRemove.
@Test
public void testRemove() throws Exception {
final int numEntries = 1000;
ObjectId treeId = createAndSaveTree(numEntries, true);
final RevTree tree = odb.getTree(treeId);
// collect some keys to remove
final Set<String> removedKeys = new HashSet<String>();
{
int i = 0;
DepthTreeIterator it = new DepthTreeIterator("", ObjectId.NULL, tree, odb, Strategy.CHILDREN);
for (; it.hasNext(); i++) {
NodeRef entry = it.next();
if (i % 10 == 0) {
removedKeys.add(entry.path());
}
}
assertEquals(100, removedKeys.size());
}
final RevTreeBuilder builder = tree.builder(odb);
for (String key : removedKeys) {
assertTrue(builder.get(key).isPresent());
builder.remove(key);
assertFalse(builder.get(key).isPresent());
}
final RevTree tree2 = builder.build();
for (String key : removedKeys) {
assertFalse(repo.getTreeChild(tree2, key).isPresent());
}
}
Aggregations