@Test public void testMatches() { ElementType type = mock( ElementType.class ); ElementMetaData meta = mock( ElementMetaData.class ); MatcherContext context = mock( MatcherContext.class ); ReportElement node = mock( ReportElement.class ); ElementType nodeElemType = mock( ElementType.class ); ElementMetaData nodeMeta = mock( ElementMetaData.class ); doReturn( meta ).when( type ).getMetaData(); doReturn( NAME ).when( meta ).getName(); doReturn( nodeElemType ).when( node ).getElementType(); doReturn( nodeMeta ).when( nodeElemType ).getMetaData(); doReturn( NAME + "_node" ).when( nodeMeta ).getName(); ElementMatcher matcher = new ElementMatcher( type ); assertThat( matcher.matches( context, node ), is( equalTo( false ) ) ); doReturn( NAME ).when( nodeMeta ).getName(); assertThat( matcher.matches( context, node ), is( equalTo( true ) ) ); AttributeMatcher attrMatcher = mock( AttributeMatcher.class ); doReturn( true ).when( attrMatcher ).matches( context, node ); matcher.add( attrMatcher ); assertThat( matcher.matches( context, node ), is( equalTo( true ) ) ); doReturn( false ).when( attrMatcher ).matches( context, node ); assertThat( matcher.matches( context, node ), is( equalTo( false ) ) ); }
public boolean matches( final MatcherContext context, final ReportElement node ) { if ( node == null ) { throw new NullPointerException(); } final String type = node.getElementType().getMetaData().getName(); if ( type.equals( name ) ) { return matchAttributes( context, node ); } return false; }
ElementMatcher implements NodeMatcher { public boolean matches( final MatcherContext context, final ReportElement node ) { if ( node == null ) { throw new NullPointerException(); } final String type = node.getElementType().getMetaData().getName(); if ( type.equals( name ) ) { return matchAttributes( context, node ); } return false; } }
ElementMatcher implements NodeMatcher { public boolean matches( final MatcherContext context, final ReportElement node ) { if ( node == null ) { throw new NullPointerException(); } final String type = node.getElementType().getMetaData().getName(); if ( type.equals( name ) ) { return matchAttributes( context, node ); } return false; } ElementMatcher( final ElementType name );  ElementMatcher( final String name ); }
ElementMatcher implements NodeMatcher { public boolean matches( final MatcherContext context, final ReportElement node ) { if ( node == null ) { throw new NullPointerException(); } final String type = node.getElementType().getMetaData().getName(); if ( type.equals( name ) ) { return matchAttributes( context, node ); } return false; } ElementMatcher( final ElementType name );  ElementMatcher( final String name ); void add( final AttributeMatcher matchers ); boolean matches( final MatcherContext context, final ReportElement node ); String toString(); }
ElementMatcher implements NodeMatcher { public boolean matches( final MatcherContext context, final ReportElement node ) { if ( node == null ) { throw new NullPointerException(); } final String type = node.getElementType().getMetaData().getName(); if ( type.equals( name ) ) { return matchAttributes( context, node ); } return false; } ElementMatcher( final ElementType name );  ElementMatcher( final String name ); void add( final AttributeMatcher matchers ); boolean matches( final MatcherContext context, final ReportElement node ); String toString();  }