25
25
26
26
public class IncompleteKeyTest {
27
27
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 ;
30
30
31
31
@ Before
32
32
public void setUp () {
33
33
pk1 = IncompleteKey .newBuilder ("ds" , "kind1" ).build ();
34
34
parent1 = Key .newBuilder ("ds" , "kind2" , 10 ).setNamespace ("ns" ).build ();
35
+ parent2 = Key .newBuilder ("ds" , "kind2" , 10 , "test-db" ).setNamespace ("ns" ).build ();
35
36
pk2 = IncompleteKey .newBuilder (parent1 , "kind3" ).build ();
36
37
pk4 = IncompleteKey .newBuilderWithDatabaseId ("ds" , "kind3" , "test-db" ).build ();
38
+ pk5 = IncompleteKey .newBuilder (parent2 , "kind4" ).build ();
37
39
}
38
40
39
41
@ Test
@@ -59,12 +61,18 @@ public void testBuilders() {
59
61
assertEquals ("test-db" , pk4 .getDatabaseId ());
60
62
assertEquals ("kind3" , pk4 .getKind ());
61
63
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 ());
62
69
}
63
70
64
71
@ Test
65
72
public void testParent () {
66
73
assertNull (pk1 .getParent ());
67
74
assertEquals (parent1 , pk2 .getParent ());
75
+ assertEquals (parent2 , pk5 .getParent ());
68
76
Key parent2 = Key .newBuilder ("ds" , "kind3" , "name" ).setNamespace ("ns" ).build ();
69
77
IncompleteKey pk3 = IncompleteKey .newBuilder (parent2 , "kind3" ).build ();
70
78
assertEquals (parent2 , pk3 .getParent ());
0 commit comments