001package org.eclipse.aether.util.filter; 002 003/* 004 * Licensed to the Apache Software Foundation (ASF) under one 005 * or more contributor license agreements. See the NOTICE file 006 * distributed with this work for additional information 007 * regarding copyright ownership. The ASF licenses this file 008 * to you under the Apache License, Version 2.0 (the 009 * "License"); you may not use this file except in compliance 010 * with the License. You may obtain a copy of the License at 011 * 012 * http://www.apache.org/licenses/LICENSE-2.0 013 * 014 * Unless required by applicable law or agreed to in writing, 015 * software distributed under the License is distributed on an 016 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 017 * KIND, either express or implied. See the License for the 018 * specific language governing permissions and limitations 019 * under the License. 020 */ 021 022import static org.junit.Assert.*; 023 024import java.util.Arrays; 025import java.util.LinkedList; 026import java.util.List; 027 028import org.eclipse.aether.graph.DependencyNode; 029import org.eclipse.aether.internal.test.util.NodeBuilder; 030import org.eclipse.aether.util.filter.ExclusionsDependencyFilter; 031import org.junit.Test; 032 033public class ExclusionDependencyFilterTest 034{ 035 036 @Test 037 public void acceptTest() 038 { 039 040 NodeBuilder builder = new NodeBuilder(); 041 builder.groupId( "com.example.test" ).artifactId( "testArtifact" ); 042 List<DependencyNode> parents = new LinkedList<>(); 043 String[] excludes; 044 045 excludes = new String[] { "com.example.test:testArtifact" }; 046 assertFalse( new ExclusionsDependencyFilter( Arrays.asList( excludes ) ).accept( builder.build(), parents ) ); 047 048 excludes = new String[] { "com.example.test:testArtifact", "com.foo:otherArtifact" }; 049 assertFalse( new ExclusionsDependencyFilter( Arrays.asList( excludes ) ).accept( builder.build(), parents ) ); 050 051 excludes = new String[] { "testArtifact" }; 052 assertFalse( new ExclusionsDependencyFilter( Arrays.asList( excludes ) ).accept( builder.build(), parents ) ); 053 054 excludes = new String[] { "otherArtifact" }; 055 assertTrue( new ExclusionsDependencyFilter( Arrays.asList( excludes ) ).accept( builder.build(), parents ) ); 056 057 assertTrue( new ExclusionsDependencyFilter( null ).accept( builder.build(), parents ) ); 058 } 059}