Search in sources :

Example 1 with TypeA

use of spoon.test.refactoring.parameter.testclasses.TypeA in project spoon by INRIA.

the class MethodsRefactoringTest method testAllMethodsSameSignatureFunction.

@Test
public void testAllMethodsSameSignatureFunction() {
    Factory factory = ModelUtils.build(new File("./src/test/java/spoon/test/refactoring/parameter/testclasses"));
    // each executable in test classes is marked with a annotation TestHierarchy,
    // which defines the name of the hierarchy where this executable belongs to.
    // collect all executables which are marked that they belong to hierarchy A_method1
    List<CtExecutable<?>> executablesOfHierarchyA = getExecutablesOfHierarchy(factory, "A_method1");
    // check executables of this hierarchy
    checkMethodHierarchies(executablesOfHierarchyA);
    // collect all executables which are marked that they belong to hierarchy R_method1
    List<CtExecutable<?>> executablesOfHierarchyR = getExecutablesOfHierarchy(factory, "R_method1");
    // check executables of this hierarchy
    checkMethodHierarchies(executablesOfHierarchyR);
    // contract: CtConstructor has no other same signature
    CtConstructor<?> constructorTypeA = factory.Class().get(TypeA.class).getConstructors().iterator().next();
    CtExecutable<?> exec = constructorTypeA.map(new AllMethodsSameSignatureFunction()).first();
    assertNull("Unexpected executable found by Constructor of TypeA " + exec, exec);
    CtConstructor<?> constructorTypeB = factory.Class().get(TypeB.class).getConstructors().iterator().next();
    exec = constructorTypeA.map(new AllMethodsSameSignatureFunction()).first();
    assertNull("Unexpected executable found by Constructor of TypeA " + exec, exec);
    // contract: constructor is returned if includingSelf == true
    assertSame(constructorTypeA, constructorTypeA.map(new AllMethodsSameSignatureFunction().includingSelf(true)).first());
}
Also used : TypeB(spoon.test.refactoring.parameter.testclasses.TypeB) Factory(spoon.reflect.factory.Factory) AllMethodsSameSignatureFunction(spoon.reflect.visitor.filter.AllMethodsSameSignatureFunction) File(java.io.File) CtExecutable(spoon.reflect.declaration.CtExecutable) TypeA(spoon.test.refactoring.parameter.testclasses.TypeA) Test(org.junit.Test)

Aggregations

File (java.io.File)1 Test (org.junit.Test)1 CtExecutable (spoon.reflect.declaration.CtExecutable)1 Factory (spoon.reflect.factory.Factory)1 AllMethodsSameSignatureFunction (spoon.reflect.visitor.filter.AllMethodsSameSignatureFunction)1 TypeA (spoon.test.refactoring.parameter.testclasses.TypeA)1 TypeB (spoon.test.refactoring.parameter.testclasses.TypeB)1