View Javadoc
1   /*
2    * Licensed under the Apache License, Version 2.0 (the "License");
3    * you may not use this file except in compliance with the License.
4    * You may obtain a copy of the License at
5    *
6    * http://www.apache.org/licenses/LICENSE-2.0
7    *
8    * Unless required by applicable law or agreed to in writing, software
9    * distributed under the License is distributed on an "AS IS" BASIS,
10   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11   * See the License for the specific language governing permissions and
12   * limitations under the License.
13   */
14  package org.basepom.mojo.duplicatefinder.classpath;
15  
16  import com.google.common.collect.ImmutableList;
17  import org.junit.Test;
18  
19  import static org.junit.Assert.assertEquals;
20  
21  public class TestPackageNameHolder {
22  
23      @Test
24      public void testEmpty() {
25          final PackageNameHolder p1 = new PackageNameHolder();
26          assertEquals("foo", p1.getQualifiedName("foo"));
27          assertEquals("foo", p1.getQualifiedPath("foo"));
28  
29          final PackageNameHolder p2 = p1.getChildPackage("bar");
30          assertEquals("bar.foo", p2.getQualifiedName("foo"));
31          assertEquals("bar/foo", p2.getQualifiedPath("foo"));
32      }
33  
34      @Test
35      public void testPrefilled() {
36          final PackageNameHolder p1 = new PackageNameHolder(ImmutableList.of("hello", "world"));
37          assertEquals("hello.world.foo", p1.getQualifiedName("foo"));
38          assertEquals("hello/world/foo", p1.getQualifiedPath("foo"));
39  
40          final PackageNameHolder p2 = p1.getChildPackage("bar");
41          assertEquals("hello.world.bar.foo", p2.getQualifiedName("foo"));
42          assertEquals("hello/world/bar/foo", p2.getQualifiedPath("foo"));
43      }
44  }