### Question:
DisplayHierarchyNode { public boolean isLeaf( DisplayHierarchyContext context ) { return rdfNode().isLiteral() || !(isRoot() || rdfNode().isAnon() || isOnExplicitPath() || !context.isSeen( rdfNode() )); } DisplayHierarchyNode( PropertyPath pathTo, DisplayHierarchyNode parent,
                                 DisplayRdfNode rdfNode, ShortNameRenderer shortNameRenderer ); PropertyPath pathTo(); RDFNodeWrapper terminalLink(); boolean isOnExplicitPath(); Set<PropertyPath> explicitPaths(); DisplayHierarchyNode parent(); boolean isRoot(); DisplayRdfNode rdfNode(); boolean isLoop(); boolean findAncestor( DisplayRdfNode resource ); boolean isLeaf( DisplayHierarchyContext context ); List<DisplayHierarchyNode> children(); void addSibling( DisplayHierarchyNode sibling ); List<DisplayHierarchyNode> siblings(); boolean hasSiblings(); void addHint( String hint ); String hintsString(); boolean hasHint( String hint ); boolean isSimpleResource(); String relatedLinksHTML(); List<Link> relatedLinks(); boolean hasAllProperties( Object... properties ); boolean hasAllProperties( List<Object> properties ); void pullToStart( Object... properties ); void pullToStart( List<Object> properties ); List<DisplayHierarchyNode> extractByPredicate( Object... properties ); List<DisplayHierarchyNode> extractByPredicate( List<Object> properties ); boolean isResource(); boolean isLiteral(); boolean isAnon(); boolean isList(); String getLexicalForm(); String getName(); Object getValue(); String getURI(); @Override String toString(); static final String SORT_BY_FORMAT; static final int MAX_RELATED_LINK_LABEL_LENGTH; }### Answer:
@Test public void testIsLeaf() { DisplayHierarchyContext dhc = contextFixture( false, "dhc" ); assertFalse( dhn.isLeaf( dhc )); DisplayHierarchyNode c0 = new DisplayHierarchyNode( new PropertyPath(), dhn, new DisplayRdfNode( rm.page(), ResourceFactory.createPlainLiteral( "foo" ) ), null ); assertTrue( c0.isLeaf( dhc )); Resource r0 = ResourceFactory.createResource( "http: DisplayHierarchyContext dhc1 = contextFixture( true, "dhc1" ); DisplayHierarchyNode c3 = new DisplayHierarchyNode( new PropertyPath( "fu" ), dhn, new DisplayRdfNode( rm.page(), r0 ), null ); assertTrue( c3.isLeaf( dhc1 )); c3.explicitPaths().add( new PropertyPath( "*" ) ); assertFalse( c3.isLeaf( dhc1 )); }