use of spoon.test.filters.testclasses.AbstractTostada in project spoon by INRIA.
the class FilterTest method testOverridingMethodFromAbstractClass.
@Test
public void testOverridingMethodFromAbstractClass() throws Exception {
// contract: When we declare an abstract method on an abstract class, we must return all overriding
// methods in sub classes and anonymous classes.
final Launcher launcher = new Launcher();
launcher.setArgs(new String[] { "--output-type", "nooutput" });
launcher.addInputResource("./src/test/java/spoon/test/filters/testclasses");
launcher.run();
final CtClass<AbstractTostada> aClass = launcher.getFactory().Class().get(AbstractTostada.class);
TreeSet<CtMethod<?>> ts = new TreeSet<CtMethod<?>>(new DeepRepresentationComparator());
List<CtMethod<?>> elements = Query.getElements(launcher.getFactory(), new OverridingMethodFilter(aClass.getMethodsByName("prepare").get(0)));
ts.addAll(elements);
assertEquals(5, elements.size());
final List<CtMethod<?>> overridingMethods = Arrays.asList(ts.toArray(new CtMethod[0]));
assertEquals("spoon.test.filters.testclasses.AbstractTostada$1", overridingMethods.get(3).getParent(CtClass.class).getQualifiedName());
assertEquals(Antojito.class, overridingMethods.get(1).getParent(CtClass.class).getActualClass());
assertEquals(SubTostada.class, overridingMethods.get(2).getParent(CtClass.class).getActualClass());
assertEquals("spoon.test.filters.testclasses.Tostada$1", overridingMethods.get(0).getParent(CtClass.class).getQualifiedName());
assertEquals(Tostada.class, overridingMethods.get(4).getParent(CtClass.class).getActualClass());
}
Aggregations