use of com.google.firebase.firestore.model.mutation.Mutation in project firebase-android-sdk by firebase.
the class SpecTestCase method doFailWrite.
private void doFailWrite(JSONObject writeFailureSpec) throws Exception {
JSONObject errorSpec = writeFailureSpec.getJSONObject("error");
boolean keepInQueue = writeFailureSpec.optBoolean("keepInQueue", false);
int code = errorSpec.getInt("code");
Status error = Status.fromCodeValue(code);
Pair<Mutation, Task<Void>> write = getCurrentOutstandingWrites().get(0);
validateNextWriteSent(write.first);
// If this is a permanent error, the write is not expected to be sent again.
if (!keepInQueue) {
getCurrentOutstandingWrites().remove(0);
}
log(" Failing a write.");
queue.runSync(() -> datastore.failWrite(error));
}
use of com.google.firebase.firestore.model.mutation.Mutation in project firebase-android-sdk by firebase.
the class DocumentOverlayCacheTestCase method testDeleteRepeatedlyWorks.
@Test
public void testDeleteRepeatedlyWorks() {
Mutation m = patchMutation("coll/doc1", map("foo", "bar"));
saveOverlays(2, m);
cache.removeOverlaysForBatchId(2);
assertNull(cache.getOverlay(key("coll/doc1")));
// Repeat
cache.removeOverlaysForBatchId(2);
assertNull(cache.getOverlay(key("coll/doc1")));
}
use of com.google.firebase.firestore.model.mutation.Mutation in project firebase-android-sdk by firebase.
the class DocumentOverlayCacheTestCase method testCanReadSavedOverlay.
@Test
public void testCanReadSavedOverlay() {
Mutation m = patchMutation("coll/doc1", map("foo", "bar"));
saveOverlays(2, m);
assertEquals(m, cache.getOverlay(key("coll/doc1")).getMutation());
}
use of com.google.firebase.firestore.model.mutation.Mutation in project firebase-android-sdk by firebase.
the class DocumentOverlayCacheTestCase method testCanReadSavedOverlaysInBatches.
@Test
public void testCanReadSavedOverlaysInBatches() {
Mutation m1 = setMutation("coll1/a", map("a", 1));
Mutation m2 = setMutation("coll1/b", map("b", 2));
Mutation m3 = setMutation("coll2/c", map("c", 3));
saveOverlays(3, m1, m2, m3);
Map<DocumentKey, Overlay> overlays = cache.getOverlays(new TreeSet<>(Arrays.asList(key("coll1/a"), key("coll1/b"), key("coll2/c"))));
assertEquals(m1, overlays.get(key("coll1/a")).getMutation());
assertEquals(m2, overlays.get(key("coll1/b")).getMutation());
assertEquals(m3, overlays.get(key("coll2/c")).getMutation());
}
use of com.google.firebase.firestore.model.mutation.Mutation in project firebase-android-sdk by firebase.
the class DocumentOverlayCacheTestCase method testSavingOverlayOverwrites.
@Test
public void testSavingOverlayOverwrites() {
Mutation m1 = patchMutation("coll/doc1", map("foo", "bar"));
Mutation m2 = setMutation("coll/doc1", map("foo", "set", "bar", 42));
saveOverlays(2, m1);
saveOverlays(2, m2);
assertEquals(m2, cache.getOverlay(key("coll/doc1")).getMutation());
}
Aggregations