use of spoon.reflect.code.CtExpression in project dspot by STAMP-project.
the class TestConstructorCreator method testGeneratorConstructionOfReturnNull.
@Test
public void testGeneratorConstructionOfReturnNull() throws Exception {
final Factory factory = Utils.getFactory();
final CtClass<?> createdClass = factory.Class().create("fr.inria.created.NewTestCreated");
CtExpression constructionOf = ConstructorCreator.generateConstructionOf(createdClass.getReference());
assertNull(constructionOf);
}
use of spoon.reflect.code.CtExpression in project dspot by STAMP-project.
the class TestConstructorCreator method testGenerateConstructorUsingFactory.
@Test
public void testGenerateConstructorUsingFactory() throws Exception {
/*
The ConstructorCreator can generate a call on factory.
We consider has factory methods that:
- are static
- return the type expected
- contains specific keyword in their names: build create //TODO we may need to update this list of names
*/
final Factory factory = Utils.getFactory();
Utils.findMethod("fr.inria.factory.FactoryTest", "test");
final List<CtExpression<?>> aClass = ConstructorCreator.generateConstructorUsingFactory(factory.Class().get("fr.inria.factory.FactoryTest").getNestedType("aClass").getReference());
assertEquals(2, aClass.size());
}
use of spoon.reflect.code.CtExpression in project dspot by STAMP-project.
the class TestConstructorCreator method testGenerateAllConstructorOfListOfSpecificObject.
@Test
public void testGenerateAllConstructorOfListOfSpecificObject() throws Exception {
/*
Test the good behavior when developers use specific implementation of List.
*/
final Factory factory = Utils.getFactory();
final CtTypeReference<ArrayList> listReference = factory.Type().createReference(ArrayList.class);
listReference.addActualTypeArgument(factory.Type().get("fr.inria.statementadd.ClassParameterAmplify").getReference());
final List<CtExpression> constructionOf = ConstructorCreator.generateAllConstructionOf(listReference);
assertEquals(1, constructionOf.size());
}
Aggregations