use of com.swiftmq.impl.routing.single.smqpr.v942.CommitRequest in project grpc-gcp-java by GoogleCloudPlatform.
the class Commit method commitCall.
public void commitCall() {
System.out.println("\n:: Committing Transaction ::\n");
if (Main.transactionId == null) {
System.out.println("WARNING: No current transaction open, run BeginTransaction first...");
return;
} else {
System.out.println("Found Transaction ID '" + Main.transactionId.toString() + "'. Committing....");
}
FirestoreBlockingStub blockingStub = new GRPCFirebaseClientFactory().createFirebaseClient().getBlockingStub();
CommitRequest commitRequest = CommitRequest.newBuilder().setTransaction(Main.transactionId).setDatabase("projects/firestoretestclient/databases/(default)").build();
try {
blockingStub.commit(commitRequest);
} catch (Exception e) {
System.out.println("Error during call: " + e.getMessage() + e.getCause());
return;
}
System.out.println("Success!");
Menu menu = new Menu();
menu.draw();
}
use of com.swiftmq.impl.routing.single.smqpr.v942.CommitRequest in project java-firestore by googleapis.
the class FirestoreTest method arrayRemoveWithPojo.
@Test
public void arrayRemoveWithPojo() throws ExecutionException, InterruptedException {
doReturn(commitResponse(1, 0)).when(firestoreMock).sendRequest(commitCapture.capture(), Matchers.<UnaryCallable<CommitRequest, CommitResponse>>any());
DocumentReference doc = firestoreMock.document("coll/doc");
doc.update("array", FieldValue.arrayRemove(SINGLE_FIELD_OBJECT)).get();
CommitRequest expectedRequest = commit(update(Collections.emptyMap(), new ArrayList<>()), transform("array", arrayRemove(SINGLE_FIELD_VALUE)));
CommitRequest actualRequest = commitCapture.getValue();
assertEquals(expectedRequest, actualRequest);
}
use of com.swiftmq.impl.routing.single.smqpr.v942.CommitRequest in project java-firestore by googleapis.
the class WriteBatchTest method setDocumentWithFloat.
@Test
public void setDocumentWithFloat() throws Exception {
doReturn(commitResponse(1, 0)).when(firestoreMock).sendRequest(commitCapture.capture(), Matchers.<UnaryCallable<CommitRequest, CommitResponse>>any());
batch.set(documentReference, LocalFirestoreHelper.SINGLE_FLOAT_MAP);
List<Write> writes = new ArrayList<>();
writes.add(set(LocalFirestoreHelper.SINGLE_FLOAT_PROTO));
assertEquals(1, batch.getMutationsSize());
List<WriteResult> writeResults = batch.commit().get();
for (int i = 0; i < writeResults.size(); ++i) {
assertEquals(Timestamp.ofTimeSecondsAndNanos(i, i), writeResults.get(i).getUpdateTime());
}
CommitRequest commitRequest = commitCapture.getValue();
assertEquals(commit(writes.toArray(new Write[] {})), commitRequest);
}
use of com.swiftmq.impl.routing.single.smqpr.v942.CommitRequest in project java-firestore by googleapis.
the class DocumentReferenceTest method updateNestedDocument.
@Test
public void updateNestedDocument() throws Exception {
doReturn(SINGLE_WRITE_COMMIT_RESPONSE).when(firestoreMock).sendRequest(commitCapture.capture(), Matchers.<UnaryCallable<CommitRequest, CommitResponse>>any());
Map<String, Object> nestedObject = new HashMap<>();
nestedObject.put("a", "b");
nestedObject.put("c.d", "e");
nestedObject.put("f.g.h", "i");
Map<String, Value> expandedObject = new HashMap<>();
expandedObject.put("a", string("b"));
expandedObject.put("c", object("d", string("e")));
expandedObject.put("f", object("g", object("h", string("i"))));
documentReference.update(nestedObject).get();
CommitRequest expectedCommit = commit(update(expandedObject, new ArrayList<>(nestedObject.keySet())));
assertCommitEquals(expectedCommit, commitCapture.getValue());
}
use of com.swiftmq.impl.routing.single.smqpr.v942.CommitRequest in project java-firestore by googleapis.
the class DocumentReferenceTest method updateDocumentWithPreconditions.
@Test
public void updateDocumentWithPreconditions() throws Exception {
doReturn(SINGLE_WRITE_COMMIT_RESPONSE).when(firestoreMock).sendRequest(commitCapture.capture(), Matchers.<UnaryCallable<CommitRequest, CommitResponse>>any());
Precondition options = Precondition.updatedAt(Timestamp.ofTimeSecondsAndNanos(479978400, 123000000));
documentReference.update(SINGLE_FIELD_MAP, options).get();
documentReference.update(options, "foo", "bar").get();
com.google.firestore.v1.Precondition.Builder precondition = com.google.firestore.v1.Precondition.newBuilder();
precondition.getUpdateTimeBuilder().setSeconds(479978400).setNanos(123000000);
CommitRequest expectedCommit = commit(update(SINGLE_FIELD_PROTO, Collections.singletonList("foo"), precondition.build()));
for (CommitRequest request : commitCapture.getAllValues()) {
assertCommitEquals(expectedCommit, request);
}
}
Aggregations