Search in sources :

Example 1 with RefactorInfo

use of org.eclipse.che.ide.ext.java.client.refactoring.RefactorInfo in project che by eclipse.

the class RenamePresenterTest method wizardShouldNotBeShowIfRenameRefactoringObjectWasNotCreated.

@Test
public void wizardShouldNotBeShowIfRenameRefactoringObjectWasNotCreated() throws Exception {
    RefactorInfo refactorInfo = RefactorInfo.of(MoveType.REFACTOR_MENU, RefactoredItemType.COMPILATION_UNIT, new Resource[] { file });
    renamePresenter.show(refactorInfo);
    verify(createRenameRefactoringDto).setRefactorLightweight(false);
    verify(createRenameRefactoringDto).setPath(anyString());
    verify(createRenameRefactoringDto).setType(COMPILATION_UNIT);
    verify(createRenameRefactoringDto).setProjectPath(eq("/project"));
    verify(refactorService).createRenameRefactoring(createRenameRefactoringDto);
    verify(renameRefactoringSessionPromise).catchError(promiseErrorCaptor.capture());
    promiseErrorCaptor.getValue().apply(promiseError);
    verify(notificationManager).notify(anyString(), anyString(), any(StatusNotification.Status.class), any(DisplayMode.class));
}
Also used : RefactoringStatus(org.eclipse.che.ide.ext.java.shared.dto.refactoring.RefactoringStatus) DisplayMode(org.eclipse.che.ide.api.notification.StatusNotification.DisplayMode) RefactorInfo(org.eclipse.che.ide.ext.java.client.refactoring.RefactorInfo) Test(org.junit.Test)

Example 2 with RefactorInfo

use of org.eclipse.che.ide.ext.java.client.refactoring.RefactorInfo in project che by eclipse.

the class RenamePresenterTest method changesShouldBeAppliedWithOkStatus.

@Test
public void changesShouldBeAppliedWithOkStatus() throws Exception {
    RefactorInfo refactorInfo = RefactorInfo.of(MoveType.REFACTOR_MENU, RefactoredItemType.COMPILATION_UNIT, new Resource[] { file });
    List<ChangeInfo> changes = new ArrayList<>();
    when(refactoringStatus.getChanges()).thenReturn(changes);
    when(changeCreationResult.isCanShowPreviewPage()).thenReturn(true);
    when(refactoringStatus.getSeverity()).thenReturn(0);
    renamePresenter.show(refactorInfo);
    verify(refactorService).createRenameRefactoring(createRenameRefactoringDto);
    verify(renameRefactoringSessionPromise).then(renameRefactoringSessionCaptor.capture());
    renameRefactoringSessionCaptor.getValue().apply(session);
    renamePresenter.onAcceptButtonClicked();
    verify(refactoringSession).setSessionId(SESSION_ID);
    verifyPreparingRenameSettingsDto();
    verifyPreparingRenameChanges();
    verify(changeCreationResultPromise).then(changeCreationResultCaptor.capture());
    changeCreationResultCaptor.getValue().apply(changeCreationResult);
    verify(refactorService).applyRefactoring(refactoringSession);
    verify(refactoringStatusPromise).then(refactoringStatusCaptor.capture());
    refactoringStatusCaptor.getValue().apply(refactoringStatus);
    verify(refactoringStatus, times(2)).getSeverity();
    verify(view).hide();
    verify(refactoringUpdater).updateAfterRefactoring(changes);
}
Also used : ChangeInfo(org.eclipse.che.ide.ext.java.shared.dto.refactoring.ChangeInfo) ArrayList(java.util.ArrayList) RefactorInfo(org.eclipse.che.ide.ext.java.client.refactoring.RefactorInfo) Test(org.junit.Test)

Example 3 with RefactorInfo

use of org.eclipse.che.ide.ext.java.client.refactoring.RefactorInfo in project che by eclipse.

the class RenamePresenterTest method renameCompilationUnitWizardShouldBeShowCompilationUnit.

