Search in sources :

Example 71 with CommitRequest

use of com.swiftmq.impl.routing.single.smqpr.v400.CommitRequest in project java-firestore by googleapis.

the class DocumentReferenceTest method setMultipleFieldsWithMerge.

@Test
public void setMultipleFieldsWithMerge() 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.foo", "second.foo", "second.trueValue")).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().putFields("trueValue", Value.newBuilder().setBooleanValue(true).build());
    nestedUpdate.put("second", nestedProto.build());
    CommitRequest expectedCommit = commit(set(nestedUpdate, Arrays.asList("first.foo", "second.foo", "second.trueValue")));
    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 72 with CommitRequest

use of com.swiftmq.impl.routing.single.smqpr.v400.CommitRequest in project java-firestore by googleapis.

the class DocumentReferenceTest method mergeWithDotsInFieldName.

@Test
public void mergeWithDotsInFieldName() throws Exception {
    doReturn(SINGLE_WRITE_COMMIT_RESPONSE).when(firestoreMock).sendRequest(commitCapture.capture(), Matchers.<UnaryCallable<CommitRequest, CommitResponse>>any());
    documentReference.set(map("a.b.c", map("d.e", "foo", "f.g", "bar")), SetOptions.mergeFieldPaths(Arrays.asList(FieldPath.of("a.b.c", "d.e")))).get();
    Map<String, Value> nestedUpdate = new HashMap<>();
    Value.Builder nestedProto = Value.newBuilder();
    nestedProto.getMapValueBuilder().putFields("d.e", Value.newBuilder().setStringValue("foo").build());
    nestedUpdate.put("a.b.c", nestedProto.build());
    CommitRequest expectedCommit = commit(set(nestedUpdate, Arrays.asList("`a.b.c`.`d.e`")));
    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 73 with CommitRequest

use of com.swiftmq.impl.routing.single.smqpr.v400.CommitRequest in project java-firestore by googleapis.

the class DocumentReferenceTest method serializeBasicTypes.

@Test
public void serializeBasicTypes() throws Exception {
    doReturn(SINGLE_WRITE_COMMIT_RESPONSE).when(firestoreMock).sendRequest(commitCapture.capture(), Matchers.<UnaryCallable<CommitRequest, CommitResponse>>any());
    documentReference.set(ALL_SUPPORTED_TYPES_MAP).get();
    documentReference.set(ALL_SUPPORTED_TYPES_OBJECT).get();
    CommitRequest expectedCommit = commit(set(ALL_SUPPORTED_TYPES_PROTO));
    assertCommitEquals(expectedCommit, commitCapture.getAllValues().get(0));
    assertCommitEquals(expectedCommit, commitCapture.getAllValues().get(1));
}
Also used : CommitRequest(com.google.firestore.v1.CommitRequest) CommitResponse(com.google.firestore.v1.CommitResponse) Test(org.junit.Test)

Example 74 with CommitRequest

use of com.swiftmq.impl.routing.single.smqpr.v400.CommitRequest in project java-firestore by googleapis.

the class DocumentReferenceTest method setDocumentWithMerge.

@Test
public void setDocumentWithMerge() throws Exception {
    doReturn(SINGLE_WRITE_COMMIT_RESPONSE).when(firestoreMock).sendRequest(commitCapture.capture(), Matchers.<UnaryCallable<CommitRequest, CommitResponse>>any());
    documentReference.set(SINGLE_FIELD_MAP, SetOptions.merge()).get();
    documentReference.set(SINGLE_FIELD_OBJECT, SetOptions.merge()).get();
    documentReference.set(ALL_SUPPORTED_TYPES_OBJECT, SetOptions.mergeFields("foo")).get();
    documentReference.set(ALL_SUPPORTED_TYPES_OBJECT, SetOptions.mergeFields(Arrays.asList("foo"))).get();
    documentReference.set(ALL_SUPPORTED_TYPES_OBJECT, SetOptions.mergeFieldPaths(Arrays.asList(FieldPath.of("foo")))).get();
    CommitRequest expectedCommit = commit(set(SINGLE_FIELD_PROTO, Arrays.asList("foo")));
    for (int i = 0; i < 5; ++i) {
        assertCommitEquals(expectedCommit, commitCapture.getAllValues().get(i));
    }
}
Also used : CommitRequest(com.google.firestore.v1.CommitRequest) CommitResponse(com.google.firestore.v1.CommitResponse) Test(org.junit.Test)

Example 75 with CommitRequest

use of com.swiftmq.impl.routing.single.smqpr.v400.CommitRequest in project java-firestore by googleapis.

the class DocumentReferenceTest method updateIndividualPojo.

@Test
public void updateIndividualPojo() throws ExecutionException, InterruptedException {
    doReturn(SINGLE_WRITE_COMMIT_RESPONSE).when(firestoreMock).sendRequest(commitCapture.capture(), Matchers.<UnaryCallable<CommitRequest, CommitResponse>>any());
    documentReference.update(UPDATED_POJO);
    documentReference.update(UPDATED_POJO).get();
    CommitRequest expectedCommit = commit(update(UPDATED_POJO_PROTO, Collections.singletonList("model")));
    for (CommitRequest request : commitCapture.getAllValues()) {
        assertCommitEquals(expectedCommit, request);
    }
}
Also used : CommitRequest(com.google.firestore.v1.CommitRequest) CommitResponse(com.google.firestore.v1.CommitResponse) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)85 CommitRequest (com.google.spanner.v1.CommitRequest)47 CommitRequest (com.google.firestore.v1.CommitRequest)40 CommitResponse (com.google.firestore.v1.CommitResponse)40 ArrayList (java.util.ArrayList)26 Connection (java.sql.Connection)23 ByteString (com.google.protobuf.ByteString)14 ExecuteSqlRequest (com.google.spanner.v1.ExecuteSqlRequest)12 SQLException (java.sql.SQLException)12 Statement (java.sql.Statement)12 CopyManager (org.postgresql.copy.CopyManager)11 BaseConnection (org.postgresql.core.BaseConnection)11 ExecuteBatchDmlRequest (com.google.spanner.v1.ExecuteBatchDmlRequest)10 ArrayValue (com.google.firestore.v1.ArrayValue)9 MapValue (com.google.firestore.v1.MapValue)9 Value (com.google.firestore.v1.Value)9 Write (com.google.firestore.v1.Write)9 StringReader (java.io.StringReader)9 HashMap (java.util.HashMap)9 AbstractMessage (com.google.protobuf.AbstractMessage)8