use of spoon.test.imports.testclasses.SubClass in project spoon by INRIA.
the class ImportTest method testNewInnerClassDefinesInItsClassAndSuperClass.
@Test
public void testNewInnerClassDefinesInItsClassAndSuperClass() throws Exception {
Launcher spoon = new Launcher();
spoon.setArgs(new String[] { "--output-type", "nooutput" });
Factory factory = spoon.createFactory();
SpoonModelBuilder compiler = spoon.createCompiler(factory, SpoonResourceHelper.resources("./src/test/java/spoon/test/imports/testclasses/SuperClass.java", "./src/test/java/spoon/test/imports/testclasses/SubClass.java"));
compiler.build();
final CtClass<?> subClass = (CtClass<?>) factory.Type().get(SubClass.class);
final CtConstructorCall<?> ctConstructorCall = subClass.getElements(new TypeFilter<CtConstructorCall<?>>(CtConstructorCall.class)).get(0);
assertEquals("new spoon.test.imports.testclasses.SubClass.Item(\"\")", ctConstructorCall.toString());
// here the buggy behavior with type members was encoded
// so we fix it
final String expected = "public class SubClass extends spoon.test.imports.testclasses.SuperClass {" + System.lineSeparator() + " public void aMethod() {" + System.lineSeparator() + " new spoon.test.imports.testclasses.SubClass.Item(\"\");" + System.lineSeparator() + " }" + System.lineSeparator() + System.lineSeparator() + " public static class Item extends spoon.test.imports.testclasses.SuperClass.Item {" + System.lineSeparator() + " public Item(java.lang.String s) {" + System.lineSeparator() + " super(1, s);" + System.lineSeparator() + " }" + System.lineSeparator() + " }" + System.lineSeparator() + "}";
assertEquals(expected, subClass.toString());
}
Aggregations