use of net.sourceforge.pmd.lang.java.qname.JavaTypeQualifiedName in project pmd by pmd.
the class JavaQualifiedNameTest method testNestedEnum.
@Test
public void testNestedEnum() {
final String TEST = "package foo.bar; class Foo { enum Bzaz{HOO;}}";
List<ASTEnumDeclaration> nodes = getNodes(ASTEnumDeclaration.class, TEST);
for (ASTEnumDeclaration coid : nodes) {
JavaTypeQualifiedName qname = coid.getQualifiedName();
assertEquals("foo.bar.Foo$Bzaz", qname.toString());
assertEquals(2, qname.getPackageList().size());
assertEquals(2, qname.getClassList().size());
}
}
use of net.sourceforge.pmd.lang.java.qname.JavaTypeQualifiedName in project pmd by pmd.
the class JavaQualifiedNameTest method testNestedEmptyPackage.
@Test
public void testNestedEmptyPackage() {
final String TEST = "class Bzaz{ class Bor{ class Foo{}}}";
List<ASTClassOrInterfaceDeclaration> nodes = getNodes(ASTClassOrInterfaceDeclaration.class, TEST);
for (ASTClassOrInterfaceDeclaration coid : nodes) {
JavaTypeQualifiedName qname = coid.getQualifiedName();
switch(coid.getImage()) {
case "Foo":
assertEquals("Bzaz$Bor$Foo", qname.toString());
assertTrue(qname.getPackageList().isEmpty());
assertTrue(qname.isUnnamedPackage());
assertEquals(3, qname.getClassList().size());
break;
default:
break;
}
}
}
use of net.sourceforge.pmd.lang.java.qname.JavaTypeQualifiedName in project pmd by pmd.
the class JavaQualifiedNameTest method testEnum.
@Test
public void testEnum() {
final String TEST = "package foo.bar; enum Bzaz{HOO;}";
List<ASTEnumDeclaration> nodes = getNodes(ASTEnumDeclaration.class, TEST);
for (ASTEnumDeclaration coid : nodes) {
JavaTypeQualifiedName qname = coid.getQualifiedName();
assertEquals("foo.bar.Bzaz", qname.toString());
assertEquals(2, qname.getPackageList().size());
assertEquals(1, qname.getClassList().size());
}
}
use of net.sourceforge.pmd.lang.java.qname.JavaTypeQualifiedName in project pmd by pmd.
the class JavaQualifiedNameTest method testParseClass.
@Test
public void testParseClass() {
JavaTypeQualifiedName outer = (JavaTypeQualifiedName) QualifiedNameFactory.ofString("foo.bar.Bzaz");
JavaTypeQualifiedName nested = (JavaTypeQualifiedName) QualifiedNameFactory.ofString("foo.bar.Bzaz$Bolg");
assertEquals(1, outer.getClassList().size());
assertEquals("Bzaz", outer.getClassList().get(0));
assertEquals(2, nested.getClassList().size());
assertEquals("Bzaz", nested.getClassList().get(0));
assertEquals("Bolg", nested.getClassList().get(1));
}
use of net.sourceforge.pmd.lang.java.qname.JavaTypeQualifiedName in project pmd by pmd.
the class JavaQualifiedNameTest method testParsePackages.
@Test
public void testParsePackages() {
JavaTypeQualifiedName packs = (JavaTypeQualifiedName) QualifiedNameFactory.ofString("foo.bar.Bzaz$Bolg");
JavaTypeQualifiedName nopacks = (JavaTypeQualifiedName) QualifiedNameFactory.ofString("Bzaz");
assertNotNull(packs.getPackageList());
assertEquals("foo", packs.getPackageList().get(0));
assertEquals("bar", packs.getPackageList().get(1));
assertTrue(nopacks.getPackageList().isEmpty());
}
Aggregations