use of spoon.refactoring.RefactoringException in project spoon by INRIA.
the class MethodsRefactoringTest method testCtParameterRemoveRefactoringValidationCheck.
@Test
public void testCtParameterRemoveRefactoringValidationCheck() throws FileNotFoundException {
String testPackagePath = "spoon/test/refactoring/parameter/testclasses";
final Launcher launcher = new Launcher();
launcher.getEnvironment().setNoClasspath(true);
SpoonModelBuilder comp = launcher.createCompiler();
comp.addInputSource(SpoonResourceHelper.createResource(new File("./src/test/java/" + testPackagePath)));
comp.build();
Factory factory = comp.getFactory();
CtType<?> typeR = factory.Class().get(TypeR.class);
CtMethod<?> methodTypeR_method1 = typeR.getMethodsByName("method1").get(0);
CtParameterRemoveRefactoring refactor = new CtParameterRemoveRefactoring().setTarget(methodTypeR_method1.getParameters().get(0));
refactor.setTarget(methodTypeR_method1.getParameters().get(0));
// check that each to be refactored method has one parameter
List<CtExecutable<?>> execs = refactor.getTargetExecutables();
execs.forEach(exec -> {
// check that each to be modified method has one parameter
assertEquals(1, exec.getParameters().size());
});
// try refactor
try {
refactor.refactor();
fail();
} catch (RefactoringException e) {
this.getClass();
}
}
Aggregations