@Test public void getChildCount() throws Exception { this.documentTreeNode.getProperties().put("exclusions", new HashSet<>(Arrays.asList("document:wiki:Path.To.Page.Alice", "document:wiki:Path.To.Page.Bob.WebHome"))); DocumentReference alice = new DocumentReference("Alice", this.documentReference.getLastSpaceReference()); when(this.entityTreeNodeIdConverter.convert(EntityReference.class, "document:wiki:Path.To.Page.Alice")) .thenReturn(alice); when(this.localEntityReferenceSerializer.serialize(alice)).thenReturn("Path.To.Page.Alice"); DocumentReference bob = new DocumentReference("wiki", Arrays.asList("Path", "To", "Page", "Bob"), "WebHome"); when(this.entityTreeNodeIdConverter.convert(EntityReference.class, "document:wiki:Path.To.Page.Bob.WebHome")) .thenReturn(bob); when(this.localEntityReferenceSerializer.serialize(bob.getParent())).thenReturn("Path.To.Page.Bob"); Query childSpacesQuery = mock(Query.class, "childSpaces"); when(this.queryManager.createQuery( "select count(*) from XWikiSpace where parent = :parent " + "and reference not in (:excludedSpaces)", Query.HQL)).thenReturn(childSpacesQuery); when(childSpacesQuery.execute()).thenReturn(Collections.singletonList(2L)); Query childTerminalPagesQuery = mock(Query.class, "childTerminalPages"); when(this.queryManager.createQuery("where doc.translation = 0 and doc.space = :space and " + "doc.name <> :defaultDocName and doc.fullName not in (:excludedDocuments)", Query.HQL)) .thenReturn(childTerminalPagesQuery); when(childTerminalPagesQuery.execute()).thenReturn(Collections.singletonList(3L)); assertEquals(5L, this.documentTreeNode.getChildCount("document:wiki:Path.To.Page.WebHome")); verify(childSpacesQuery).setWiki("wiki"); verify(childSpacesQuery).bindValue("parent", "Path.To.Page"); verify(childSpacesQuery).bindValue("excludedSpaces", Collections.singleton("Path.To.Page.Bob")); verify(childTerminalPagesQuery).setWiki("wiki"); verify(childTerminalPagesQuery).bindValue("space", "Path.To.Page"); verify(childTerminalPagesQuery).bindValue("defaultDocName", "WebHome"); verify(childTerminalPagesQuery).bindValue("excludedDocuments", Collections.singleton("Path.To.Page.Alice")); this.documentTreeNode.getProperties().put("showTerminalDocuments", false); assertEquals(2L, this.documentTreeNode.getChildCount("document:wiki:Path.To.Page.WebHome")); }
@Override protected int getChildCount(DocumentReference documentReference) throws Exception { return getPseudoChildCount(documentReference) + getChildDocumentsCount(documentReference); }
DocumentTreeNode extends AbstractDocumentTreeNode implements Initializable { @Override protected int getChildCount(DocumentReference documentReference) throws Exception { return getPseudoChildCount(documentReference) + getChildDocumentsCount(documentReference); } }
DocumentTreeNode extends AbstractDocumentTreeNode implements Initializable { @Override protected int getChildCount(DocumentReference documentReference) throws Exception { return getPseudoChildCount(documentReference) + getChildDocumentsCount(documentReference); } DocumentTreeNode(); }
DocumentTreeNode extends AbstractDocumentTreeNode implements Initializable { @Override protected int getChildCount(DocumentReference documentReference) throws Exception { return getPseudoChildCount(documentReference) + getChildDocumentsCount(documentReference); } DocumentTreeNode(); @Override void initialize(); }
DocumentTreeNode extends AbstractDocumentTreeNode implements Initializable { @Override protected int getChildCount(DocumentReference documentReference) throws Exception { return getPseudoChildCount(documentReference) + getChildDocumentsCount(documentReference); } DocumentTreeNode(); @Override void initialize();  }