@@ -312,8 +312,9 @@ private List<Entity> setUpBatchTests(Key taskKey1, Key taskKey2) {
312
312
313
313
@ Test
314
314
public void testBatchUpsert () {
315
- Key taskKey1 = keyFactory .newKey (1 );
316
- Key taskKey2 = keyFactory .newKey (2 );
315
+ // [START batch_upsert]
316
+ Key taskKey1 = datastore .allocateId (keyFactory .newKey ());
317
+ Key taskKey2 = datastore .allocateId (keyFactory .newKey ());
317
318
Entity task1 = Entity .builder (taskKey1 )
318
319
.set ("type" , "Personal" )
319
320
.set ("done" , false )
@@ -326,7 +327,6 @@ public void testBatchUpsert() {
326
327
.set ("priority" , 5 )
327
328
.set ("description" , "Integrate Cloud Datastore" )
328
329
.build ();
329
- // [START batch_upsert]
330
330
Batch batch = datastore .newBatch ();
331
331
batch .put (task1 , task2 );
332
332
batch .submit ();
@@ -737,15 +737,9 @@ private Cursor cursorPaging(int pageSize, Cursor pageCursor) {
737
737
738
738
@ Test
739
739
public void testEventualConsistentQuery () {
740
- setUpQueryTests ();
741
740
// [START eventual_consistent_query]
742
- Query <Entity > query = Query .entityQueryBuilder ()
743
- .kind ("Task" )
744
- .filter (PropertyFilter .hasAncestor (
745
- datastore .newKeyFactory ().kind ("TaskList" ).newKey ("default" )))
746
- .build ();
741
+ // Read consistency cannot be specified in gcloud-java.
747
742
// [END eventual_consistent_query]
748
- assertValidQuery (query );
749
743
}
750
744
751
745
@ Test
@@ -795,8 +789,8 @@ public void testTransactionalUpdate() {
795
789
assertSuccessfulTransfer (keys .get (0 ), keys .get (1 ));
796
790
}
797
791
798
- private void transferFunds ( Key fromKey , Key toKey , long amount ) {
799
- // [START transactional_update]
792
+ // [START transactional_update]
793
+ void transferFunds ( Key fromKey , Key toKey , long amount ) {
800
794
Transaction txn = datastore .newTransaction ();
801
795
try {
802
796
Entity from = txn .get (fromKey );
@@ -811,8 +805,8 @@ private void transferFunds(Key fromKey, Key toKey, long amount) {
811
805
txn .rollback ();
812
806
}
813
807
}
814
- // [END transactional_update]
815
808
}
809
+ // [END transactional_update]
816
810
817
811
@ Test
818
812
public void testTransactionalRetry () {
0 commit comments