Search in sources :

Example 26 with Value

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());
}
Also used : CommitRequest(com.google.firestore.v1.CommitRequest) HashMap(java.util.HashMap) Value(com.google.firestore.v1.Value) MapValue(com.google.firestore.v1.MapValue) ArrayValue(com.google.firestore.v1.ArrayValue) CommitResponse(com.google.firestore.v1.CommitResponse) Test(org.junit.Test)

Example 27 with Value

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());
}
Also used : RunQueryRequest(com.google.firestore.v1.RunQueryRequest) Value(com.google.firestore.v1.Value) ArrayValue(com.google.firestore.v1.ArrayValue) Test(org.junit.Test)

Example 28 with Value

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());
}
Also used : RunQueryRequest(com.google.firestore.v1.RunQueryRequest) Value(com.google.firestore.v1.Value) ArrayValue(com.google.firestore.v1.ArrayValue) Test(org.junit.Test)

Example 29 with Value

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());
}
Also used : RunQueryRequest(com.google.firestore.v1.RunQueryRequest) Value(com.google.firestore.v1.Value) ArrayValue(com.google.firestore.v1.ArrayValue) Test(org.junit.Test)

Example 30 with Value

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());
}
Also used : RunQueryRequest(com.google.firestore.v1.RunQueryRequest) Value(com.google.firestore.v1.Value) ArrayValue(com.google.firestore.v1.ArrayValue) Test(org.junit.Test)

Aggregations

AdManagerServices (com.google.api.ads.admanager.axis.factory.AdManagerServices)162 ApiError (com.google.api.ads.admanager.axis.v202205.ApiError)162 ApiException (com.google.api.ads.admanager.axis.v202205.ApiException)162 AdManagerSession (com.google.api.ads.admanager.lib.client.AdManagerSession)162 ConfigurationLoadException (com.google.api.ads.common.lib.conf.ConfigurationLoadException)162 OAuthException (com.google.api.ads.common.lib.exception.OAuthException)162 ValidationException (com.google.api.ads.common.lib.exception.ValidationException)162 Credential (com.google.api.client.auth.oauth2.Credential)162 RemoteException (java.rmi.RemoteException)162 Test (org.junit.Test)129 StatementBuilder (com.google.api.ads.admanager.axis.utils.v202205.StatementBuilder)125 Value (com.google.firestore.v1.Value)108 ArrayValue (com.google.firestore.v1.ArrayValue)73 LinkedHashSet (java.util.LinkedHashSet)71 ObjectValue (com.google.firebase.firestore.model.ObjectValue)53 NullValue (com.google.protobuf.NullValue)50 MapValue (com.google.firestore.v1.MapValue)47 ArrayList (java.util.ArrayList)31 HashMap (java.util.HashMap)24 IOException (java.io.IOException)22