use of org.eclipse.che.ide.ext.java.shared.dto.refactoring.RenameRefactoringSession in project che by eclipse.
the class RenameRefactoringTest method testCreateRename.
@Test
public void testCreateRename() throws Exception {
StringBuilder b = new StringBuilder();
b.append("package p;\n");
b.append("public class A{}\n");
ICompilationUnit unit = getPackageP().createCompilationUnit("A.java", b.toString(), false, null);
IType type = unit.getAllTypes()[0];
RenameRefactoringSession refactoring = manager.createRenameRefactoring(type, unit, b.indexOf("A"), false);
assertThat(refactoring).isNotNull();
assertThat(refactoring.getSessionId()).isNotNull().isNotEmpty();
assertThat(refactoring.getLinkedModeModel()).isNull();
assertThat(refactoring.getWizardType()).isEqualTo(RenameRefactoringSession.RenameWizard.TYPE);
}
use of org.eclipse.che.ide.ext.java.shared.dto.refactoring.RenameRefactoringSession in project che by eclipse.
the class RenameRefactoringTest method testRenamePackage.
@Test
public void testRenamePackage() throws Exception {
final IPackageFragment packageFragment = getRoot().createPackageFragment("p.a.b.c", true, null);
RenameRefactoringSession refactoring = manager.createRenameRefactoring(packageFragment, null, -1, false);
assertThat(refactoring).isNotNull();
assertThat(refactoring.getSessionId()).isNotNull().isNotEmpty();
final ValidateNewName validateNewName = new DtoServerImpls.ValidateNewNameImpl().withNewName("p.x.s.z");
validateNewName.setSessionId(refactoring.getSessionId());
final RefactoringStatus status = manager.renameValidateNewName(validateNewName);
assertThat(status.getSeverity()).isEqualTo(RefactoringStatus.OK);
}
use of org.eclipse.che.ide.ext.java.shared.dto.refactoring.RenameRefactoringSession in project che by eclipse.
the class RenameRefactoringTest method testRenameValidateInvalidName.
@Test
public void testRenameValidateInvalidName() throws Exception {
StringBuilder b = new StringBuilder();
b.append("package p;\n");
b.append("public class A{}\n");
ICompilationUnit unit = getPackageP().createCompilationUnit("A.java", b.toString(), false, null);
IType type = unit.getAllTypes()[0];
RenameRefactoringSession refactoring = manager.createRenameRefactoring(type, unit, b.indexOf("A"), false);
DtoServerImpls.ValidateNewNameImpl validateNewName = new DtoServerImpls.ValidateNewNameImpl();
validateNewName.setSessionId(refactoring.getSessionId());
validateNewName.setNewName("My#Class");
RefactoringStatus status = manager.renameValidateNewName(validateNewName);
assertThat(status).isNotNull();
assertThat(status.getSeverity()).isEqualTo(RefactoringStatus.FATAL);
}
Aggregations