use of org.eclipse.che.ide.ext.java.shared.dto.refactoring.RenameRefactoringSession in project che by eclipse.
the class RenameRefactoringTest method testApplyLinkedRename.
@Test
public void testApplyLinkedRename() 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"), true);
assertThat(refactoring).isNotNull();
assertThat(refactoring.getSessionId()).isNotNull().isNotEmpty();
LinkedRenameRefactoringApply apply = new DtoServerImpls.LinkedRenameRefactoringApplyImpl();
apply.setSessionId(refactoring.getSessionId());
apply.setNewName("Test");
RefactoringStatus status = manager.applyLinkedRename(apply);
assertThat(status).isNotNull();
assertThat(status.getSeverity()).isEqualTo(RefactoringStatus.OK);
assertThat(unit.exists()).isFalse();
ICompilationUnit newUnit = getPackageP().getCompilationUnit("Test.java");
assertThat(newUnit.exists()).isTrue();
}
use of org.eclipse.che.ide.ext.java.shared.dto.refactoring.RenameRefactoringSession in project che by eclipse.
the class RenameRefactoringTest method testRenameValidateName.
@Test
public void testRenameValidateName() 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("MyClass");
RefactoringStatus status = manager.renameValidateNewName(validateNewName);
assertThat(status).isNotNull();
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 testCreateLinkedRename.
@Test
public void testCreateLinkedRename() 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"), true);
assertThat(refactoring).isNotNull();
assertThat(refactoring.getSessionId()).isNotNull().isNotEmpty();
assertThat(refactoring.getLinkedModeModel()).isNotNull();
}
use of org.eclipse.che.ide.ext.java.shared.dto.refactoring.RenameRefactoringSession in project che by eclipse.
the class RenameRefactoringTest method testRenamePackageAlwaysWithWizard.
@Test
public void testRenamePackageAlwaysWithWizard() 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);
RenameRefactoringSession refactoring = manager.createRenameRefactoring(getPackageP(), unit, b.indexOf("p;"), true);
assertThat(refactoring).isNotNull();
assertThat(refactoring.getSessionId()).isNotNull().isNotEmpty();
assertThat(refactoring.getLinkedModeModel()).isNull();
assertThat(refactoring.getWizardType()).isEqualTo(RenameRefactoringSession.RenameWizard.PACKAGE);
}
use of org.eclipse.che.ide.ext.java.shared.dto.refactoring.RenameRefactoringSession in project che by eclipse.
the class RenameRefactoringTest method testDoRename.
@Test
public void testDoRename() 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("MyClass");
manager.renameValidateNewName(validateNewName);
RenameSettings settings = new DtoServerImpls.RenameSettingsImpl();
settings.setSessionId(refactoring.getSessionId());
settings.setDeprecateDelegates(true);
settings.setUpdateReferences(true);
manager.setRenameSettings(settings);
ChangeCreationResult change = manager.createChange(refactoring.getSessionId());
assertThat(change).isNotNull();
RefactoringStatus applyRefactoring = manager.applyRefactoring(refactoring.getSessionId());
assertThat(applyRefactoring).isNotNull();
assertThat(applyRefactoring.getSeverity()).isEqualTo(RefactoringStatus.OK);
assertThat(unit.exists()).isFalse();
ICompilationUnit newUnit = getPackageP().getCompilationUnit("MyClass.java");
assertThat(newUnit.exists()).isTrue();
}
Aggregations