use of net.sourceforge.pmd.lang.java.qname.JavaOperationQualifiedName in project pmd by pmd.
the class JavaMultifileVisitorTest method testBothClassesOperationsAreThere.
@Test
public void testBothClassesOperationsAreThere() {
parseAndVisitForClass(MultifileVisitorTestData2.class);
parseAndVisitForClass(MultifileVisitorTestData2.class);
final ProjectMirror toplevel = PackageStats.INSTANCE;
final JavaOperationSigMask operationSigMask = new JavaOperationSigMask();
JavaQualifiedName clazz = QualifiedNameFactory.ofClass(MultifileVisitorTestData2.class);
JavaQualifiedName clazz2 = QualifiedNameFactory.ofClass(MultifileVisitorTestData2.class);
String[] opNames = { "getX()", "getY()", "setX(String)", "setY(String)", "mymethod1()", "mymethod2()", "mystatic1()", "mystatic2(String)", "mystatic2(String, String)" };
Role[] roles = { Role.GETTER_OR_SETTER, Role.GETTER_OR_SETTER, Role.GETTER_OR_SETTER, Role.GETTER_OR_SETTER, Role.METHOD, Role.METHOD, Role.STATIC, Role.STATIC, Role.STATIC };
for (int i = 0; i < opNames.length; i++) {
operationSigMask.restrictRolesTo(roles[i]);
JavaOperationQualifiedName name1 = (JavaOperationQualifiedName) QualifiedNameFactory.ofString(clazz.toString() + "#" + opNames[i]);
JavaOperationQualifiedName name2 = (JavaOperationQualifiedName) QualifiedNameFactory.ofString(clazz2.toString() + "#" + opNames[i]);
assertTrue(toplevel.hasMatchingSig(name1, operationSigMask));
assertTrue(toplevel.hasMatchingSig(name2, operationSigMask));
}
}
use of net.sourceforge.pmd.lang.java.qname.JavaOperationQualifiedName in project pmd by pmd.
the class JavaQualifiedNameTest method testConstructorWithParams.
@Test
public void testConstructorWithParams() {
final String TEST = "package bar; class Bzaz{ public Bzaz(int j, String k){}}";
List<ASTConstructorDeclaration> nodes = getNodes(ASTConstructorDeclaration.class, TEST);
for (ASTConstructorDeclaration declaration : nodes) {
JavaOperationQualifiedName qname = declaration.getQualifiedName();
assertEquals("bar.Bzaz#Bzaz(int, String)", qname.toString());
assertNotNull(qname.getOperation());
assertEquals("Bzaz(int, String)", qname.getOperation());
}
}
use of net.sourceforge.pmd.lang.java.qname.JavaOperationQualifiedName in project pmd by pmd.
the class JavaQualifiedNameTest method testConstructor.
@Test
public void testConstructor() {
final String TEST = "package bar; class Bzaz{ public Bzaz(){}}";
List<ASTConstructorDeclaration> nodes = getNodes(ASTConstructorDeclaration.class, TEST);
for (ASTConstructorDeclaration declaration : nodes) {
JavaOperationQualifiedName qname = declaration.getQualifiedName();
assertEquals("bar.Bzaz#Bzaz()", qname.toString());
assertNotNull(qname.getOperation());
assertEquals("Bzaz()", qname.getOperation());
}
}
use of net.sourceforge.pmd.lang.java.qname.JavaOperationQualifiedName in project pmd by pmd.
the class JavaQualifiedNameTest method testMethod.
@Test
public void testMethod() {
final String TEST = "package bar; class Bzaz{ public void foo(){}}";
List<ASTMethodDeclaration> nodes = getNodes(ASTMethodDeclaration.class, TEST);
for (ASTMethodDeclaration declaration : nodes) {
JavaOperationQualifiedName qname = declaration.getQualifiedName();
assertEquals("bar.Bzaz#foo()", qname.toString());
assertNotNull(qname.getOperation());
assertEquals("foo()", qname.getOperation());
}
}
use of net.sourceforge.pmd.lang.java.qname.JavaOperationQualifiedName in project pmd by pmd.
the class JavaQualifiedNameTest method testParseOperation.
@Test
public void testParseOperation() {
JavaOperationQualifiedName noparams = (JavaOperationQualifiedName) QualifiedNameFactory.ofString("foo.bar.Bzaz$Bolg#bar()");
JavaOperationQualifiedName params = (JavaOperationQualifiedName) QualifiedNameFactory.ofString("foo.bar.Bzaz#bar(String, int)");
assertEquals("bar()", noparams.getOperation());
assertEquals("bar(String, int)", params.getOperation());
}
Aggregations