use of spoon.test.processing.testclasses.CtInterfaceProcessor in project spoon by INRIA.
the class ProcessingTest method testCallProcessorWithMultipleTypes.
@Test
public void testCallProcessorWithMultipleTypes() {
// contract: when calling a processor capable of treating CtClass and another capable of treating CtType, they are called on the right types
Launcher spoon = new Launcher();
spoon.addInputResource("./src/test/java/spoon/test/imports/testclasses");
CtClassProcessor classProcessor = new CtClassProcessor();
spoon.addProcessor(classProcessor);
CtTypeProcessor typeProcessor = new CtTypeProcessor();
spoon.addProcessor(typeProcessor);
CtInterfaceProcessor interfaceProcessor = new CtInterfaceProcessor();
spoon.addProcessor(interfaceProcessor);
spoon.run();
assertFalse(classProcessor.elements.isEmpty());
for (CtType type : classProcessor.elements) {
assertTrue("Type " + type.getSimpleName() + " is not a class", type instanceof CtClass);
}
assertFalse(classProcessor.elements.isEmpty());
for (CtType type : interfaceProcessor.elements) {
assertTrue("Type " + type.getSimpleName() + " is not an interface", type instanceof CtInterface);
}
assertFalse(typeProcessor.elements.isEmpty());
for (CtType type : typeProcessor.elements) {
if (type instanceof CtClass) {
assertTrue(classProcessor.elements.contains(type));
assertFalse(interfaceProcessor.elements.contains(type));
} else if (type instanceof CtInterface) {
assertFalse(classProcessor.elements.contains(type));
assertTrue(interfaceProcessor.elements.contains(type));
} else {
assertFalse(classProcessor.elements.contains(type));
assertFalse(interfaceProcessor.elements.contains(type));
}
}
}
Aggregations