### Question:
DocumentQueryFilter implements QueryFilter { @Override public List filterResults(List results) { for (int i = 0; i < results.size(); i++) { Object result = results.get(i); if (result instanceof String) { results.set(i, this.documentReferenceResolver.resolve((String) result)); } else if (result instanceof Object[]) { Object[] row = (Object[]) result; if (row.length > 0 && row[0] instanceof String) { row[0] = this.documentReferenceResolver.resolve((String) row[0]); } } } return results; }  @Override String filterStatement(String statement, String language); @Override List filterResults(List results);  }### Answer:
@Test public void filterResultsWithOneColumn() { DocumentReference documentReference = new DocumentReference("wiki", Arrays.asList("Path", "To"), "Page"); when(this.resolver.resolve("Path.To.Page")).thenReturn(documentReference); List<Object> results = Arrays.asList("Path.To.Page"); assertEquals(Arrays.asList(documentReference), this.filter.filterResults(results)); }
@Test public void filterResultsWithTwoColumns() { DocumentReference documentReference = new DocumentReference("wiki", Arrays.asList("Path", "To"), "Page"); when(this.resolver.resolve("Path.To.Page")).thenReturn(documentReference); List<Object> results = Arrays.asList((Object) new Object[]{ "Path.To.Page", "red" }); List<Object> filteredResults = this.filter.filterResults(results); assertEquals(1, filteredResults.size()); assertArrayEquals(new Object[]{ documentReference, "red" }, (Object[]) filteredResults.get(0)); }
@Test public void filterResultsWithOneColumnButNotString() { List<Object> results = Collections.singletonList(23); assertSame(results, this.filter.filterResults(results)); }
@Test public void filterResultsWithTwoColumnsButNotString() { List<Object> results = Collections.singletonList(new Object[]{ 23, "Path.To.Page" }); assertSame(results, this.filter.filterResults(results)); }
@Test public void filterResultsEmpty() { List<Object> results = Collections.emptyList(); assertSame(results, this.filter.filterResults(results)); }