use of com.google.cloud.firestore.DocumentSnapshot in project java-firestore by googleapis.
the class ITSystemTest method nestedQuery.
@Test
public void nestedQuery() throws Exception {
randomColl = randomColl.document("foo").collection("bar");
addDocument("foo", "bar");
QuerySnapshot querySnapshot = randomColl.get().get();
DocumentSnapshot documentSnapshot = querySnapshot.getDocuments().get(0);
assertTrue(documentSnapshot.getReference().getPath().contains("/foo/bar"));
}
use of com.google.cloud.firestore.DocumentSnapshot in project java-firestore by googleapis.
the class ITSystemTest method createDocumentWithFloat.
@Test
public void createDocumentWithFloat() throws Exception {
assertEquals(20, randomDoc.getId().length());
randomDoc.create(LocalFirestoreHelper.SINGLE_FLOAT_PROTO).get();
DocumentSnapshot documentSnapshot = randomDoc.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 readOnlyTransaction_successfulGet.
@Test
public void readOnlyTransaction_successfulGet() throws ExecutionException, InterruptedException, TimeoutException {
final DocumentReference documentReference = randomColl.add(SINGLE_FIELD_MAP).get();
final AtomicReference<DocumentSnapshot> ref = new AtomicReference<>();
final ApiFuture<Void> runTransaction = firestore.runTransaction(transaction -> {
final DocumentSnapshot snapshot = transaction.get(documentReference).get(5, TimeUnit.SECONDS);
ref.compareAndSet(null, snapshot);
return null;
}, TransactionOptions.createReadOnlyOptionsBuilder().build());
runTransaction.get(10, TimeUnit.SECONDS);
assertEquals("bar", ref.get().get("foo"));
}
use of com.google.cloud.firestore.DocumentSnapshot in project java-firestore by googleapis.
the class ITSystemTest method deserializeCustomMap.
@Test
public void deserializeCustomMap() throws Exception {
LocalFirestoreHelper.CustomMap customMap = new LocalFirestoreHelper.CustomMap();
customMap.fooMap = FOO_MAP;
DocumentReference documentReference = randomColl.document("doc1");
documentReference.set(customMap).get();
DocumentSnapshot documentSnapshots = documentReference.get().get();
LocalFirestoreHelper.CustomMap targetCustomMap = documentSnapshots.toObject(LocalFirestoreHelper.CustomMap.class);
assertEquals(FOO_MAP, targetCustomMap.fooMap);
assertEquals(SINGLE_FIELD_OBJECT, targetCustomMap.fooMap.get("customMap"));
}
use of com.google.cloud.firestore.DocumentSnapshot in project java-firestore by googleapis.
the class ITSystemTest method getAllWithFieldMask.
@Test
public void getAllWithFieldMask() throws Exception {
DocumentReference ref = randomColl.document("doc1");
ref.set(ALL_SUPPORTED_TYPES_MAP).get();
List<DocumentSnapshot> documentSnapshots = firestore.getAll(new DocumentReference[] { ref }, FieldMask.of("foo")).get();
assertEquals(map("foo", "bar"), documentSnapshots.get(0).getData());
}
Aggregations