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");
}