use of com.google.cloud.firestore.DocumentReference in project java-docs-samples by GoogleCloudPlatform.
the class ManageDataSnippetsIT method testUpdateAndCreateIfMissing.
@Test
public void testUpdateAndCreateIfMissing() throws Exception {
manageDataSnippets.updateAndCreateIfMissing();
DocumentReference docRef = db.collection("cities").document("BJ");
assertTrue(getDocumentDataAsCity(docRef).getCapital());
}
use of com.google.cloud.firestore.DocumentReference in project java-docs-samples by GoogleCloudPlatform.
the class ManageDataSnippetsIT method testAddDocWithAutoGenId.
@Test
public void testAddDocWithAutoGenId() throws Exception {
String autoId = manageDataSnippets.addDocumentDataWithAutoGeneratedId();
City city = new City("Tokyo");
city.setCountry("Japan");
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 testAddDataWithDifferentDataTypes.
@Test
public void testAddDataWithDifferentDataTypes() throws Exception {
Map<String, Object> expectedData = manageDataSnippets.addDocumentWithDifferentDataTypes();
DocumentReference docRef = db.collection("data").document("one");
assertEquals(expectedData, getDocumentDataAsMap(docRef));
}
use of com.google.cloud.firestore.DocumentReference in project java-docs-samples by GoogleCloudPlatform.
the class ManageDataSnippetsIT method testUpdateSimpleDocument.
@Test
public void testUpdateSimpleDocument() throws Exception {
manageDataSnippets.updateSimpleDocument();
DocumentReference docRef = db.collection("cities").document("DC");
City city = new City("Washington D.C.");
city.setCapital(true);
assertTrue(Objects.equals(city, getDocumentDataAsCity(docRef)));
}
use of com.google.cloud.firestore.DocumentReference in project java-docs-samples by GoogleCloudPlatform.
the class ManageDataSnippetsIT method testUpdateServerTimestamp.
@Test
public void testUpdateServerTimestamp() throws Exception {
manageDataSnippets.updateServerTimestamp();
DocumentReference docRef = db.collection("objects").document("some-id");
Map<String, Object> data = getDocumentDataAsMap(docRef);
assertTrue(data.get("timestamp") instanceof Date);
}
Aggregations