use of com.google.cloud.firestore.DocumentReference in project java-docs-samples by GoogleCloudPlatform.
the class ManageDataSnippetsIT method testAddDataAsEntity.
@Test
public void testAddDataAsEntity() throws Exception {
City city = manageDataSnippets.addSimpleDocumentAsEntity();
DocumentReference docRef = db.collection("cities").document("LA");
assertTrue(Objects.equals(city, getDocumentDataAsCity(docRef)));
}
use of com.google.cloud.firestore.DocumentReference in project java-docs-samples by GoogleCloudPlatform.
the class ManageDataSnippetsIT method testUpdateUsingMap.
@Test
public void testUpdateUsingMap() throws Exception {
manageDataSnippets.updateUsingMap();
DocumentReference docRef = db.collection("cities").document("DC");
City city = new City("Washington D.C.");
city.setCapital(true);
city.setCountry("USA");
assertTrue(Objects.equals(city, getDocumentDataAsCity(docRef)));
}
use of com.google.cloud.firestore.DocumentReference in project java-docs-samples by GoogleCloudPlatform.
the class ManageDataSnippetsIT method testAddDocAfterAutoGenId.
@Test
public void testAddDocAfterAutoGenId() throws Exception {
String autoId = manageDataSnippets.addDocumentDataAfterAutoGeneratingId();
City city = new City();
DocumentReference docRef = db.collection("cities").document(autoId);
assertTrue(Objects.equals(city, getDocumentDataAsCity(docRef)));
}
use of com.google.cloud.firestore.DocumentReference in project java-docs-samples by GoogleCloudPlatform.
the class ManageDataSnippetsIT method testUpdateNestedFields.
@Test
public void testUpdateNestedFields() throws Exception {
manageDataSnippets.updateNestedFields();
DocumentReference docRef = db.collection("users").document("frank");
DocumentSnapshot snapshot = getDocumentData(docRef);
assertEquals((long) snapshot.getLong("age"), 13);
assertEquals(snapshot.getString("favorites.color"), "Red");
assertEquals(snapshot.getString("favorites.food"), "Pizza");
}
use of com.google.cloud.firestore.DocumentReference in project java-docs-samples by GoogleCloudPlatform.
the class ManageDataSnippetsIT method testDeleteFields.
@Test
public void testDeleteFields() throws Exception {
manageDataSnippets.deleteFields();
DocumentReference docRef = db.collection("cities").document("BJ");
Map<String, Object> data = getDocumentDataAsMap(docRef);
assertFalse(data.containsKey("capital"));
}
Aggregations