2525
2626public class IncompleteKeyTest {
2727
28- private static IncompleteKey pk1 , pk2 , pk4 ;
29- private static Key parent1 ;
28+ private static IncompleteKey pk1 , pk2 , pk4 , pk5 ;
29+ private static Key parent1 , parent2 ;
3030
3131 @ Before
3232 public void setUp () {
3333 pk1 = IncompleteKey .newBuilder ("ds" , "kind1" ).build ();
3434 parent1 = Key .newBuilder ("ds" , "kind2" , 10 ).setNamespace ("ns" ).build ();
35+ parent2 = Key .newBuilder ("ds" , "kind2" , 10 , "test-db" ).setNamespace ("ns" ).build ();
3536 pk2 = IncompleteKey .newBuilder (parent1 , "kind3" ).build ();
3637 pk4 = IncompleteKey .newBuilderWithDatabaseId ("ds" , "kind3" , "test-db" ).build ();
38+ pk5 = IncompleteKey .newBuilder (parent2 , "kind4" ).build ();
3739 }
3840
3941 @ Test
@@ -59,12 +61,18 @@ public void testBuilders() {
5961 assertEquals ("test-db" , pk4 .getDatabaseId ());
6062 assertEquals ("kind3" , pk4 .getKind ());
6163 assertTrue (pk4 .getAncestors ().isEmpty ());
64+
65+ assertEquals ("ds" , pk5 .getProjectId ());
66+ assertEquals ("test-db" , pk5 .getDatabaseId ());
67+ assertEquals ("kind4" , pk5 .getKind ());
68+ assertEquals (parent2 .getPath (), pk5 .getAncestors ());
6269 }
6370
6471 @ Test
6572 public void testParent () {
6673 assertNull (pk1 .getParent ());
6774 assertEquals (parent1 , pk2 .getParent ());
75+ assertEquals (parent2 , pk5 .getParent ());
6876 Key parent2 = Key .newBuilder ("ds" , "kind3" , "name" ).setNamespace ("ns" ).build ();
6977 IncompleteKey pk3 = IncompleteKey .newBuilder (parent2 , "kind3" ).build ();
7078 assertEquals (parent2 , pk3 .getParent ());
0 commit comments