Search in sources :

Example 1 with FieldValue

use of com.google.cloud.firestore.FieldValue in project java-firestore by googleapis.

the class ITSystemTest method mergeDocumentWithServerTimestamp.

@Test
public void mergeDocumentWithServerTimestamp() throws Exception {
    Map<String, Object> originalMap = LocalFirestoreHelper.map("a", "b");
    Map<String, FieldValue> updateMap = map("c", FieldValue.serverTimestamp());
    randomDoc.set(originalMap).get();
    randomDoc.set(updateMap, SetOptions.merge()).get();
    DocumentSnapshot documentSnapshot = randomDoc.get().get();
    assertEquals("b", documentSnapshot.getString("a"));
    assertNotNull(documentSnapshot.getDate("c"));
}
Also used : QueryDocumentSnapshot(com.google.cloud.firestore.QueryDocumentSnapshot) DocumentSnapshot(com.google.cloud.firestore.DocumentSnapshot) FieldValue(com.google.cloud.firestore.FieldValue) Test(org.junit.Test)

Aggregations

DocumentSnapshot (com.google.cloud.firestore.DocumentSnapshot)1 FieldValue (com.google.cloud.firestore.FieldValue)1 QueryDocumentSnapshot (com.google.cloud.firestore.QueryDocumentSnapshot)1 Test (org.junit.Test)1