### Question:
ViewableQueryFilter implements QueryFilter { @Override public List filterResults(List results) { List<Object> filteredResults = new LinkedList<>(); for (Object result : results) { EntityReference entityReference = null; if (result instanceof EntityReference) { entityReference = (EntityReference) result; } else if (result instanceof Object[] && ((Object[]) result)[0] instanceof EntityReference) { entityReference = (EntityReference) ((Object[]) result)[0]; } if (entityReference != null && this.authorization.hasAccess(Right.VIEW, entityReference)) { filteredResults.add(result); } } return filteredResults; }  @Override String filterStatement(String statement, String language); @Override List filterResults(List results);  }### Answer:
@Test public void filterResultsEmpty() { List<Object> results = Collections.emptyList(); assertEquals(results, this.filter.filterResults(results)); }
@Test public void filterResultsWithOneEntityReferenceColumn() { List<Object> results = Arrays.asList(this.unauthorized, this.authorized); assertEquals(Arrays.asList(this.authorized), this.filter.filterResults(results)); }
@Test public void filterResultsWithTwoColumnsAndEntityReference() { List<Object> results = Arrays.asList(new Object[]{ this.unauthorized, 23 }, new Object[]{ this.authorized, 17 }); List<Object> filteredResults = this.filter.filterResults(results); assertEquals(1, filteredResults.size()); assertArrayEquals(new Object[]{ this.authorized, 17 }, (Object[]) filteredResults.get(0)); }
@Test public void filterResultsWithOneColumnNotEntityReference() { List<Object> results = Collections.singletonList("Path.To.Page"); assertEquals(Collections.emptyList(), this.filter.filterResults(results)); }
@Test public void filterResultsWithTwoColumnsNotEntityReference() { List<Object> results = Collections.singletonList(new Object[]{ 17, this.authorized }); assertEquals(Collections.emptyList(), this.filter.filterResults(results)); }