@SuppressWarnings("unchecked") @Test public void getSelectedDocumentsFromMultipleWikis() throws Exception { createDocumentReference("Shape.2D.%", "one", "Shape", "2D", "%"); createDocumentReference("Shape.3D.%", "two", "Shape", "3D", "%"); when(this.request.getParameterValues("pages")).thenReturn(new String[] {"Shape.2D.%", "Shape.3D.%"}); createDocumentReference("Shape.2D.WebHome", "one", "Shape", "2D", "WebHome"); createDocumentReference("Shape.3D.Cube.%", "three", "Shape", "3D", "Cube", "%"); when(this.request.getParameterValues("excludes")) .thenReturn(new String[] {"Shape.2D.WebHome", "Shape.3D.Cube.%25"}); Query queryOne = mock(Query.class, "one"); when(this.queryManager.createQuery("where (doc.fullName like ?1 and doc.fullName not in (?2))", Query.HQL)) .thenReturn(queryOne); when(queryOne.setWiki("one")).thenReturn(queryOne); when(queryOne.bindValues(any(List.class))).thenReturn(queryOne); DocumentReference circleReference = new DocumentReference("one", Arrays.asList("Shape", "2D"), "Circle"); when(queryOne.execute()).thenReturn(Collections.singletonList(circleReference)); Query queryTwo = mock(Query.class, "two"); when(this.queryManager.createQuery("where (doc.fullName like ?1)", Query.HQL)).thenReturn(queryTwo); when(queryTwo.setWiki("two")).thenReturn(queryTwo); when(queryTwo.bindValues(any(List.class))).thenReturn(queryTwo); DocumentReference sphereReference = new DocumentReference("two", Arrays.asList("Shape", "3D"), "Sphere"); when(queryTwo.execute()).thenReturn(Collections.singletonList(sphereReference)); Set<DocumentReference> result = Arrays.asList(sphereReference, circleReference).stream().collect(Collectors.toSet()); assertEquals(result, this.documentSelectionResolver.getSelectedDocuments()); }
public Collection<DocumentReference> getSelectedDocuments() { Map<DocumentReference, Collection<DocumentReference>> selection = getSelectionFromRequest(); EntityTreeFilter filter = getFilterFromRequest(); if (filter != null) { extendSelection(selection, filter); } Set<DocumentReference> selectedDocuments = new LinkedHashSet<>(); selectedDocuments.addAll(selection.keySet().stream().filter(this::isExactMatch).collect(Collectors.toSet())); selection.keySet().removeAll(selectedDocuments); selectedDocuments.addAll(getSelectedDocuments(selection)); return selectedDocuments; }
DocumentSelectionResolver { public Collection<DocumentReference> getSelectedDocuments() { Map<DocumentReference, Collection<DocumentReference>> selection = getSelectionFromRequest(); EntityTreeFilter filter = getFilterFromRequest(); if (filter != null) { extendSelection(selection, filter); } Set<DocumentReference> selectedDocuments = new LinkedHashSet<>(); selectedDocuments.addAll(selection.keySet().stream().filter(this::isExactMatch).collect(Collectors.toSet())); selection.keySet().removeAll(selectedDocuments); selectedDocuments.addAll(getSelectedDocuments(selection)); return selectedDocuments; } }
DocumentSelectionResolver { public Collection<DocumentReference> getSelectedDocuments() { Map<DocumentReference, Collection<DocumentReference>> selection = getSelectionFromRequest(); EntityTreeFilter filter = getFilterFromRequest(); if (filter != null) { extendSelection(selection, filter); } Set<DocumentReference> selectedDocuments = new LinkedHashSet<>(); selectedDocuments.addAll(selection.keySet().stream().filter(this::isExactMatch).collect(Collectors.toSet())); selection.keySet().removeAll(selectedDocuments); selectedDocuments.addAll(getSelectedDocuments(selection)); return selectedDocuments; }  }
DocumentSelectionResolver { public Collection<DocumentReference> getSelectedDocuments() { Map<DocumentReference, Collection<DocumentReference>> selection = getSelectionFromRequest(); EntityTreeFilter filter = getFilterFromRequest(); if (filter != null) { extendSelection(selection, filter); } Set<DocumentReference> selectedDocuments = new LinkedHashSet<>(); selectedDocuments.addAll(selection.keySet().stream().filter(this::isExactMatch).collect(Collectors.toSet())); selection.keySet().removeAll(selectedDocuments); selectedDocuments.addAll(getSelectedDocuments(selection)); return selectedDocuments; }  boolean isSelectionSpecified(); Collection<DocumentReference> getSelectedDocuments(); }
DocumentSelectionResolver { public Collection<DocumentReference> getSelectedDocuments() { Map<DocumentReference, Collection<DocumentReference>> selection = getSelectionFromRequest(); EntityTreeFilter filter = getFilterFromRequest(); if (filter != null) { extendSelection(selection, filter); } Set<DocumentReference> selectedDocuments = new LinkedHashSet<>(); selectedDocuments.addAll(selection.keySet().stream().filter(this::isExactMatch).collect(Collectors.toSet())); selection.keySet().removeAll(selectedDocuments); selectedDocuments.addAll(getSelectedDocuments(selection)); return selectedDocuments; }  boolean isSelectionSpecified(); Collection<DocumentReference> getSelectedDocuments();  }