use of com.google.cloud.firestore.DocumentSnapshot in project java-firestore by googleapis.
the class ITSystemTest method getAll.
@Test
public void getAll() throws Exception {
DocumentReference ref1 = randomColl.document("doc1");
DocumentReference ref2 = randomColl.document("doc2");
ApiFutures.allAsList(ImmutableList.of(ref1.set(SINGLE_FIELD_MAP), ref2.set(SINGLE_FIELD_MAP))).get();
List<DocumentSnapshot> documentSnapshots = firestore.getAll(ref1, ref2).get();
assertEquals(2, documentSnapshots.size());
assertEquals("doc1", documentSnapshots.get(0).getId());
assertEquals(SINGLE_FIELD_OBJECT, documentSnapshots.get(0).toObject(SingleField.class));
assertEquals("doc2", documentSnapshots.get(1).getId());
assertEquals(SINGLE_FIELD_OBJECT, documentSnapshots.get(1).toObject(SingleField.class));
}
use of com.google.cloud.firestore.DocumentSnapshot in project java-firestore by googleapis.
the class ITSystemTest method selectQuery.
@Test
public void selectQuery() throws Exception {
addDocument("foo", 1, "bar", 2);
QuerySnapshot querySnapshot = randomColl.select("foo").get().get();
assertEquals(1, querySnapshot.size());
DocumentSnapshot documentSnapshot = querySnapshot.getDocuments().get(0);
assertEquals(1L, documentSnapshot.get("foo"));
assertNull(documentSnapshot.get("bar"));
}
use of com.google.cloud.firestore.DocumentSnapshot in project java-firestore by googleapis.
the class ITSystemTest method getFieldMaskWithDocumentReference.
@Test
public void getFieldMaskWithDocumentReference() throws Exception {
DocumentReference ref = randomColl.document("doc1");
ref.set(ALL_SUPPORTED_TYPES_MAP).get();
DocumentSnapshot documentSnapshots = ref.get(FieldMask.of("foo", "foobar")).get();
assertEquals("bar", documentSnapshots.get("foo"));
assertNull(documentSnapshots.get("foobar"));
}
use of com.google.cloud.firestore.DocumentSnapshot in project java-firestore by googleapis.
the class ITSystemTest method testRecursiveDeleteLeafDocument.
@Test
public void testRecursiveDeleteLeafDocument() throws Exception {
setupRecursiveDeleteTest();
DocumentReference document = randomColl.document("bob/parentsCol/daniel/childCol/ernie");
firestore.recursiveDelete(document).get();
DocumentSnapshot snap = document.get().get();
assertFalse(snap.exists());
assertEquals(5, countCollectionChildren(randomColl));
}
use of com.google.cloud.firestore.DocumentSnapshot in project java-firestore by googleapis.
the class ITSystemTest method fieldDelete.
@Test
public void fieldDelete() throws Exception {
Map<String, Object> fields = new HashMap<>();
fields.put("foo1", "bar1");
fields.put("foo2", "bar2");
randomDoc.set(fields).get();
DocumentSnapshot documentSnapshot = randomDoc.get().get();
assertEquals("bar1", documentSnapshot.getString("foo1"));
assertEquals("bar2", documentSnapshot.getString("foo2"));
randomDoc.update("foo1", "bar3", "foo2", FieldValue.delete()).get();
documentSnapshot = randomDoc.get().get();
assertEquals("bar3", documentSnapshot.getString("foo1"));
assertNull(documentSnapshot.getString("foo2"));
}
Aggregations