@@ -144,6 +144,7 @@ public class ITDatastoreTest {
144
144
private static Key KEY3 ;
145
145
private static Key KEY4 ;
146
146
private static Key KEY5 ;
147
+ private static Key KEY6 ;
147
148
private static final String MARKS_KIND = "Marks" ;
148
149
private static FullEntity <IncompleteKey > PARTIAL_ENTITY1 ;
149
150
private static FullEntity <IncompleteKey > PARTIAL_ENTITY2 ;
@@ -193,6 +194,10 @@ public ITDatastoreTest(
193
194
KEY3 = Key .newBuilder (KEY2 ).setName ("bla" ).setNamespace (NAMESPACE ).build ();
194
195
KEY4 = Key .newBuilder (KEY2 ).setName ("newName1" ).setNamespace (NAMESPACE ).build ();
195
196
KEY5 = Key .newBuilder (KEY2 ).setName ("newName2" ).setNamespace (NAMESPACE ).build ();
197
+ KEY6 =
198
+ Key .newBuilder (options .getProjectId (), KIND2 , 100 , options .getDatabaseId ())
199
+ .setNamespace (NAMESPACE )
200
+ .build ();
196
201
197
202
LIST_VALUE2 = ListValue .of (Collections .singletonList (KeyValue .of (KEY1 )));
198
203
@@ -1787,6 +1792,21 @@ public void testGet() {
1787
1792
assertFalse (entity .contains ("bla" ));
1788
1793
}
1789
1794
1795
+ @ Test
1796
+ public void testIncompleteKey () {
1797
+ Key parentKey = null ;
1798
+ try {
1799
+ IncompleteKey incompleteKey = IncompleteKey .newBuilder (KEY6 , KIND1 ).build ();
1800
+ parentKey = incompleteKey .getParent ();
1801
+ Entity entity = Entity .newBuilder (parentKey ).set ("name" , "val" ).build ();
1802
+ datastore .put (entity );
1803
+ Entity retrievedEntity = datastore .get (parentKey );
1804
+ assertThat (retrievedEntity ).isEqualTo (entity );
1805
+ } finally {
1806
+ datastore .delete (parentKey );
1807
+ }
1808
+ }
1809
+
1790
1810
@ Test
1791
1811
public void testGetWithReadTime () throws InterruptedException {
1792
1812
Key key =
0 commit comments