use of net.sourceforge.pmd.lang.java.multifile.signature.JavaOperationSignature.Role 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));
}
}
Aggregations