Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #4423 - Getter on mutations size #4424

Merged
merged 4 commits into from
Feb 8, 2019
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -664,4 +664,9 @@ public List<WriteResult> apply(CommitResponse commitResponse) {
boolean isEmpty() {
return mutations.isEmpty();
}

/** Get the number of mutations. */
public int getMutationsSize() {
return mutations.size();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,9 @@ public void updateDocument() throws Exception {
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<>();

Expand Down Expand Up @@ -125,7 +127,9 @@ public void setDocument() throws Exception {
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());
Expand All @@ -143,7 +147,9 @@ public void omitWriteResultForDocumentTransforms() throws Exception {
commitCapture.capture(), Matchers.<UnaryCallable<CommitRequest, CommitResponse>>any());

batch.set(documentReference, map("time", FieldValue.serverTimestamp()));


assertEquals(1, batch.getMutationsSize());

List<WriteResult> writeResults = batch.commit().get();
assertEquals(1, writeResults.size());
}
Expand All @@ -158,7 +164,9 @@ public void createDocument() throws Exception {
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<>();

Expand Down Expand Up @@ -187,7 +195,9 @@ public void deleteDocument() throws Exception {
com.google.firestore.v1beta1.Precondition.newBuilder();
precondition.getUpdateTimeBuilder().setSeconds(1).setNanos(2);
writes.add(delete(precondition.build()));


assertEquals(2, batch.getMutationsSize());

List<WriteResult> writeResults = batch.commit().get();

for (int i = 0; i < writeResults.size(); ++i) {
Expand Down