use of com.google.api.ads.admanager.axis.v202205.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.api.ads.admanager.axis.v202205.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.api.ads.admanager.axis.v202205.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.api.ads.admanager.axis.v202205.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());
}
use of com.google.api.ads.admanager.axis.v202205.Value in project java-firestore by googleapis.
the class QueryTest method inQueriesFieldsNotUsedInOrderBy.
@Test
public void inQueriesFieldsNotUsedInOrderBy() throws Exception {
doAnswer(queryResponse()).when(firestoreMock).streamRequest(runQuery.capture(), streamObserverCapture.capture(), Matchers.<ServerStreamingCallable>any());
// Field "foo" used in `whereIn` should not appear in implicit orderBys in the resulting query.
query.whereIn(FieldPath.of("foo"), Arrays.<Object>asList("value1", "value2")).startAt(SINGLE_FIELD_SNAPSHOT).get().get();
Value value = Value.newBuilder().setArrayValue(ArrayValue.newBuilder().addValues(Value.newBuilder().setStringValue("value1").build()).addValues(Value.newBuilder().setStringValue("value2").build()).build()).build();
RunQueryRequest expectedRequest = query(filter(Operator.IN, "foo", value), order("__name__", Direction.ASCENDING), startAt(reference(DOCUMENT_NAME), true));
assertEquals(expectedRequest, runQuery.getValue());
}
Aggregations