use of com.google.firestore.v1beta1.Value in project java-firestore by googleapis.
the class DocumentReferenceTest method updateWithDotsInFieldName.
@Test
public void updateWithDotsInFieldName() throws Exception {
doReturn(SINGLE_WRITE_COMMIT_RESPONSE).when(firestoreMock).sendRequest(commitCapture.capture(), Matchers.<UnaryCallable<CommitRequest, CommitResponse>>any());
documentReference.update(map("a.b.c", map("d.e", "foo"))).get();
Map<String, Value> nestedUpdate = new HashMap<>();
Value.Builder valueProto = Value.newBuilder();
valueProto.getMapValueBuilder().putFields("d.e", Value.newBuilder().setStringValue("foo").build());
Value.Builder cProto = Value.newBuilder();
cProto.getMapValueBuilder().putFields("c", valueProto.build());
Value.Builder bProto = Value.newBuilder();
bProto.getMapValueBuilder().putFields("b", cProto.build());
nestedUpdate.put("a", bProto.build());
CommitRequest expectedCommit = commit(update(nestedUpdate, Arrays.asList("a.b.c")));
assertCommitEquals(expectedCommit, commitCapture.getValue());
}
use of com.google.firestore.v1beta1.Value in project java-firestore by googleapis.
the class DocumentReferenceTest method setNestedMapWithMerge.
@Test
public void setNestedMapWithMerge() throws Exception {
doReturn(SINGLE_WRITE_COMMIT_RESPONSE).when(firestoreMock).sendRequest(commitCapture.capture(), Matchers.<UnaryCallable<CommitRequest, CommitResponse>>any());
documentReference.set(NESTED_CLASS_OBJECT, SetOptions.mergeFields("first", "second")).get();
Map<String, Value> nestedUpdate = new HashMap<>();
Value.Builder nestedProto = Value.newBuilder();
nestedProto.getMapValueBuilder().putAllFields(SINGLE_FIELD_PROTO);
nestedUpdate.put("first", nestedProto.build());
nestedProto.getMapValueBuilder().putAllFields(ALL_SUPPORTED_TYPES_PROTO);
nestedUpdate.put("second", nestedProto.build());
CommitRequest expectedCommit = commit(set(nestedUpdate, Arrays.asList("first", "second")));
assertCommitEquals(expectedCommit, commitCapture.getValue());
}
use of com.google.firestore.v1beta1.Value in project java-firestore by googleapis.
the class QueryTest method withDocumentSnapshotCursor.
@Test
public void withDocumentSnapshotCursor() {
doAnswer(queryResponse()).when(firestoreMock).streamRequest(runQuery.capture(), streamObserverCapture.capture(), Matchers.<ServerStreamingCallable>any());
query.startAt(SINGLE_FIELD_SNAPSHOT).get();
Value documentBoundary = reference(DOCUMENT_NAME);
RunQueryRequest queryRequest = query(order("__name__", StructuredQuery.Direction.ASCENDING), startAt(documentBoundary, true));
assertEquals(queryRequest, runQuery.getValue());
}
use of com.google.firestore.v1beta1.Value in project java-firestore by googleapis.
the class QueryTest method notInQueriesWithReferenceArray.
@Test
public void notInQueriesWithReferenceArray() throws Exception {
doAnswer(queryResponse()).when(firestoreMock).streamRequest(runQuery.capture(), streamObserverCapture.capture(), Matchers.<ServerStreamingCallable>any());
query.whereNotIn(FieldPath.documentId(), Arrays.asList("doc", firestoreMock.document("coll/doc"))).get().get();
Value value = Value.newBuilder().setArrayValue(ArrayValue.newBuilder().addValues(reference(DOCUMENT_NAME)).addValues(reference(DOCUMENT_NAME)).build()).build();
RunQueryRequest expectedRequest = query(filter(Operator.NOT_IN, "__name__", value));
assertEquals(expectedRequest, runQuery.getValue());
}
use of com.google.firestore.v1beta1.Value in project java-firestore by googleapis.
the class QueryTest method withDocumentReferenceCursor.
@Test
public void withDocumentReferenceCursor() {
doAnswer(queryResponse()).when(firestoreMock).streamRequest(runQuery.capture(), streamObserverCapture.capture(), Matchers.<ServerStreamingCallable>any());
DocumentReference documentCursor = firestoreMock.document(DOCUMENT_PATH);
Value documentValue = reference(DOCUMENT_NAME);
query.startAt(documentCursor).get();
RunQueryRequest queryRequest = query(order("__name__", StructuredQuery.Direction.ASCENDING), startAt(documentValue, true));
assertEquals(queryRequest, runQuery.getValue());
}
Aggregations