@Test public void testSimpleDelete() { metadataStore.write("a/repo", ""); assertEquals("", metadataStore.read("a/repo").get().getOrigin()); metadataStore.delete("a/repo"); assertFalse(metadataStore.read("a/repo").isPresent()); }
@Test public void testChangeOriginFromMetedata() { metadataStore.write("test/repo", "other/repo"); assertEquals("test/repo", metadatas.get("/test/repo.metadata").getName()); assertEquals("other/repo", metadatas.get("/test/repo.metadata").getOrigin()); assertEquals("other/repo", metadatas.get("/other/repo.metadata").getName()); metadataStore.write("test/repo", "other/otherOrigin"); assertEquals("other/otherOrigin", metadatas.get("/test/repo.metadata").getOrigin()); assertEquals(0, metadatas.get("/other/repo.metadata").getForks().size()); }
@Test public void testWriteNewMetadataWithOrigin() { metadataStore.write("test/repo", "other/repo"); assertEquals("test/repo", metadatas.get("/test/repo.metadata").getName()); assertEquals("other/repo", metadatas.get("/other/repo.metadata").getName()); }
@Test public void testWriteTwoForks() { metadataStore.write("test/repo", "origin/repo"); metadataStore.write("fork/repo", "origin/repo"); assertEquals(3, metadatas.size()); assertEquals("test/repo", metadatas.get("/test/repo.metadata").getName()); assertEquals("fork/repo", metadatas.get("/fork/repo.metadata").getName()); assertEquals("origin/repo", metadatas.get("/origin/repo.metadata").getName()); assertEquals(2, metadatas.get("/origin/repo.metadata").getForks().size()); }
@Test public void testComplexDelete() { metadataStore.write("b/repo", "a/repo"); metadataStore.write("c/repo", "b/repo"); metadataStore.write("d/repo", "c/repo"); metadataStore.delete("c/repo"); assertEquals("", metadataStore.read("d/repo").get().getOrigin()); assertEquals("a/repo", metadataStore.read("b/repo").get().getOrigin()); assertEquals("b/repo", metadataStore.read("a/repo").get().getForks().get(0)); assertEquals(0, metadataStore.read("b/repo").get().getForks().size()); assertFalse(metadataStore.read("c/repo").isPresent()); }
@Test public void testComplexForkTracking() { metadataStore.write("b/repo", "a/repo"); metadataStore.write("c/repo", "b/repo"); metadataStore.write("d/repo", "c/repo"); assertEquals("c/repo", metadataStore.read("d/repo").get().getOrigin()); assertEquals("b/repo", metadataStore.read("c/repo").get().getOrigin()); assertEquals("a/repo", metadataStore.read("b/repo").get().getOrigin()); assertEquals("b/repo", metadataStore.read("a/repo").get().getForks().get(0)); assertEquals("c/repo", metadataStore.read("b/repo").get().getForks().get(0)); assertEquals("d/repo", metadataStore.read("c/repo").get().getForks().get(0)); }
@Test public void testFixRightPathToSave() { metadataStore.write("/test/repo", ""); verify(storage).write(eq("/test/repo.metadata"), anyObject()); }
@Test public void testStorageInitialization() { metadataStore.init(); verify(storage).init(eq("default://system/metadata")); }
@Test public void testWriteWithNullOrigin() { metadataStore.write("test/repo", null); assertEquals("test/repo", metadatas.get("/test/repo.metadata").getName()); }