); indexTree("roads", EMPTY_ID, null, 0), // indexTree("roads/highways", "a21", "d1", 2), // 1 feature added indexTree("roads/streetsRenamed", "a3", "d2", 1), // tree renamed indexTree("buildings", "a41", null, 1), // 1 feature removed indexTree("buildings/stores", "a5", "d31", 1), // only metadata changed indexTree("buildings/knownUnknown", "a61", "d41", 2), // renamed, changed tree and indexTree("admin", "c1", "d5", 2), // new mixed tree, contains features and subtrees indexTree("admin/area", "c2", "d6", 1), // indexTree("admin/line", EMPTY_ID, "d7", 0)// );
); indexTree("roads", EMPTY_ID, null, 0), // indexTree("roads/highways", "a21", "d1", 2), // 1 feature added indexTree("roads/streetsRenamed", "a3", "d2", 1), // tree renamed indexTree("buildings", "a41", null, 1), // 1 feature removed indexTree("buildings/stores", "a5", "d31", 1), // only metadata changed indexTree("buildings/knownUnknown", "a61", "d41", 2), // renamed, changed tree and indexTree("admin", "c1", "d5", 2), // new mixed tree, contains features and subtrees indexTree("admin/area", "c2", "d6", 1), // indexTree("admin/line", EMPTY_ID, "d7", 0)// );
@Test public void testNestedChanges() { leftTree = createHeadTree(// repoTree("roads", EMPTY_ID, null, 0), // repoTree("roads/highways", EMPTY_ID, "d1", 0), // repoTree("roads/streets", "a3", "d2", 1), // repoTree("buildings", EMPTY_ID, null, 0), // repoTree("buildings/stores", EMPTY_ID, "d3", 0), // repoTree("buildings/unknown", "a6", "d4", 1)// ); rightTree = createStageHeadTree(// indexTree("roads", EMPTY_ID, null, 0), // indexTree("roads/highways", "a21", "d1", 1), // 1 added indexTree("roads/streets", EMPTY_ID, "d2", 0), // 1 removed indexTree("buildings", EMPTY_ID, null, 0), // indexTree("buildings/stores", "a51", "d3", 2), // 2 added indexTree("buildings/unknown", "a6", "d4", 1)// not changed ); final ObjectId newRepoRoot = command.call(); assertNotNull(newRepoRoot); // check all blobs have been moved from the index to the object database verifyRepositoryTree(NodeRef.ROOT, newRepoRoot); ImmutableMap<String, NodeRef> refsByPath = getRefsByPath(newRepoRoot, true); Set<String> expected = set("roads", "roads/highways", "roads/highways/highways.0", "roads/streets", "buildings", "buildings/stores", "buildings/stores/stores.0", "buildings/stores/stores.1", "buildings/unknown", "buildings/unknown/unknown.0"); ImmutableSet<String> actual = refsByPath.keySet(); assertEquals(expected, actual); }
@Test public void testNestedChanges() { leftTree = createHeadTree(// repoTree("roads", EMPTY_ID, null, 0), // repoTree("roads/highways", EMPTY_ID, "d1", 0), // repoTree("roads/streets", "a3", "d2", 1), // repoTree("buildings", EMPTY_ID, null, 0), // repoTree("buildings/stores", EMPTY_ID, "d3", 0), // repoTree("buildings/unknown", "a6", "d4", 1)// ); rightTree = createStageHeadTree(// indexTree("roads", EMPTY_ID, null, 0), // indexTree("roads/highways", "a21", "d1", 1), // 1 added indexTree("roads/streets", EMPTY_ID, "d2", 0), // 1 removed indexTree("buildings", EMPTY_ID, null, 0), // indexTree("buildings/stores", "a51", "d3", 2), // 2 added indexTree("buildings/unknown", "a6", "d4", 1)// not changed ); final ObjectId newRepoRoot = command.call(); assertNotNull(newRepoRoot); // check all blobs have been moved from the index to the object database verifyRepositoryTree(NodeRef.ROOT, newRepoRoot); ImmutableMap<String, NodeRef> refsByPath = getRefsByPath(newRepoRoot, true); Set<String> expected = set("roads", "roads/highways", "roads/highways/highways.0", "roads/streets", "buildings", "buildings/stores", "buildings/stores/stores.0", "buildings/stores/stores.1", "buildings/unknown", "buildings/unknown/unknown.0"); ImmutableSet<String> actual = refsByPath.keySet(); assertEquals(expected, actual); }
@Test public void testRenameNested() { leftTree = createHeadTree(// repoTree("roads", EMPTY_ID, null, 0), // repoTree("roads/highways", "a2", "d1", 2), // repoTree("roads/streets", "a3", "d2", 2) // ); rightTree = createStageHeadTree(// indexTree("roads", EMPTY_ID, null, 0), // indexTree("roads/highways", "a2", "d1", 2), // indexTree("roads/streetsRenamed", "a3", "d2", 2) // ); ObjectId newRepoRoot = command.call(); assertNotNull(newRepoRoot); // check all blobs have been moved from the index to the object database verifyRepositoryTree(NodeRef.ROOT, newRepoRoot); ImmutableMap<String, NodeRef> refsByPath = getTreeRefsByPath(newRepoRoot); assertEquals(3, refsByPath.size()); assertTrue(refsByPath.containsKey("roads")); assertTrue(refsByPath.containsKey("roads/highways")); assertTrue(refsByPath.containsKey("roads/streetsRenamed")); }
@Test public void testRenameNested() { leftTree = createHeadTree(// repoTree("roads", EMPTY_ID, null, 0), // repoTree("roads/highways", "a2", "d1", 2), // repoTree("roads/streets", "a3", "d2", 2) // ); rightTree = createStageHeadTree(// indexTree("roads", EMPTY_ID, null, 0), // indexTree("roads/highways", "a2", "d1", 2), // indexTree("roads/streetsRenamed", "a3", "d2", 2) // ); ObjectId newRepoRoot = command.call(); assertNotNull(newRepoRoot); // check all blobs have been moved from the index to the object database verifyRepositoryTree(NodeRef.ROOT, newRepoRoot); ImmutableMap<String, NodeRef> refsByPath = getTreeRefsByPath(newRepoRoot); assertEquals(3, refsByPath.size()); assertTrue(refsByPath.containsKey("roads")); assertTrue(refsByPath.containsKey("roads/highways")); assertTrue(refsByPath.containsKey("roads/streetsRenamed")); }
@Test public void testDeletes() { leftTree = createHeadTree(// repoTree("roads", EMPTY_ID, null, 0), // repoTree("roads/highways", "a2", "d1", 10), // repoTree("roads/streets", "a3", "d2", 10), // repoTree("buildings", EMPTY_ID, null, 0), // repoTree("buildings/stores", "a5", "d3", 5), // repoTree("buildings/unknown", "a6", "d4", 5), // repoTree("buildings/towers", "a7", "d5", 5)// ); rightTree = createStageHeadTree(// indexTree("roads", EMPTY_ID, null, 0), // indexTree("roads/highways", "a2", "d1", 10), // indexTree("buildings", EMPTY_ID, null, 0), // indexTree("buildings/stores", "a5", "d31", 5)// ); final ObjectId newRepoRoot = command.call(); assertNotNull(newRepoRoot); // check all blobs have been moved from the index to the object database verifyRepositoryTree(NodeRef.ROOT, newRepoRoot); ImmutableMap<String, NodeRef> refsByPath = getTreeRefsByPath(newRepoRoot); assertEquals(set("roads", "roads/highways", "buildings", "buildings/stores"), refsByPath.keySet()); }
@Test public void testEmptyRepoSingleStagedTree() { rightTree = createStageHeadTree(// indexTree("roads", "a1", "d1", 10)// ); ObjectId newRepoRoot = command.call(); assertNotNull(newRepoRoot); // print(newRepoRoot); // check all blobs have been moved from the index to the object database verifyRepositoryTree(NodeRef.ROOT, newRepoRoot); ImmutableMap<String, NodeRef> refsByPath = getTreeRefsByPath(newRepoRoot); assertEquals(1, refsByPath.size()); assertTrue(refsByPath.keySet().contains("roads")); }
@Test public void testDeletes() { leftTree = createHeadTree(// repoTree("roads", EMPTY_ID, null, 0), // repoTree("roads/highways", "a2", "d1", 10), // repoTree("roads/streets", "a3", "d2", 10), // repoTree("buildings", EMPTY_ID, null, 0), // repoTree("buildings/stores", "a5", "d3", 5), // repoTree("buildings/unknown", "a6", "d4", 5), // repoTree("buildings/towers", "a7", "d5", 5)// ); rightTree = createStageHeadTree(// indexTree("roads", EMPTY_ID, null, 0), // indexTree("roads/highways", "a2", "d1", 10), // indexTree("buildings", EMPTY_ID, null, 0), // indexTree("buildings/stores", "a5", "d31", 5)// ); final ObjectId newRepoRoot = command.call(); assertNotNull(newRepoRoot); // check all blobs have been moved from the index to the object database verifyRepositoryTree(NodeRef.ROOT, newRepoRoot); ImmutableMap<String, NodeRef> refsByPath = getTreeRefsByPath(newRepoRoot); assertEquals(set("roads", "roads/highways", "buildings", "buildings/stores"), refsByPath.keySet()); }
@Test public void testEmptyRepoSingleStagedTree() { rightTree = createStageHeadTree(// indexTree("roads", "a1", "d1", 10)// ); ObjectId newRepoRoot = command.call(); assertNotNull(newRepoRoot); // print(newRepoRoot); // check all blobs have been moved from the index to the object database verifyRepositoryTree(NodeRef.ROOT, newRepoRoot); ImmutableMap<String, NodeRef> refsByPath = getTreeRefsByPath(newRepoRoot); assertEquals(1, refsByPath.size()); assertTrue(refsByPath.keySet().contains("roads")); }
@Test public void testMetadataIdChangeOnly() { leftTree = createHeadTree(// repoTree("buildings", EMPTY_ID, null, 0), // repoTree("buildings/stores", "a5", "d3", 5)// old md id is d3 ); rightTree = createStageHeadTree(// indexTree("buildings", EMPTY_ID, null, 0), // indexTree("buildings/stores", "a5", "d31", 5)// new md id is d31 ); ObjectId newRepoRoot = command.call(); assertNotNull(newRepoRoot); // check all blobs have been moved from the index to the object database verifyRepositoryTree(NodeRef.ROOT, newRepoRoot); ImmutableMap<String, NodeRef> refsByPath = getTreeRefsByPath(newRepoRoot); assertEquals(set("buildings", "buildings/stores"), refsByPath.keySet()); assertEquals(id("d31"), refsByPath.get("buildings/stores").getMetadataId()); }
@Test public void testMetadataIdChangeOnly() { leftTree = createHeadTree(// repoTree("buildings", EMPTY_ID, null, 0), // repoTree("buildings/stores", "a5", "d3", 5)// old md id is d3 ); rightTree = createStageHeadTree(// indexTree("buildings", EMPTY_ID, null, 0), // indexTree("buildings/stores", "a5", "d31", 5)// new md id is d31 ); ObjectId newRepoRoot = command.call(); assertNotNull(newRepoRoot); // check all blobs have been moved from the index to the object database verifyRepositoryTree(NodeRef.ROOT, newRepoRoot); ImmutableMap<String, NodeRef> refsByPath = getTreeRefsByPath(newRepoRoot); assertEquals(set("buildings", "buildings/stores"), refsByPath.keySet()); assertEquals(id("d31"), refsByPath.get("buildings/stores").getMetadataId()); }
@Test public void testRename() { leftTree = createHeadTree(// repoTree("roads", EMPTY_ID, null, 0) // ); rightTree = createStageHeadTree(// indexTree("roadsRenamed", EMPTY_ID, null, 0) // ); ObjectId newRepoRoot = command.call(); assertNotNull(newRepoRoot); // check all blobs have been moved from the index to the object database verifyRepositoryTree(NodeRef.ROOT, newRepoRoot); ImmutableMap<String, NodeRef> refsByPath = getTreeRefsByPath(newRepoRoot); assertEquals(1, refsByPath.size()); assertTrue(refsByPath.containsKey("roadsRenamed")); }
@Test public void testRename() { leftTree = createHeadTree(// repoTree("roads", EMPTY_ID, null, 0) // ); rightTree = createStageHeadTree(// indexTree("roadsRenamed", EMPTY_ID, null, 0) // ); ObjectId newRepoRoot = command.call(); assertNotNull(newRepoRoot); // check all blobs have been moved from the index to the object database verifyRepositoryTree(NodeRef.ROOT, newRepoRoot); ImmutableMap<String, NodeRef> refsByPath = getTreeRefsByPath(newRepoRoot); assertEquals(1, refsByPath.size()); assertTrue(refsByPath.containsKey("roadsRenamed")); }