@Test public void filterResultsArray() throws Exception { List<?> filteredResults = this.mocker.getComponentUnderTest() .filterResults(Arrays.asList(new Object[] {"alice", 13}, new Object[] {"bob", 7})); assertEquals(1, filteredResults.size()); Object[] result = (Object[]) filteredResults.get(0); assertEquals(1, result.length); assertEquals(7, result[0]); }
@Override public List filterResults(List results) { List<Object> filteredResults = new LinkedList<>(); for (Object result : results) { if (result instanceof String) { DocumentReference documentReference = this.documentReferenceResolver.resolve((String) result); if (this.authorization.hasAccess(Right.VIEW, documentReference)) { filteredResults.add(result); } } else if (result instanceof Object[]) { Object[] row = (Object[]) result; if (row.length > 0 && row[0] instanceof String) { DocumentReference documentReference = this.documentReferenceResolver.resolve((String) row[0]); if (this.authorization.hasAccess(Right.VIEW, documentReference)) { filteredResults.add(row.length > 1 ? Arrays.copyOfRange(row, 1, row.length) : row); } } } } return filteredResults; }
ViewableAllowedDBListValueFilter implements QueryFilter { @Override public List filterResults(List results) { List<Object> filteredResults = new LinkedList<>(); for (Object result : results) { if (result instanceof String) { DocumentReference documentReference = this.documentReferenceResolver.resolve((String) result); if (this.authorization.hasAccess(Right.VIEW, documentReference)) { filteredResults.add(result); } } else if (result instanceof Object[]) { Object[] row = (Object[]) result; if (row.length > 0 && row[0] instanceof String) { DocumentReference documentReference = this.documentReferenceResolver.resolve((String) row[0]); if (this.authorization.hasAccess(Right.VIEW, documentReference)) { filteredResults.add(row.length > 1 ? Arrays.copyOfRange(row, 1, row.length) : row); } } } } return filteredResults; } }
ViewableAllowedDBListValueFilter implements QueryFilter { @Override public List filterResults(List results) { List<Object> filteredResults = new LinkedList<>(); for (Object result : results) { if (result instanceof String) { DocumentReference documentReference = this.documentReferenceResolver.resolve((String) result); if (this.authorization.hasAccess(Right.VIEW, documentReference)) { filteredResults.add(result); } } else if (result instanceof Object[]) { Object[] row = (Object[]) result; if (row.length > 0 && row[0] instanceof String) { DocumentReference documentReference = this.documentReferenceResolver.resolve((String) row[0]); if (this.authorization.hasAccess(Right.VIEW, documentReference)) { filteredResults.add(row.length > 1 ? Arrays.copyOfRange(row, 1, row.length) : row); } } } } return filteredResults; }  }
ViewableAllowedDBListValueFilter implements QueryFilter { @Override public List filterResults(List results) { List<Object> filteredResults = new LinkedList<>(); for (Object result : results) { if (result instanceof String) { DocumentReference documentReference = this.documentReferenceResolver.resolve((String) result); if (this.authorization.hasAccess(Right.VIEW, documentReference)) { filteredResults.add(result); } } else if (result instanceof Object[]) { Object[] row = (Object[]) result; if (row.length > 0 && row[0] instanceof String) { DocumentReference documentReference = this.documentReferenceResolver.resolve((String) row[0]); if (this.authorization.hasAccess(Right.VIEW, documentReference)) { filteredResults.add(row.length > 1 ? Arrays.copyOfRange(row, 1, row.length) : row); } } } } return filteredResults; }  @Override String filterStatement(String statement, String language); @Override List filterResults(List results); }
ViewableAllowedDBListValueFilter implements QueryFilter { @Override public List filterResults(List results) { List<Object> filteredResults = new LinkedList<>(); for (Object result : results) { if (result instanceof String) { DocumentReference documentReference = this.documentReferenceResolver.resolve((String) result); if (this.authorization.hasAccess(Right.VIEW, documentReference)) { filteredResults.add(result); } } else if (result instanceof Object[]) { Object[] row = (Object[]) result; if (row.length > 0 && row[0] instanceof String) { DocumentReference documentReference = this.documentReferenceResolver.resolve((String) row[0]); if (this.authorization.hasAccess(Right.VIEW, documentReference)) { filteredResults.add(row.length > 1 ? Arrays.copyOfRange(row, 1, row.length) : row); } } } } return filteredResults; }  @Override String filterStatement(String statement, String language); @Override List filterResults(List results);  }