1
2
3
4
5
6
7
8
9
10
11
12
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 }