OrDependencyFilter implements DependencyFilter { public boolean accept( DependencyNode node, List<DependencyNode> parents ) { for ( DependencyFilter filter : filters ) { if ( filter.accept( node, parents ) ) { return true; } } return false; } OrDependencyFilter( DependencyFilter... filters );  OrDependencyFilter( Collection<DependencyFilter> filters ); static DependencyFilter newInstance( DependencyFilter filter1, DependencyFilter filter2 ); boolean accept( DependencyNode node, List<DependencyNode> parents ); @Override boolean equals( Object obj ); @Override int hashCode();  }
@Test public void acceptTest() { NodeBuilder builder = new NodeBuilder(); builder.artifactId( "test" ); List<DependencyNode> parents = new LinkedList<DependencyNode>(); assertFalse( new OrDependencyFilter().accept( builder.build(), parents ) ); assertTrue( new OrDependencyFilter( getAcceptFilter() ).accept( builder.build(), parents ) ); assertFalse( new OrDependencyFilter( getDenyFilter() ).accept( builder.build(), parents ) ); assertFalse( new OrDependencyFilter( getDenyFilter(), getDenyFilter() ).accept( builder.build(), parents ) ); assertTrue( new OrDependencyFilter( getDenyFilter(), getAcceptFilter() ).accept( builder.build(), parents ) ); assertTrue( new OrDependencyFilter( getAcceptFilter(), getDenyFilter() ).accept( builder.build(), parents ) ); assertTrue( new OrDependencyFilter( getAcceptFilter(), getAcceptFilter() ).accept( builder.build(), parents ) ); assertFalse( new OrDependencyFilter( getDenyFilter(), getDenyFilter(), getDenyFilter() ).accept( builder.build(), parents ) ); assertTrue( new OrDependencyFilter( getAcceptFilter(), getDenyFilter(), getDenyFilter() ).accept( builder.build(), parents ) ); assertTrue( new OrDependencyFilter( getAcceptFilter(), getAcceptFilter(), getDenyFilter() ).accept( builder.build(), parents ) ); assertTrue( new OrDependencyFilter( getAcceptFilter(), getAcceptFilter(), getAcceptFilter() ).accept( builder.build(), parents ) ); Collection<DependencyFilter> filters = new LinkedList<DependencyFilter>(); filters.add( getDenyFilter() ); filters.add( getAcceptFilter() ); assertTrue( new OrDependencyFilter( filters ).accept( builder.build(), parents ) ); filters = new LinkedList<DependencyFilter>(); filters.add( getDenyFilter() ); filters.add( getDenyFilter() ); assertFalse( new OrDependencyFilter( filters ).accept( builder.build(), parents ) ); assertTrue( AndDependencyFilter.newInstance( getAcceptFilter(), getAcceptFilter() ).accept( builder.build(), parents ) ); assertFalse( AndDependencyFilter.newInstance( getAcceptFilter(), getDenyFilter() ).accept( builder.build(), parents ) ); assertTrue( AndDependencyFilter.newInstance( getAcceptFilter(), null ).accept( builder.build(), parents ) ); assertFalse( AndDependencyFilter.newInstance( getDenyFilter(), null ).accept( builder.build(), parents ) ); assertNull( AndDependencyFilter.newInstance( null, null ) ); }