### Question:
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);  }### Answer:
@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); }
@Test public void getChildrenByTitle() 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); this.wikiTreeNode.getProperties().put("orderBy", "title"); this.wikiTreeNode.getProperties().put("exclusions", new HashSet<>(Arrays.asList("document:bar:A.WebHome", "document:foo:B.WebHome"))); when(this.queryManager.getNamedQuery("nonTerminalPagesOrderedByTitle")).thenReturn(this.query); when(this.localizationContext.getCurrentLocale()).thenReturn(Locale.FRENCH); 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).bindValue("locale", "fr"); verify(this.query).bindValue("excludedSpaces", Collections.singleton("B")); verify(this.query).addFilter(this.excludedSpaceFilter); }