private void verifyTreeStructure(ObjectId treeId, NodeRef... treeRefs) { Set<String> expectedPaths = ImmutableSet .copyOf(Iterables.transform(Arrays.asList(treeRefs), (nr) -> nr.path())); ImmutableMap<String, NodeRef> refs = getTreeRefsByPath(treeId); assertEquals(expectedPaths, refs.keySet()); }
private void verifyTreeStructure(ObjectId treeId, NodeRef... treeRefs) { Set<String> expectedPaths = ImmutableSet .copyOf(Iterables.transform(Arrays.asList(treeRefs), (nr) -> nr.path())); ImmutableMap<String, NodeRef> refs = getTreeRefsByPath(treeId); assertEquals(expectedPaths, refs.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 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 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")); }
@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 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 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 testDeleteAll() { 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(); final ObjectId newRepoRoot = command.call(); assertNotNull(newRepoRoot); ImmutableMap<String, NodeRef> refsByPath = getTreeRefsByPath(newRepoRoot); assertEquals(set(), refsByPath.keySet()); }
@Test public void testDeleteAll() { 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(); final ObjectId newRepoRoot = command.call(); assertNotNull(newRepoRoot); ImmutableMap<String, NodeRef> refsByPath = getTreeRefsByPath(newRepoRoot); assertEquals(set(), refsByPath.keySet()); }
@Test public void testNoChanges() { leftTree = createHeadTree(// 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(// repoTree("buildings", EMPTY_ID, null, 0), // repoTree("buildings/stores", "a5", "d3", 5), // repoTree("buildings/unknown", "a6", "d4", 5), // repoTree("buildings/towers", "a7", "d5", 5)// ); 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(4, refsByPath.size()); Set<String> expected = set("buildings", "buildings/stores", "buildings/unknown", "buildings/towers"); assertEquals(expected, refsByPath.keySet()); }
@Test public void testNoChanges() { leftTree = createHeadTree(// 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(// repoTree("buildings", EMPTY_ID, null, 0), // repoTree("buildings/stores", "a5", "d3", 5), // repoTree("buildings/unknown", "a6", "d4", 5), // repoTree("buildings/towers", "a7", "d5", 5)// ); 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(4, refsByPath.size()); Set<String> expected = set("buildings", "buildings/stores", "buildings/unknown", "buildings/towers"); assertEquals(expected, refsByPath.keySet()); }
@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 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()); }