use of com.google.firestore.v1beta1.BeginTransactionResponse in project spring-cloud-gcp by GoogleCloudPlatform.
the class ReactiveFirestoreTransactionManager method startTransaction.
private Mono<ReactiveFirestoreResourceHolder> startTransaction(TransactionDefinition definition) {
TransactionOptions.Builder txOptions = definition.isReadOnly() ? TransactionOptions.newBuilder().setReadOnly(TransactionOptions.ReadOnly.newBuilder().build()) : TransactionOptions.newBuilder().setReadWrite(TransactionOptions.ReadWrite.newBuilder().build());
BeginTransactionRequest beginTransactionRequest = BeginTransactionRequest.newBuilder().setOptions(txOptions).setDatabase(this.databasePath).build();
return ObservableReactiveUtil.<BeginTransactionResponse>unaryCall(obs -> this.firestore.beginTransaction(beginTransactionRequest, obs)).map(beginTransactionResponse -> new ReactiveFirestoreResourceHolder(beginTransactionResponse.getTransaction()));
}
use of com.google.firestore.v1beta1.BeginTransactionResponse in project java-datastore by googleapis.
the class RemoteRpcTest method testGzip.
@Test
public void testGzip() throws IOException, DatastoreException {
BeginTransactionResponse response = newBeginTransactionResponse();
InjectedTestValues injectedTestValues = new InjectedTestValues(gzip(response), new byte[1], true);
RemoteRpc rpc = newRemoteRpc(injectedTestValues);
InputStream is = rpc.call("beginTransaction", BeginTransactionResponse.getDefaultInstance());
BeginTransactionResponse parsedResponse = BeginTransactionResponse.parseFrom(is);
is.close();
assertEquals(response, parsedResponse);
// Check that the underlying stream is exhausted.
assertEquals(-1, injectedTestValues.inputStream.read());
}
use of com.google.firestore.v1beta1.BeginTransactionResponse in project java-firestore by googleapis.
the class FirestoreClientTest method beginTransactionTest.
@Test
public void beginTransactionTest() throws Exception {
BeginTransactionResponse expectedResponse = BeginTransactionResponse.newBuilder().setTransaction(ByteString.EMPTY).build();
mockFirestore.addResponse(expectedResponse);
String database = "database1789464955";
BeginTransactionResponse actualResponse = client.beginTransaction(database);
Assert.assertEquals(expectedResponse, actualResponse);
List<AbstractMessage> actualRequests = mockFirestore.getRequests();
Assert.assertEquals(1, actualRequests.size());
BeginTransactionRequest actualRequest = ((BeginTransactionRequest) actualRequests.get(0));
Assert.assertEquals(database, actualRequest.getDatabase());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Aggregations