use of com.swiftmq.impl.routing.single.smqpr.v400.CommitRequest in project java-firestore by googleapis.
the class WriteBatchTest method setDocumentWithValue.
@Test
public void setDocumentWithValue() throws Exception {
doReturn(commitResponse(4, 0)).when(firestoreMock).sendRequest(commitCapture.capture(), Matchers.<UnaryCallable<CommitRequest, CommitResponse>>any());
batch.set(documentReference, LocalFirestoreHelper.SINGLE_FIELD_PROTO).set(documentReference, LocalFirestoreHelper.SINGLE_FIELD_OBJECT).set(documentReference, LocalFirestoreHelper.SINGLE_FIELD_PROTO, SetOptions.merge()).set(documentReference, LocalFirestoreHelper.SINGLE_FIELD_OBJECT, SetOptions.merge());
List<Write> writes = new ArrayList<>();
writes.add(set(LocalFirestoreHelper.SINGLE_FIELD_PROTO));
writes.add(set(LocalFirestoreHelper.SINGLE_FIELD_PROTO));
writes.add(set(LocalFirestoreHelper.SINGLE_FIELD_PROTO, Arrays.asList("foo")));
writes.add(set(LocalFirestoreHelper.SINGLE_FIELD_PROTO, Arrays.asList("foo")));
assertEquals(4, 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.v400.CommitRequest in project java-firestore by googleapis.
the class WriteBatchTest method createDocumentWithFloat.
@Test
public void createDocumentWithFloat() throws Exception {
doReturn(commitResponse(1, 0)).when(firestoreMock).sendRequest(commitCapture.capture(), Matchers.<UnaryCallable<CommitRequest, CommitResponse>>any());
batch.create(documentReference, LocalFirestoreHelper.SINGLE_FLOAT_MAP);
assertEquals(1, batch.getMutationsSize());
List<WriteResult> writeResults = batch.commit().get();
List<Write> writes = new ArrayList<>();
for (int i = 0; i < writeResults.size(); ++i) {
assertEquals(Timestamp.ofTimeSecondsAndNanos(i, i), writeResults.get(i).getUpdateTime());
writes.add(create(LocalFirestoreHelper.SINGLE_FLOAT_PROTO));
}
CommitRequest commitRequest = commitCapture.getValue();
assertEquals(commit(writes.toArray(new Write[] {})), commitRequest);
}
use of com.swiftmq.impl.routing.single.smqpr.v400.CommitRequest in project java-firestore by googleapis.
the class WriteBatchTest method setDocument.
@Test
public void setDocument() throws Exception {
doReturn(commitResponse(4, 0)).when(firestoreMock).sendRequest(commitCapture.capture(), Matchers.<UnaryCallable<CommitRequest, CommitResponse>>any());
batch.set(documentReference, LocalFirestoreHelper.SINGLE_FIELD_MAP).set(documentReference, LocalFirestoreHelper.SINGLE_FIELD_OBJECT).set(documentReference, LocalFirestoreHelper.SINGLE_FIELD_MAP, SetOptions.merge()).set(documentReference, LocalFirestoreHelper.SINGLE_FIELD_OBJECT, SetOptions.merge());
List<Write> writes = new ArrayList<>();
writes.add(set(LocalFirestoreHelper.SINGLE_FIELD_PROTO));
writes.add(set(LocalFirestoreHelper.SINGLE_FIELD_PROTO));
writes.add(set(LocalFirestoreHelper.SINGLE_FIELD_PROTO, Arrays.asList("foo")));
writes.add(set(LocalFirestoreHelper.SINGLE_FIELD_PROTO, Arrays.asList("foo")));
assertEquals(4, 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.v400.CommitRequest in project java-firestore by googleapis.
the class WriteBatchTest method createDocument.
@Test
public void createDocument() throws Exception {
doReturn(commitResponse(2, 0)).when(firestoreMock).sendRequest(commitCapture.capture(), Matchers.<UnaryCallable<CommitRequest, CommitResponse>>any());
batch.create(documentReference, LocalFirestoreHelper.SINGLE_FIELD_MAP).create(documentReference, LocalFirestoreHelper.SINGLE_FIELD_OBJECT);
assertEquals(2, batch.getMutationsSize());
List<WriteResult> writeResults = batch.commit().get();
List<Write> writes = new ArrayList<>();
for (int i = 0; i < writeResults.size(); ++i) {
assertEquals(Timestamp.ofTimeSecondsAndNanos(i, i), writeResults.get(i).getUpdateTime());
writes.add(create(LocalFirestoreHelper.SINGLE_FIELD_PROTO));
}
CommitRequest commitRequest = commitCapture.getValue();
assertEquals(commit(writes.toArray(new Write[] {})), commitRequest);
}
use of com.swiftmq.impl.routing.single.smqpr.v400.CommitRequest in project java-firestore by googleapis.
the class WriteBatchTest method updateDocument.
@Test
public void updateDocument() throws Exception {
doReturn(commitResponse(4, 0)).when(firestoreMock).sendRequest(commitCapture.capture(), Matchers.<UnaryCallable<CommitRequest, CommitResponse>>any());
List<com.google.firestore.v1.Precondition> preconditions = Arrays.asList(com.google.firestore.v1.Precondition.newBuilder().setExists(true).build(), com.google.firestore.v1.Precondition.newBuilder().setExists(true).build(), com.google.firestore.v1.Precondition.newBuilder().setUpdateTime(com.google.protobuf.Timestamp.getDefaultInstance()).build(), com.google.firestore.v1.Precondition.newBuilder().setUpdateTime(com.google.protobuf.Timestamp.getDefaultInstance()).build());
Precondition updateTime = Precondition.updatedAt(Timestamp.ofTimeSecondsAndNanos(0, 0));
batch.update(documentReference, LocalFirestoreHelper.SINGLE_FIELD_MAP);
batch.update(documentReference, "foo", "bar");
batch.update(documentReference, updateTime, "foo", "bar");
batch.update(documentReference, LocalFirestoreHelper.SINGLE_FIELD_MAP, updateTime);
assertEquals(4, batch.getMutationsSize());
List<WriteResult> writeResults = batch.commit().get();
List<Write> writes = new ArrayList<>();
for (int i = 0; i < writeResults.size(); ++i) {
assertEquals(Timestamp.ofTimeSecondsAndNanos(i, i), writeResults.get(i).getUpdateTime());
writes.add(update(LocalFirestoreHelper.SINGLE_FIELD_PROTO, Collections.singletonList("foo"), preconditions.get(i)));
}
CommitRequest commitRequest = commitCapture.getValue();
assertEquals(commit(writes.toArray(new Write[] {})), commitRequest);
}
Aggregations