Search in sources :

Example 1 with SubInheritanceHierarchyFunction

use of spoon.reflect.visitor.filter.SubInheritanceHierarchyFunction in project spoon by INRIA.

the class MethodsRefactoringTest method testSubInheritanceHierarchyFunction.

@Test
public void testSubInheritanceHierarchyFunction() {
    Factory factory = ModelUtils.build(new File("./src/test/java/spoon/test/refactoring/parameter/testclasses"));
    List<String> allSubtypes = factory.Class().get(TypeA.class).map(new SubInheritanceHierarchyFunction()).map((CtType type) -> type.getQualifiedName()).list();
    checkContainsOnly(allSubtypes, "spoon.test.refactoring.parameter.testclasses.TypeB", "spoon.test.refactoring.parameter.testclasses.TypeB$1", "spoon.test.refactoring.parameter.testclasses.TypeC");
    allSubtypes = factory.Class().get(TypeB.class).map(new SubInheritanceHierarchyFunction()).map((CtType type) -> type.getQualifiedName()).list();
    checkContainsOnly(allSubtypes, "spoon.test.refactoring.parameter.testclasses.TypeB$1", "spoon.test.refactoring.parameter.testclasses.TypeC");
    allSubtypes = factory.Class().get(TypeC.class).map(new SubInheritanceHierarchyFunction()).map((CtType type) -> type.getQualifiedName()).list();
    assertEquals(0, allSubtypes.size());
    allSubtypes = factory.Interface().get(IFaceB.class).map(new SubInheritanceHierarchyFunction()).map((CtType type) -> type.getQualifiedName()).list();
    checkContainsOnly(allSubtypes, "spoon.test.refactoring.parameter.testclasses.TypeB", "spoon.test.refactoring.parameter.testclasses.TypeB$1", "spoon.test.refactoring.parameter.testclasses.TypeB$1Local", "spoon.test.refactoring.parameter.testclasses.TypeB$2", "spoon.test.refactoring.parameter.testclasses.TypeC", "spoon.test.refactoring.parameter.testclasses.IFaceL", "spoon.test.refactoring.parameter.testclasses.TypeL", "spoon.test.refactoring.parameter.testclasses.TypeM");
    allSubtypes = factory.Interface().get(IFaceL.class).map(new SubInheritanceHierarchyFunction()).map((CtType type) -> type.getQualifiedName()).list();
    checkContainsOnly(allSubtypes, "spoon.test.refactoring.parameter.testclasses.TypeB$1Local", "spoon.test.refactoring.parameter.testclasses.TypeL", "spoon.test.refactoring.parameter.testclasses.TypeM");
    allSubtypes = factory.Interface().get(IFaceK.class).map(new SubInheritanceHierarchyFunction()).map((CtType type) -> type.getQualifiedName()).list();
    checkContainsOnly(allSubtypes, "spoon.test.refactoring.parameter.testclasses.TypeB$1Local", "spoon.test.refactoring.parameter.testclasses.TypeL", "spoon.test.refactoring.parameter.testclasses.TypeM", "spoon.test.refactoring.parameter.testclasses.TypeK", "spoon.test.refactoring.parameter.testclasses.TypeR", "spoon.test.refactoring.parameter.testclasses.TypeS");
}
Also used : CtType(spoon.reflect.declaration.CtType) Factory(spoon.reflect.factory.Factory) File(java.io.File) SubInheritanceHierarchyFunction(spoon.reflect.visitor.filter.SubInheritanceHierarchyFunction) TypeA(spoon.test.refactoring.parameter.testclasses.TypeA) Test(org.junit.Test)

Aggregations

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