### Question:
IndexedQueryEngine implements QueryEngine { @Override public ImmutableSortedMap<DocumentKey, Document> getDocumentsMatchingQuery( Query query, SnapshotVersion lastLimboFreeSnapshotVersion, ImmutableSortedSet<DocumentKey> remoteKeys) { hardAssert(localDocuments != null, "setLocalDocumentsView() not called"); return query.isDocumentQuery() ? localDocuments.getDocumentsMatchingQuery(query, SnapshotVersion.NONE) : performCollectionQuery(query); } IndexedQueryEngine(SQLiteCollectionIndex collectionIndex); @Override void setLocalDocumentsView(LocalDocumentsView localDocuments); @Override ImmutableSortedMap<DocumentKey, Document> getDocumentsMatchingQuery(
      Query query,
      SnapshotVersion lastLimboFreeSnapshotVersion,
      ImmutableSortedSet<DocumentKey> remoteKeys); @Override void handleDocumentChange(MaybeDocument oldDocument, MaybeDocument newDocument);  }### Answer:
@Test @Ignore("Pending cr/164068667") public void addDocumentQuery() { addDocument(IGNORED_DOC); addDocument(MATCHING_DOC); Query query = query("coll").filter(filter("a", "==", "a")); ImmutableSortedMap<DocumentKey, Document> results = queryEngine.getDocumentsMatchingQuery( query, null, DocumentKey.emptyKeySet()); assertThat(results).doesNotContain(IGNORED_DOC.getKey()); assertThat(results).contains(MATCHING_DOC.getKey()); }
@Test @Ignore("Pending cr/164068667") public void updateDocumentQuery() { addDocument(IGNORED_DOC); addDocument(NON_MATCHING_DOC); updateDocument(NON_MATCHING_DOC, MATCHING_DOC); Query query = query("coll").filter(filter("a", "==", "a")); ImmutableSortedMap<DocumentKey, Document> results = queryEngine.getDocumentsMatchingQuery( query, null, DocumentKey.emptyKeySet()); assertThat(results).doesNotContain(IGNORED_DOC.getKey()); assertThat(results).contains(MATCHING_DOC.getKey()); }
@Test @Ignore("Pending cr/164068667") public void removeDocumentQuery() { addDocument(IGNORED_DOC); addDocument(MATCHING_DOC); removeDocument(MATCHING_DOC); Query query = query("coll").filter(filter("a", "==", "a")); ImmutableSortedMap<DocumentKey, Document> results = queryEngine.getDocumentsMatchingQuery( query, null, DocumentKey.emptyKeySet()); assertThat(results).doesNotContain(IGNORED_DOC.getKey()); assertThat(results).doesNotContain(MATCHING_DOC.getKey()); }
@Test @Ignore("Pending cr/164068667") public void nestedQuery() { Document nonMatchingDoc = doc("coll/a", ORIGINAL_VERSION, map("a", map("a", "b"))); Document matchingDoc = doc("coll/a", UPDATED_VERSION, map("a", map("a", "a"))); Document ignoredDoc = doc("coll/b", ORIGINAL_VERSION, map("a", map("a", "b"))); addDocument(nonMatchingDoc); addDocument(ignoredDoc); updateDocument(nonMatchingDoc, matchingDoc); Query query = query("coll").filter(filter("a.a", "==", "a")); ImmutableSortedMap<DocumentKey, Document> results = queryEngine.getDocumentsMatchingQuery( query, null, DocumentKey.emptyKeySet()); assertThat(results).doesNotContain(ignoredDoc.getKey()); assertThat(results).contains(matchingDoc.getKey()); }
@Test @Ignore("Pending cr/164068667") public void orderByQuery() { addDocument(IGNORED_DOC); addDocument(MATCHING_DOC); Query query = query("coll").orderBy(TestUtil.orderBy("a")); ImmutableSortedMap<DocumentKey, Document> results = queryEngine.getDocumentsMatchingQuery( query, null, DocumentKey.emptyKeySet()); assertThat(results).doesNotContain(IGNORED_DOC.getKey()); assertThat(results).contains(MATCHING_DOC.getKey()); }