@Test public void getChildCount() 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); assertEquals(0, this.wikiTreeNode.getChildCount("something")); assertEquals(0, this.wikiTreeNode.getChildCount("some:thing")); when(this.queryManager.createQuery("select count(*) from XWikiSpace where parent is null and hidden <> true", Query.HQL)).thenReturn(this.query); when(query.execute()).thenReturn(Collections.singletonList(2L)); assertEquals(2L, this.wikiTreeNode.getChildCount("wiki:foo")); verify(this.query).setWiki("foo"); verify(this.query, never()).bindValue(anyString(), any()); }
@Override public int getChildCount(String nodeId) { EntityReference wikiReference = resolve(nodeId); if (wikiReference != null && wikiReference.getType() == EntityType.WIKI) { try { return getChildCount(new WikiReference(wikiReference)); } catch (QueryException e) { this.logger.warn("Failed to count the children of [{}]. Root cause [{}].", nodeId, ExceptionUtils.getRootCauseMessage(e)); } } return 0; }
WikiTreeNode extends AbstractEntityTreeNode { @Override public int getChildCount(String nodeId) { EntityReference wikiReference = resolve(nodeId); if (wikiReference != null && wikiReference.getType() == EntityType.WIKI) { try { return getChildCount(new WikiReference(wikiReference)); } catch (QueryException e) { this.logger.warn("Failed to count the children of [{}]. Root cause [{}].", nodeId, ExceptionUtils.getRootCauseMessage(e)); } } return 0; } }
WikiTreeNode extends AbstractEntityTreeNode { @Override public int getChildCount(String nodeId) { EntityReference wikiReference = resolve(nodeId); if (wikiReference != null && wikiReference.getType() == EntityType.WIKI) { try { return getChildCount(new WikiReference(wikiReference)); } catch (QueryException e) { this.logger.warn("Failed to count the children of [{}]. Root cause [{}].", nodeId, ExceptionUtils.getRootCauseMessage(e)); } } return 0; }  }
WikiTreeNode extends AbstractEntityTreeNode { @Override public int getChildCount(String nodeId) { EntityReference wikiReference = resolve(nodeId); if (wikiReference != null && wikiReference.getType() == EntityType.WIKI) { try { return getChildCount(new WikiReference(wikiReference)); } catch (QueryException e) { this.logger.warn("Failed to count the children of [{}]. Root cause [{}].", nodeId, ExceptionUtils.getRootCauseMessage(e)); } } return 0; }  @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 int getChildCount(String nodeId) { EntityReference wikiReference = resolve(nodeId); if (wikiReference != null && wikiReference.getType() == EntityType.WIKI) { try { return getChildCount(new WikiReference(wikiReference)); } catch (QueryException e) { this.logger.warn("Failed to count the children of [{}]. Root cause [{}].", nodeId, ExceptionUtils.getRootCauseMessage(e)); } } return 0; }  @Override List<String> getChildren(String nodeId, int offset, int limit); @Override int getChildCount(String nodeId); @Override String getParent(String nodeId);  }