@Test public void getChildren() throws Exception { this.wikiTreeNode.getProperties().put("filterHiddenDocuments", true); UserProperties userProperties = mock(UserProperties.class); when(userProperties.displayHiddenDocuments()).thenReturn(false); when(this.userPropertiesResolver.resolve(CurrentUserReference.INSTANCE)).thenReturn(userProperties); String statement = "select reference, 0 as terminal from XWikiSpace page order by lower(name), name"; when(this.queryManager.createQuery(statement, Query.HQL)).thenReturn(this.query); when(query.execute()).thenReturn(Collections.singletonList(new DocumentReference("foo", "C", "WebHome"))); assertEquals(Collections.singletonList("document:foo:C.WebHome"), this.wikiTreeNode.getChildren("wiki:foo", 5, 10)); verify(this.query).setWiki("foo"); verify(this.query).setOffset(5); verify(this.query).setLimit(10); verify(this.query).addFilter(this.topLevelPageFilter); verify(this.query).addFilter(this.hiddenPageFilter); }
@Override public List<String> getChildren(String nodeId, int offset, int limit) { EntityReference wikiReference = resolve(nodeId); if (wikiReference != null && wikiReference.getType() == EntityType.WIKI) { try { return serialize(getChildren(new WikiReference(wikiReference), offset, limit)); } catch (QueryException e) { this.logger.warn("Failed to retrieve the children of [{}]. Root cause [{}].", nodeId, ExceptionUtils.getRootCauseMessage(e)); } } return Collections.emptyList(); }
WikiTreeNode extends AbstractEntityTreeNode { @Override public List<String> getChildren(String nodeId, int offset, int limit) { EntityReference wikiReference = resolve(nodeId); if (wikiReference != null && wikiReference.getType() == EntityType.WIKI) { try { return serialize(getChildren(new WikiReference(wikiReference), offset, limit)); } catch (QueryException e) { this.logger.warn("Failed to retrieve the children of [{}]. Root cause [{}].", nodeId, ExceptionUtils.getRootCauseMessage(e)); } } return Collections.emptyList(); } }
WikiTreeNode extends AbstractEntityTreeNode { @Override public List<String> getChildren(String nodeId, int offset, int limit) { EntityReference wikiReference = resolve(nodeId); if (wikiReference != null && wikiReference.getType() == EntityType.WIKI) { try { return serialize(getChildren(new WikiReference(wikiReference), offset, limit)); } catch (QueryException e) { this.logger.warn("Failed to retrieve the children of [{}]. Root cause [{}].", nodeId, ExceptionUtils.getRootCauseMessage(e)); } } return Collections.emptyList(); }  }
WikiTreeNode extends AbstractEntityTreeNode { @Override public List<String> getChildren(String nodeId, int offset, int limit) { EntityReference wikiReference = resolve(nodeId); if (wikiReference != null && wikiReference.getType() == EntityType.WIKI) { try { return serialize(getChildren(new WikiReference(wikiReference), offset, limit)); } catch (QueryException e) { this.logger.warn("Failed to retrieve the children of [{}]. Root cause [{}].", nodeId, ExceptionUtils.getRootCauseMessage(e)); } } return Collections.emptyList(); }  @Override List<String> getChildren(String nodeId, int offset, int limit); @Override int getChildCount(String nodeId); @Override String getParent(String nodeId); }
WikiTreeNode extends AbstractEntityTreeNode { @Override public List<String> getChildren(String nodeId, int offset, int limit) { EntityReference wikiReference = resolve(nodeId); if (wikiReference != null && wikiReference.getType() == EntityType.WIKI) { try { return serialize(getChildren(new WikiReference(wikiReference), offset, limit)); } catch (QueryException e) { this.logger.warn("Failed to retrieve the children of [{}]. Root cause [{}].", nodeId, ExceptionUtils.getRootCauseMessage(e)); } } return Collections.emptyList(); }  @Override List<String> getChildren(String nodeId, int offset, int limit); @Override int getChildCount(String nodeId); @Override String getParent(String nodeId);  }