use of org.eclipse.che.ide.ext.java.shared.dto.refactoring.MoveSettings in project che by eclipse.
the class MoveRefactoringSessionTest method testPreviewChanges.
@Test
public void testPreviewChanges() 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);
RefactoringPreview change = manager.getRefactoringPreview(sessionId);
RefactoringChange change1 = new DtoServerImpls.ChangeEnabledStateImpl();
change1.setSessionId(sessionId);
change1.setChangeId(change.getChildrens().get(0).getId());
ChangePreview preview = manager.getChangePreview(change1);
assertThat(preview).isNotNull();
assertThat(preview.getFileName()).isNotNull().isNotEmpty();
assertThat(preview.getOldContent()).isNotNull().isNotEmpty();
assertThat(preview.getNewContent()).isNotNull().isNotEmpty();
}
use of org.eclipse.che.ide.ext.java.shared.dto.refactoring.MoveSettings in project che by eclipse.
the class MoveRefactoringSessionTest method testCtrateMoveChanges.
@Test
public void testCtrateMoveChanges() 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);
ChangeCreationResult change = manager.createChange(sessionId);
assertThat(change).isNotNull();
assertThat(change.isCanShowPreviewPage()).isTrue();
assertThat(change.getStatus().getSeverity()).isEqualTo(RefactoringStatus.OK);
}
use of org.eclipse.che.ide.ext.java.shared.dto.refactoring.MoveSettings in project che by eclipse.
the class MovePresenter method prepareMovingChanges.
private Promise<ChangeCreationResult> prepareMovingChanges(final RefactoringSession session) {
MoveSettings moveSettings = dtoFactory.createDto(MoveSettings.class);
moveSettings.setSessionId(refactoringSessionId);
moveSettings.setUpdateReferences(view.isUpdateReferences());
moveSettings.setUpdateQualifiedNames(view.isUpdateQualifiedNames());
if (moveSettings.isUpdateQualifiedNames()) {
moveSettings.setFilePatterns(view.getFilePatterns());
}
return refactorService.setMoveSettings(moveSettings).thenPromise(new Function<Void, Promise<ChangeCreationResult>>() {
@Override
public Promise<ChangeCreationResult> apply(Void arg) throws FunctionException {
return refactorService.createChange(session);
}
});
}
use of org.eclipse.che.ide.ext.java.shared.dto.refactoring.MoveSettings 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();
}
use of org.eclipse.che.ide.ext.java.shared.dto.refactoring.MoveSettings in project che by eclipse.
the class MoveRefactoringSessionTest method testGetMoveChanges.
@Test
public void testGetMoveChanges() 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);
RefactoringPreview change = manager.getRefactoringPreview(sessionId);
assertThat(change).isNotNull();
assertThat(change.getText()).isEqualTo("Move");
assertThat(change.getChildrens()).isNotNull().hasSize(2);
}
Aggregations