public static Builder newBuilder(Key parent, String kind) { return newBuilder(parent.getProjectId(), kind) .setNamespace(parent.getNamespace()) .addAncestors(parent.getPath()); } }
@Test public void testBuilders() throws Exception { assertEquals("ds", pk1.getProjectId()); assertEquals("kind1", pk1.getKind()); assertTrue(pk1.getAncestors().isEmpty()); assertEquals("ds", pk2.getProjectId()); assertEquals("kind3", pk2.getKind()); assertEquals(parent1.getPath(), pk2.getAncestors()); assertEquals(pk2, IncompleteKey.newBuilder(pk2).build()); IncompleteKey pk3 = IncompleteKey.newBuilder(pk2).setKind("kind4").build(); assertEquals("ds", pk3.getProjectId()); assertEquals("kind4", pk3.getKind()); assertEquals(parent1.getPath(), pk3.getAncestors()); }
assertEquals(PARTIAL_ENTITY2.getKey().getKind(), entity6.getKey().getKind()); assertEquals(PARTIAL_ENTITY2.getKey(), IncompleteKey.newBuilder(entity6.getKey()).build()); assertNotEquals(PARTIAL_ENTITY2.getKey().getPath(), entity6.getKey().getPath()); assertNotEquals(PARTIAL_ENTITY2.getKey(), entity6.getKey()); assertSame(entity5, entities.get(2));
public static Builder newBuilder(Key parent, String kind) { return newBuilder(parent.getProjectId(), kind) .setNamespace(parent.getNamespace()) .addAncestors(parent.getPath()); } }