|
34 | 34 | import com.google.api.core.SettableApiFuture; |
35 | 35 | import com.google.api.gax.rpc.ApiStreamObserver; |
36 | 36 | import com.google.cloud.Timestamp; |
37 | | -import com.google.cloud.firestore.BulkWriter; |
38 | 37 | import com.google.cloud.firestore.CollectionReference; |
39 | 38 | import com.google.cloud.firestore.DocumentReference; |
40 | 39 | import com.google.cloud.firestore.DocumentSnapshot; |
@@ -1316,113 +1315,6 @@ public void deleteNestedFieldUsingFieldPath() throws Exception { |
1316 | 1315 | assertNull(documentSnapshots.getData().get("c.d")); |
1317 | 1316 | } |
1318 | 1317 |
|
1319 | | - @Test |
1320 | | - public void bulkWriterCreate() throws Exception { |
1321 | | - DocumentReference docRef = randomColl.document(); |
1322 | | - |
1323 | | - BulkWriter writer = firestore.bulkWriter(); |
1324 | | - ApiFuture<WriteResult> result = |
1325 | | - writer.create(docRef, Collections.singletonMap("foo", (Object) "bar")); |
1326 | | - writer.close(); |
1327 | | - |
1328 | | - assertNotNull(result.get().getUpdateTime()); |
1329 | | - DocumentSnapshot snapshot = docRef.get().get(); |
1330 | | - assertEquals("bar", snapshot.get("foo")); |
1331 | | - } |
1332 | | - |
1333 | | - @Test |
1334 | | - public void bulkWriterCreateAddsPrecondition() throws Exception { |
1335 | | - DocumentReference docRef = randomColl.document(); |
1336 | | - docRef.set(Collections.singletonMap("foo", (Object) "bar")).get(); |
1337 | | - |
1338 | | - BulkWriter writer = firestore.bulkWriter(); |
1339 | | - ApiFuture<WriteResult> result = |
1340 | | - writer.create(docRef, Collections.singletonMap("foo", (Object) "bar")); |
1341 | | - writer.close(); |
1342 | | - |
1343 | | - try { |
1344 | | - result.get(); |
1345 | | - fail("Create operation should have thrown exception"); |
1346 | | - } catch (Exception e) { |
1347 | | - assertTrue(e.getMessage().contains("Document already exists")); |
1348 | | - } |
1349 | | - } |
1350 | | - |
1351 | | - @Test |
1352 | | - public void bulkWriterSet() throws Exception { |
1353 | | - DocumentReference docRef = randomColl.document(); |
1354 | | - |
1355 | | - BulkWriter writer = firestore.bulkWriter(); |
1356 | | - ApiFuture<WriteResult> result = |
1357 | | - writer.set(docRef, Collections.singletonMap("foo", (Object) "bar")); |
1358 | | - writer.close(); |
1359 | | - |
1360 | | - assertNotNull(result.get().getUpdateTime()); |
1361 | | - DocumentSnapshot snapshot = docRef.get().get(); |
1362 | | - assertEquals("bar", snapshot.get("foo")); |
1363 | | - } |
1364 | | - |
1365 | | - @Test |
1366 | | - public void bulkWriterUpdate() throws Exception { |
1367 | | - DocumentReference docRef = randomColl.document(); |
1368 | | - docRef.set(Collections.singletonMap("foo", "oldValue")).get(); |
1369 | | - |
1370 | | - BulkWriter writer = firestore.bulkWriter(); |
1371 | | - ApiFuture<WriteResult> result = writer.update(docRef, "foo", "newValue"); |
1372 | | - writer.close(); |
1373 | | - |
1374 | | - assertNotNull(result.get().getUpdateTime()); |
1375 | | - DocumentSnapshot snapshot = docRef.get().get(); |
1376 | | - assertEquals("newValue", snapshot.get("foo")); |
1377 | | - } |
1378 | | - |
1379 | | - @Test |
1380 | | - public void bulkWriterUpdateAddsPrecondition() throws Exception { |
1381 | | - DocumentReference docRef = randomColl.document(); |
1382 | | - |
1383 | | - BulkWriter writer = firestore.bulkWriter(); |
1384 | | - ApiFuture<WriteResult> result = writer.update(docRef, "foo", "newValue"); |
1385 | | - writer.close(); |
1386 | | - |
1387 | | - try { |
1388 | | - result.get(); |
1389 | | - fail("Update operation should have thrown exception"); |
1390 | | - } catch (Exception e) { |
1391 | | - assertTrue(e.getMessage().contains("No document to update")); |
1392 | | - } |
1393 | | - } |
1394 | | - |
1395 | | - @Test |
1396 | | - public void bulkWriterDelete() throws Exception { |
1397 | | - DocumentReference docRef = randomColl.document(); |
1398 | | - docRef.set(Collections.singletonMap("foo", "oldValue")).get(); |
1399 | | - |
1400 | | - BulkWriter writer = firestore.bulkWriter(); |
1401 | | - ApiFuture<WriteResult> result = writer.delete(docRef); |
1402 | | - writer.close(); |
1403 | | - |
1404 | | - assertNotNull(result.get().getUpdateTime()); |
1405 | | - // TODO(b/158502664): Remove this check once we can get write times. |
1406 | | - assertEquals(Timestamp.ofTimeSecondsAndNanos(0, 0), result.get().getUpdateTime()); |
1407 | | - DocumentSnapshot snapshot = docRef.get().get(); |
1408 | | - assertNull(snapshot.get("foo")); |
1409 | | - } |
1410 | | - |
1411 | | - @Test |
1412 | | - public void bulkWriterWritesInOrder() throws Exception { |
1413 | | - DocumentReference docRef = randomColl.document(); |
1414 | | - docRef.set(Collections.singletonMap("foo", "oldValue")).get(); |
1415 | | - |
1416 | | - BulkWriter writer = firestore.bulkWriter(); |
1417 | | - writer.set(docRef, Collections.singletonMap("foo", (Object) "bar1")); |
1418 | | - writer.set(docRef, Collections.singletonMap("foo", (Object) "bar2")); |
1419 | | - writer.set(docRef, Collections.singletonMap("foo", (Object) "bar3")); |
1420 | | - writer.close(); |
1421 | | - |
1422 | | - ApiFuture<DocumentSnapshot> result = docRef.get(); |
1423 | | - assertEquals(Collections.singletonMap("foo", "bar3"), result.get().getData()); |
1424 | | - } |
1425 | | - |
1426 | 1318 | @Test |
1427 | 1319 | public void readOnlyTransaction_successfulGet() |
1428 | 1320 | throws ExecutionException, InterruptedException, TimeoutException { |
|
0 commit comments