@@ -312,8 +312,9 @@ private List<Entity> setUpBatchTests(Key taskKey1, Key taskKey2) {
312312
313313 @ Test
314314 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 ());
317318 Entity task1 = Entity .builder (taskKey1 )
318319 .set ("type" , "Personal" )
319320 .set ("done" , false )
@@ -326,7 +327,6 @@ public void testBatchUpsert() {
326327 .set ("priority" , 5 )
327328 .set ("description" , "Integrate Cloud Datastore" )
328329 .build ();
329- // [START batch_upsert]
330330 Batch batch = datastore .newBatch ();
331331 batch .put (task1 , task2 );
332332 batch .submit ();
@@ -737,15 +737,9 @@ private Cursor cursorPaging(int pageSize, Cursor pageCursor) {
737737
738738 @ Test
739739 public void testEventualConsistentQuery () {
740- setUpQueryTests ();
741740 // [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.
747742 // [END eventual_consistent_query]
748- assertValidQuery (query );
749743 }
750744
751745 @ Test
@@ -795,8 +789,8 @@ public void testTransactionalUpdate() {
795789 assertSuccessfulTransfer (keys .get (0 ), keys .get (1 ));
796790 }
797791
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 ) {
800794 Transaction txn = datastore .newTransaction ();
801795 try {
802796 Entity from = txn .get (fromKey );
@@ -811,8 +805,8 @@ private void transferFunds(Key fromKey, Key toKey, long amount) {
811805 txn .rollback ();
812806 }
813807 }
814- // [END transactional_update]
815808 }
809+ // [END transactional_update]
816810
817811 @ Test
818812 public void testTransactionalRetry () {
0 commit comments