@Test public void testMatches() { NodeMatcher childMatcher = mock( NodeMatcher.class ); MatcherContext context = mock( MatcherContext.class ); ReportElement node = mock( ReportElement.class ); Section parent = mock( Section.class ); DescendantMatcher matcher = new DescendantMatcher( childMatcher ); assertThat( matcher.matches( context, null ), is( equalTo( false ) ) ); assertThat( matcher.matches( context, node ), is( equalTo( false ) ) ); doReturn( parent ).when( context ).getParent( node ); assertThat( matcher.matches( context, node ), is( equalTo( false ) ) ); doReturn( true ).when( childMatcher ).matches( context, parent ); assertThat( matcher.matches( context, node ), is( equalTo( true ) ) ); }
public boolean matches( final MatcherContext context, final ReportElement node ) { ReportElement n = node; while ( n != null ) { final Section parent = context.getParent( n ); if ( parent == null ) { break; } if ( childMatcher.matches( context, parent ) ) { return true; } n = parent; } return false; }
DescendantMatcher implements NodeMatcher { public boolean matches( final MatcherContext context, final ReportElement node ) { ReportElement n = node; while ( n != null ) { final Section parent = context.getParent( n ); if ( parent == null ) { break; } if ( childMatcher.matches( context, parent ) ) { return true; } n = parent; } return false; } }
DescendantMatcher implements NodeMatcher { public boolean matches( final MatcherContext context, final ReportElement node ) { ReportElement n = node; while ( n != null ) { final Section parent = context.getParent( n ); if ( parent == null ) { break; } if ( childMatcher.matches( context, parent ) ) { return true; } n = parent; } return false; } DescendantMatcher( final NodeMatcher childMatcher ); }
DescendantMatcher implements NodeMatcher { public boolean matches( final MatcherContext context, final ReportElement node ) { ReportElement n = node; while ( n != null ) { final Section parent = context.getParent( n ); if ( parent == null ) { break; } if ( childMatcher.matches( context, parent ) ) { return true; } n = parent; } return false; } DescendantMatcher( final NodeMatcher childMatcher ); boolean matches( final MatcherContext context, final ReportElement node ); String toString(); }
DescendantMatcher implements NodeMatcher { public boolean matches( final MatcherContext context, final ReportElement node ) { ReportElement n = node; while ( n != null ) { final Section parent = context.getParent( n ); if ( parent == null ) { break; } if ( childMatcher.matches( context, parent ) ) { return true; } n = parent; } return false; } DescendantMatcher( final NodeMatcher childMatcher ); boolean matches( final MatcherContext context, final ReportElement node ); String toString();  }