use of com.google.cloud.firestore.DocumentSnapshot in project java-firestore by googleapis.
the class ITBulkWriterTest method bulkWriterUpdate.
@Test
public void bulkWriterUpdate() throws Exception {
DocumentReference docRef = randomColl.document();
docRef.set(Collections.singletonMap("foo", "oldValue")).get();
BulkWriter writer = firestore.bulkWriter();
ApiFuture<WriteResult> result = writer.update(docRef, "foo", "newValue");
writer.close();
assertNotNull(result.get().getUpdateTime());
DocumentSnapshot snapshot = docRef.get().get();
assertEquals("newValue", snapshot.get("foo"));
}
use of com.google.cloud.firestore.DocumentSnapshot in project java-firestore by googleapis.
the class ITBulkWriterTest method bulkWriterSet.
@Test
public void bulkWriterSet() throws Exception {
DocumentReference docRef = randomColl.document();
BulkWriter writer = firestore.bulkWriter();
ApiFuture<WriteResult> result = writer.set(docRef, Collections.singletonMap("foo", "bar"));
writer.close();
assertNotNull(result.get().getUpdateTime());
DocumentSnapshot snapshot = docRef.get().get();
assertEquals("bar", snapshot.get("foo"));
}
use of com.google.cloud.firestore.DocumentSnapshot in project java-firestore by googleapis.
the class ITSystemTest method testRecursiveDeleteNestedDocument.
@Test
public void testRecursiveDeleteNestedDocument() throws Exception {
setupRecursiveDeleteTest();
DocumentReference document = randomColl.document("bob/parentsCol/daniel");
firestore.recursiveDelete(document).get();
DocumentSnapshot snap = document.get().get();
assertFalse(snap.exists());
assertEquals(1, countDocumentChildren(randomColl.document("bob")));
assertEquals(3, countCollectionChildren(randomColl));
}
use of com.google.cloud.firestore.DocumentSnapshot in project java-firestore by googleapis.
the class ITSystemTest method addDocument.
@Test
public void addDocument() throws Exception {
DocumentReference documentReference = randomColl.add(SINGLE_FIELD_MAP).get();
assertEquals(20, documentReference.getId().length());
DocumentSnapshot documentSnapshot = documentReference.get().get();
assertEquals(SINGLE_FIELD_OBJECT, documentSnapshot.toObject(SingleField.class));
}
use of com.google.cloud.firestore.DocumentSnapshot in project java-firestore by googleapis.
the class ITSystemTest method deserializeCustomList.
@Test
public void deserializeCustomList() throws Exception {
LocalFirestoreHelper.CustomList customList = new LocalFirestoreHelper.CustomList();
customList.fooList = FOO_LIST;
DocumentReference documentReference = randomColl.document("doc1");
documentReference.set(customList).get();
DocumentSnapshot documentSnapshots = documentReference.get().get();
LocalFirestoreHelper.CustomList targetCustomList = documentSnapshots.toObject(LocalFirestoreHelper.CustomList.class);
assertEquals(FOO_LIST, targetCustomList.fooList);
assertEquals(SINGLE_FIELD_OBJECT, targetCustomList.fooList.get(0));
}
Aggregations