use of com.google.cloud.firestore.CollectionReference in project java-firestore by googleapis.
the class RetrieveDataSnippetsIT method testGetSubcollections.
@Test
public void testGetSubcollections() throws Exception {
// Add a landmark subcollection
Map<String, String> data = new HashMap<>();
data.put("foo", "bar");
db.document("cities/SF/landmarks/example").set(data).get();
Iterable<CollectionReference> collections = retrieveDataSnippets.listCollections();
List<CollectionReference> collectionList = new ArrayList<>();
for (CollectionReference collRef : collections) {
collectionList.add(collRef);
}
assertEquals(collectionList.size(), 1);
assertEquals(collectionList.get(0).getId(), "landmarks");
}
use of com.google.cloud.firestore.CollectionReference in project java-firestore by googleapis.
the class ManageDataSnippetsIT method testWriteBatchIsSuccessful.
@Test
public void testWriteBatchIsSuccessful() throws Exception {
manageDataSnippets.writeBatch();
CollectionReference collection = db.collection("cities");
ApiFuture<DocumentSnapshot> document = collection.document("NYC").get();
assertTrue(document.get().exists());
DocumentReference documentReference = collection.document("SF");
Map<String, Object> data = getDocumentDataAsMap(documentReference);
assertTrue(data.containsKey("population"));
document = collection.document("LA").get();
assertFalse(document.get().exists());
}
Aggregations