1717package com .google .gcloud .datastore ;
1818
1919import static org .junit .Assert .assertEquals ;
20+ import static org .junit .Assert .assertNull ;
2021import static org .junit .Assert .assertTrue ;
2122
23+ import org .junit .Before ;
2224import org .junit .Test ;
2325
2426public class IncompleteKeyTest {
2527
28+ private static IncompleteKey pk1 , pk2 ;
29+ private static Key parent ;
30+
31+ @ Before
32+ public void setUp () {
33+ pk1 = IncompleteKey .builder ("ds" , "kind1" ).build ();
34+ parent = Key .builder ("ds" , "kind2" , 10 ).build ();
35+ pk2 = IncompleteKey .builder (parent , "kind3" ).build ();
36+ }
37+
2638 @ Test
2739 public void testBuilders () throws Exception {
28- IncompleteKey pk1 = IncompleteKey .builder ("ds" , "kind1" ).build ();
2940 assertEquals ("ds" , pk1 .projectId ());
3041 assertEquals ("kind1" , pk1 .kind ());
3142 assertTrue (pk1 .ancestors ().isEmpty ());
3243
33- Key parent = Key .builder ("ds" , "kind2" , 10 ).build ();
34- IncompleteKey pk2 = IncompleteKey .builder (parent , "kind3" ).build ();
3544 assertEquals ("ds" , pk2 .projectId ());
3645 assertEquals ("kind3" , pk2 .kind ());
3746 assertEquals (parent .path (), pk2 .ancestors ());
@@ -42,4 +51,10 @@ public void testBuilders() throws Exception {
4251 assertEquals ("kind4" , pk3 .kind ());
4352 assertEquals (parent .path (), pk3 .ancestors ());
4453 }
54+
55+ @ Test
56+ public void testParent () {
57+ assertNull (pk1 .parent ());
58+ assertEquals (parent , pk2 .parent ());
59+ }
4560}
0 commit comments