@Test
public void renameCompilationUnitWizardShouldBeShowCompilationUnit() throws Exception {
    when(session.getWizardType()).thenReturn(RenameRefactoringSession.RenameWizard.COMPILATION_UNIT);
    RefactorInfo refactorInfo = RefactorInfo.of(MoveType.REFACTOR_MENU, RefactoredItemType.COMPILATION_UNIT, new Resource[] { file });
    renamePresenter.show(refactorInfo);
    verifyPreparingRenameRefactoringDto();
    verify(refactorService).createRenameRefactoring(createRenameRefactoringDto);
    verify(renameRefactoringSessionPromise).then(renameRefactoringSessionCaptor.capture());
    renameRefactoringSessionCaptor.getValue().apply(session);
    verifyPreparingWizard();
    verify(locale).renameCompilationUnitTitle();
    verify(view).setTitle(anyString());
    verify(view).setVisiblePatternsPanel(true);
    verify(view).setVisibleFullQualifiedNamePanel(true);
    verify(view).setVisibleSimilarlyVariablesPanel(true);
    verify(view).show();
}
Also used : RefactorInfo(org.eclipse.che.ide.ext.java.client.refactoring.RefactorInfo) Test(org.junit.Test)

Example 4 with RefactorInfo

use of org.eclipse.che.ide.ext.java.client.refactoring.RefactorInfo in project che by eclipse.

the class RenamePresenterTest method renameLocalVariableWizardShouldBeShow.

@Test
public void renameLocalVariableWizardShouldBeShow() throws Exception {
    RefactorInfo refactorInfo = RefactorInfo.of(MoveType.REFACTOR_MENU, RefactoredItemType.COMPILATION_UNIT, new Resource[] { file });
    renamePresenter.show(refactorInfo);
    verifyPreparingRenameRefactoringDto();
    verify(refactorService).createRenameRefactoring(createRenameRefactoringDto);
    verify(renameRefactoringSessionPromise).then(renameRefactoringSessionCaptor.capture());
    renameRefactoringSessionCaptor.getValue().apply(session);
    verifyPreparingWizard();
    verify(locale).renameLocalVariableTitle();
    verify(view).setTitle(anyString());
    verify(view).show();
}
Also used : RefactorInfo(org.eclipse.che.ide.ext.java.client.refactoring.RefactorInfo) Test(org.junit.Test)

Example 5 with RefactorInfo

use of org.eclipse.che.ide.ext.java.client.refactoring.RefactorInfo in project che by eclipse.

the class RenamePresenterTest method renameTypeParameterWizardShouldBeShow.

@Test
public void renameTypeParameterWizardShouldBeShow() throws Exception {
    when(session.getWizardType()).thenReturn(RenameRefactoringSession.RenameWizard.TYPE_PARAMETER);
    RefactorInfo refactorInfo = RefactorInfo.of(MoveType.REFACTOR_MENU, RefactoredItemType.COMPILATION_UNIT, new Resource[] { file });
    renamePresenter.show(refactorInfo);
    verifyPreparingRenameRefactoringDto();
    verify(refactorService).createRenameRefactoring(createRenameRefactoringDto);
    verify(renameRefactoringSessionPromise).then(renameRefactoringSessionCaptor.capture());
    renameRefactoringSessionCaptor.getValue().apply(session);
    verifyPreparingWizard();
    verify(locale).renameTypeVariableTitle();
    verify(view).setTitle(anyString());
    verify(view).show();
}
Also used : RefactorInfo(org.eclipse.che.ide.ext.java.client.refactoring.RefactorInfo) Test(org.junit.Test)

Aggregations

RefactorInfo (org.eclipse.che.ide.ext.java.client.refactoring.RefactorInfo)11 Test (org.junit.Test)11 ChangeInfo (org.eclipse.che.ide.ext.java.shared.dto.refactoring.ChangeInfo)2 ArrayList (java.util.ArrayList)1 DisplayMode (org.eclipse.che.ide.api.notification.StatusNotification.DisplayMode)1 RefactoringStatus (org.eclipse.che.ide.ext.java.shared.dto.refactoring.RefactoringStatus)1