DependencyFilterUtils { public static DependencyFilter classpathFilter( String... classpathTypes ) { return classpathFilter( ( classpathTypes != null ) ? Arrays.asList( classpathTypes ) : null ); } private  DependencyFilterUtils(); static DependencyFilter notFilter( DependencyFilter filter ); static DependencyFilter andFilter( DependencyFilter... filters ); static DependencyFilter andFilter( Collection<DependencyFilter> filters ); static DependencyFilter orFilter( DependencyFilter... filters ); static DependencyFilter orFilter( Collection<DependencyFilter> filters ); static DependencyFilter classpathFilter( String... classpathTypes ); static DependencyFilter classpathFilter( Collection<String> classpathTypes );  }
@Test public void testClasspathFilterCompile() { NodeBuilder builder = new NodeBuilder().artifactId( "aid" ); DependencyFilter filter = DependencyFilterUtils.classpathFilter( "compile" ); assertTrue( filter.accept( builder.scope( "compile" ).build(), PARENTS ) ); assertTrue( filter.accept( builder.scope( "system" ).build(), PARENTS ) ); assertTrue( filter.accept( builder.scope( "provided" ).build(), PARENTS ) ); assertFalse( filter.accept( builder.scope( "runtime" ).build(), PARENTS ) ); assertFalse( filter.accept( builder.scope( "test" ).build(), PARENTS ) ); }
@Test public void testClasspathFilterRuntime() { NodeBuilder builder = new NodeBuilder().artifactId( "aid" ); DependencyFilter filter = DependencyFilterUtils.classpathFilter( "runtime" ); assertTrue( filter.accept( builder.scope( "compile" ).build(), PARENTS ) ); assertFalse( filter.accept( builder.scope( "system" ).build(), PARENTS ) ); assertFalse( filter.accept( builder.scope( "provided" ).build(), PARENTS ) ); assertTrue( filter.accept( builder.scope( "runtime" ).build(), PARENTS ) ); assertFalse( filter.accept( builder.scope( "test" ).build(), PARENTS ) ); }
@Test public void testClasspathFilterTest() { NodeBuilder builder = new NodeBuilder().artifactId( "aid" ); DependencyFilter filter = DependencyFilterUtils.classpathFilter( "test" ); assertTrue( filter.accept( builder.scope( "compile" ).build(), PARENTS ) ); assertTrue( filter.accept( builder.scope( "system" ).build(), PARENTS ) ); assertTrue( filter.accept( builder.scope( "provided" ).build(), PARENTS ) ); assertTrue( filter.accept( builder.scope( "runtime" ).build(), PARENTS ) ); assertTrue( filter.accept( builder.scope( "test" ).build(), PARENTS ) ); }
@Test public void testClasspathFilterCompileRuntime() { NodeBuilder builder = new NodeBuilder().artifactId( "aid" ); DependencyFilter filter = DependencyFilterUtils.classpathFilter( "compile", "runtime" ); assertTrue( filter.accept( builder.scope( "compile" ).build(), PARENTS ) ); assertTrue( filter.accept( builder.scope( "system" ).build(), PARENTS ) ); assertTrue( filter.accept( builder.scope( "provided" ).build(), PARENTS ) ); assertTrue( filter.accept( builder.scope( "runtime" ).build(), PARENTS ) ); assertFalse( filter.accept( builder.scope( "test" ).build(), PARENTS ) ); }
@Test public void testClasspathFilterCompilePlusRuntime() { NodeBuilder builder = new NodeBuilder().artifactId( "aid" ); DependencyFilter filter = DependencyFilterUtils.classpathFilter( "compile+runtime" ); assertTrue( filter.accept( builder.scope( "compile" ).build(), PARENTS ) ); assertTrue( filter.accept( builder.scope( "system" ).build(), PARENTS ) ); assertTrue( filter.accept( builder.scope( "provided" ).build(), PARENTS ) ); assertTrue( filter.accept( builder.scope( "runtime" ).build(), PARENTS ) ); assertFalse( filter.accept( builder.scope( "test" ).build(), PARENTS ) ); }
@Test public void testClasspathFilterRuntimeCommaSystem() { NodeBuilder builder = new NodeBuilder().artifactId( "aid" ); DependencyFilter filter = DependencyFilterUtils.classpathFilter( "runtime,system" ); assertTrue( filter.accept( builder.scope( "compile" ).build(), PARENTS ) ); assertTrue( filter.accept( builder.scope( "system" ).build(), PARENTS ) ); assertFalse( filter.accept( builder.scope( "provided" ).build(), PARENTS ) ); assertTrue( filter.accept( builder.scope( "runtime" ).build(), PARENTS ) ); assertFalse( filter.accept( builder.scope( "test" ).build(), PARENTS ) ); }
@Test public void testClasspathFilterNull() { NodeBuilder builder = new NodeBuilder().artifactId( "aid" ); DependencyFilter filter = DependencyFilterUtils.classpathFilter( (String[]) null ); assertFalse( filter.accept( builder.scope( "compile" ).build(), PARENTS ) ); assertFalse( filter.accept( builder.scope( "system" ).build(), PARENTS ) ); assertFalse( filter.accept( builder.scope( "provided" ).build(), PARENTS ) ); assertFalse( filter.accept( builder.scope( "runtime" ).build(), PARENTS ) ); assertFalse( filter.accept( builder.scope( "test" ).build(), PARENTS ) ); }
@Test public void testClasspathFilterUnknownScope() { NodeBuilder builder = new NodeBuilder().artifactId( "aid" ); DependencyFilter filter = DependencyFilterUtils.classpathFilter( "compile" ); assertTrue( filter.accept( builder.scope( "" ).build(), PARENTS ) ); assertTrue( filter.accept( builder.scope( "unknown" ).build(), PARENTS ) ); }