Skip to content

Commit

Permalink
test: reduce the scope of the testSettersAreAllGood test
Browse files Browse the repository at this point in the history
  • Loading branch information
tdurieux committed Feb 23, 2017
1 parent f6d989a commit 97cafcc
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions src/test/java/spoon/test/intercession/IntercessionTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import spoon.reflect.declaration.CtConstructor;
import spoon.reflect.declaration.CtMethod;
import spoon.reflect.declaration.CtParameter;
import spoon.reflect.declaration.CtType;
import spoon.reflect.declaration.CtTypeParameter;
import spoon.reflect.declaration.ModifierKind;
import spoon.reflect.factory.Factory;
Expand Down Expand Up @@ -191,18 +192,23 @@ public void testSettersAreAllGood() throws Exception {
String systemClassPath = classpath.substring(0, classpath.length() - 1);

final Launcher launcher = new Launcher();
launcher.run(new String[] {
"-i", "./src/main/java",
"--output-type", "nooutput",
"--source-classpath", systemClassPath
});
launcher.addInputResource("./src/main/java/spoon/reflect/");
launcher.addInputResource("./src/main/java/spoon/support/");
launcher.getModelBuilder().setSourceClasspath(systemClassPath);
launcher.buildModel();

final Factory factory = launcher.getFactory();
final List<CtMethod<?>> setters = Query
.getElements(factory, new AbstractFilter<CtMethod<?>>(CtMethod.class) {
@Override
public boolean matches(CtMethod<?> element) {
return element.getDeclaringType().isInterface() &&
element.getDeclaringType().getSimpleName().startsWith("Ct") &&
CtType<?> declaringType = element.getDeclaringType();
if (declaringType.getPackage().getQualifiedName().startsWith("spoon.support.visitor")
|| declaringType.getPackage().getQualifiedName().startsWith("spoon.reflect.visitor")) {
return false;
}
return declaringType.isInterface() &&
declaringType.getSimpleName().startsWith("Ct") &&
(element.getSimpleName().startsWith("set") ||
element.getSimpleName().startsWith("add"));
}
Expand Down

0 comments on commit 97cafcc

Please sign in to comment.