@Test public void testUpdatesDocumentsBasedOnQueryWithFilters() { Query query = messageQuery().filter(filter("sort", "<=", 2)); View view = new View(query, DocumentKey.emptyKeySet()); Document doc1 = doc("rooms/eros/messages/1", 0, map("sort", 1)); Document doc2 = doc("rooms/eros/messages/2", 0, map("sort", 3)); Document doc3 = doc("rooms/eros/messages/3", 0, map("sort", 2)); Document doc4 = doc("rooms/eros/messages/4", 0, map()); ViewSnapshot snapshot = applyChanges(view, doc1, doc2, doc3, doc4).getSnapshot(); assertEquals(query, snapshot.getQuery()); assertEquals(asList(doc1, doc3), snapshot.getDocuments().toList()); Document newDoc2 = doc("rooms/eros/messages/2", 1, map("sort", 2)); Document newDoc3 = doc("rooms/eros/messages/3", 1, map("sort", 3)); Document newDoc4 = doc("rooms/eros/messages/4", 1, map("sort", 0)); snapshot = applyChanges(view, newDoc2, newDoc3, newDoc4).getSnapshot(); assertEquals(query, snapshot.getQuery()); assertEquals(asList(newDoc4, doc1, newDoc2), snapshot.getDocuments().toList()); assertEquals( asList( DocumentViewChange.create(Type.REMOVED, doc3), DocumentViewChange.create(Type.ADDED, newDoc4), DocumentViewChange.create(Type.ADDED, newDoc2)), snapshot.getChanges()); assertTrue(snapshot.isFromCache()); assertFalse(snapshot.didSyncStateChange()); }
public ViewChange applyChanges(DocumentChanges docChanges) { return applyChanges(docChanges, null); }
View { public ViewChange applyChanges(DocumentChanges docChanges) { return applyChanges(docChanges, null); } }
View { public ViewChange applyChanges(DocumentChanges docChanges) { return applyChanges(docChanges, null); } View(Query query, ImmutableSortedSet<DocumentKey> remoteDocuments); }
View { public ViewChange applyChanges(DocumentChanges docChanges) { return applyChanges(docChanges, null); } View(Query query, ImmutableSortedSet<DocumentKey> remoteDocuments); SyncState getSyncState(); DocumentChanges computeDocChanges(
      ImmutableSortedMap<DocumentKey, D> docChanges); DocumentChanges computeDocChanges(
      ImmutableSortedMap<DocumentKey, D> docChanges, @Nullable DocumentChanges previousChanges); ViewChange applyChanges(DocumentChanges docChanges); ViewChange applyChanges(DocumentChanges docChanges, TargetChange targetChange); ViewChange applyOnlineStateChange(OnlineState onlineState); }
View { public ViewChange applyChanges(DocumentChanges docChanges) { return applyChanges(docChanges, null); } View(Query query, ImmutableSortedSet<DocumentKey> remoteDocuments); SyncState getSyncState(); DocumentChanges computeDocChanges(
      ImmutableSortedMap<DocumentKey, D> docChanges); DocumentChanges computeDocChanges(
      ImmutableSortedMap<DocumentKey, D> docChanges, @Nullable DocumentChanges previousChanges); ViewChange applyChanges(DocumentChanges docChanges); ViewChange applyChanges(DocumentChanges docChanges, TargetChange targetChange); ViewChange applyOnlineStateChange(OnlineState onlineState);  }