Search in sources :

Example 11 with RefactoringStatus

use of org.eclipse.che.ide.ext.java.shared.dto.refactoring.RefactoringStatus in project che by eclipse.

the class MoveRefactoringSessionTest method testSetMoveDestination.

@Test
public void testSetMoveDestination() throws Exception {
    IType type = fProject.findType("p.A");
    ICompilationUnit unit = type.getCompilationUnit();
    String sessionId = manager.createMoveRefactoringSession(new IJavaElement[] { unit });
    ReorgDestination destination = new DtoServerImpls.ReorgDestinationImpl();
    destination.setSessionId(sessionId);
    destination.setProjectPath(RefactoringTestSetup.getProject().getPath().toOSString());
    destination.setDestination(p1.getPath().toOSString());
    destination.setType(ReorgDestination.DestinationType.PACKAGE);
    RefactoringStatus status = manager.setRefactoringDestination(destination);
    assertThat(status).isNotNull();
    assertThat(status.getSeverity()).isEqualTo(RefactoringStatus.OK);
}
Also used : ICompilationUnit(org.eclipse.jdt.core.ICompilationUnit) RefactoringStatus(org.eclipse.che.ide.ext.java.shared.dto.refactoring.RefactoringStatus) ReorgDestination(org.eclipse.che.ide.ext.java.shared.dto.refactoring.ReorgDestination) IType(org.eclipse.jdt.core.IType) Test(org.junit.Test)

Example 12 with RefactoringStatus

use of org.eclipse.che.ide.ext.java.shared.dto.refactoring.RefactoringStatus in project che by eclipse.

the class MoveRefactoringSessionTest method testApplyMove.

@Test
public void testApplyMove() throws Exception {
    IType type = fProject.findType("p.A");
    ICompilationUnit unit = type.getCompilationUnit();
    String sessionId = manager.createMoveRefactoringSession(new IJavaElement[] { unit });
    ReorgDestination destination = new DtoServerImpls.ReorgDestinationImpl();
    destination.setSessionId(sessionId);
    destination.setProjectPath(RefactoringTestSetup.getProject().getPath().toOSString());
    destination.setDestination(p1.getPath().toOSString());
    destination.setType(ReorgDestination.DestinationType.PACKAGE);
    manager.setRefactoringDestination(destination);
    MoveSettings settings = new DtoServerImpls.MoveSettingsImpl();
    settings.setUpdateReferences(true);
    settings.setSessionId(sessionId);
    manager.setMoveSettings(settings);
    manager.createChange(sessionId);
    RefactoringStatus status = manager.applyRefactoring(sessionId);
    assertThat(status).isNotNull();
    assertThat(status.getSeverity()).isEqualTo(RefactoringStatus.OK);
    IType movedType = fProject.findType("p1.A");
    assertThat(movedType).isNotNull();
    assertThat(movedType.exists()).isTrue();
}
Also used : ICompilationUnit(org.eclipse.jdt.core.ICompilationUnit) RefactoringStatus(org.eclipse.che.ide.ext.java.shared.dto.refactoring.RefactoringStatus) ReorgDestination(org.eclipse.che.ide.ext.java.shared.dto.refactoring.ReorgDestination) MoveSettings(org.eclipse.che.ide.ext.java.shared.dto.refactoring.MoveSettings) IType(org.eclipse.jdt.core.IType) Test(org.junit.Test)

Aggregations

RefactoringStatus (org.eclipse.che.ide.ext.java.shared.dto.refactoring.RefactoringStatus)12 Test (org.junit.Test)9 ICompilationUnit (org.eclipse.jdt.core.ICompilationUnit)7 IType (org.eclipse.jdt.core.IType)7 RenameRefactoringSession (org.eclipse.che.ide.ext.java.shared.dto.refactoring.RenameRefactoringSession)6 DtoServerImpls (org.eclipse.che.plugin.java.server.dto.DtoServerImpls)5 ReorgDestination (org.eclipse.che.ide.ext.java.shared.dto.refactoring.ReorgDestination)3 OperationException (org.eclipse.che.api.promises.client.OperationException)2 ValidateNewName (org.eclipse.che.ide.ext.java.shared.dto.refactoring.ValidateNewName)2 Operation (org.eclipse.che.api.promises.client.Operation)1 PromiseError (org.eclipse.che.api.promises.client.PromiseError)1 ChangeCreationResult (org.eclipse.che.ide.ext.java.shared.dto.refactoring.ChangeCreationResult)1 ChangePreview (org.eclipse.che.ide.ext.java.shared.dto.refactoring.ChangePreview)1 LinkedRenameRefactoringApply (org.eclipse.che.ide.ext.java.shared.dto.refactoring.LinkedRenameRefactoringApply)1 MoveSettings (org.eclipse.che.ide.ext.java.shared.dto.refactoring.MoveSettings)1 RefactoringChange (org.eclipse.che.ide.ext.java.shared.dto.refactoring.RefactoringChange)1 RefactoringPreview (org.eclipse.che.ide.ext.java.shared.dto.refactoring.RefactoringPreview)1 RenameSettings (org.eclipse.che.ide.ext.java.shared.dto.refactoring.RenameSettings)1 IPackageFragment (org.eclipse.jdt.core.IPackageFragment)1