use of org.guvnor.ala.ui.model.RuntimeKey in project kie-wb-common by kiegroup.
the class RuntimePresenterActionsTest method testStopRuntimeConfirmYesAndSuccessful.
@Test
public void testStopRuntimeConfirmYesAndSuccessful() {
prepareRuntimeStop();
RuntimeKey currentKey = runtime.getKey();
when(translationService.format(RuntimePresenter_RuntimeStopSuccessMessage, item.getRuntime().getKey().getId())).thenReturn(SUCCESS_MESSAGE);
when(translationService.getTranslation(RuntimePresenter_RuntimeStoppingMessage)).thenReturn(BUSY_POPUP_MESSAGE);
yesCommandCaptor.getValue().execute();
verify(runtimeService, times(1)).stopRuntime(currentKey);
verify(popupHelper, times(1)).showBusyIndicator(BUSY_POPUP_MESSAGE);
verify(popupHelper, times(1)).hideBusyIndicator();
verify(notificationEvent, times(1)).fire(new NotificationEvent(SUCCESS_MESSAGE, NotificationEvent.NotificationType.SUCCESS));
}
use of org.guvnor.ala.ui.model.RuntimeKey in project kie-wb-common by kiegroup.
the class RuntimePresenterActionsTest method testStartRuntimeFailed.
@Test
public void testStartRuntimeFailed() {
prepareRuntime();
RuntimeKey currentKey = runtime.getKey();
doThrow(new RuntimeException(ERROR_MESSAGE)).when(runtimeService).startRuntime(currentKey);
when(translationService.getTranslation(RuntimePresenter_RuntimeStartingMessage)).thenReturn(BUSY_POPUP_MESSAGE);
presenter.startRuntime();
verify(popupHelper, times(1)).showBusyIndicator(BUSY_POPUP_MESSAGE);
verify(popupHelper, times(1)).hideBusyIndicator();
verify(notificationEvent, times(0)).fire(any(NotificationEvent.class));
verify(defaultErrorCallback, times(1)).error(any(Message.class), exceptionCaptor.capture());
assertEquals(ERROR_MESSAGE, exceptionCaptor.getValue().getCause().getMessage());
}
use of org.guvnor.ala.ui.model.RuntimeKey in project kie-wb-common by kiegroup.
the class RuntimePresenterActionsTest method testDeleteRuntimeConfirmYesAndFailedAndDontForceDeletion.
@Test
public void testDeleteRuntimeConfirmYesAndFailedAndDontForceDeletion() {
prepareRuntimeDelete();
RuntimeKey currentKey = runtime.getKey();
RuntimeException deleteException = new RuntimeException(ERROR_MESSAGE);
// needs to use null instead of ERROR_MESSAGE because of the CallerMock
when(translationService.format(RuntimePresenter_RuntimeDeleteFailedMessage, null)).thenReturn(CONFIRM_MESSAGE_2);
when(translationService.getTranslation(RuntimePresenter_RuntimeDeleteFailedTitle)).thenReturn(TITLE_2);
when(translationService.getTranslation(RuntimePresenter_RuntimeDeletingMessage)).thenReturn(BUSY_POPUP_MESSAGE);
doThrow(deleteException).when(runtimeService).deleteRuntime(currentKey, false);
yesCommandCaptor.getValue().execute();
verify(runtimeService, times(1)).deleteRuntime(currentKey, false);
verify(popupHelper, times(1)).showBusyIndicator(BUSY_POPUP_MESSAGE);
verify(popupHelper, times(1)).hideBusyIndicator();
// dialog asking if forced deletion is wanted
verify(popupHelper, times(1)).showYesNoPopup(eq(TITLE_2), eq(CONFIRM_MESSAGE_2), yesCommandCaptor.capture(), noCommandCaptor.capture());
// say no
noCommandCaptor.getValue().execute();
// forced deletion will never be produced.
verify(runtimeService, never()).deleteRuntime(currentKey, true);
}
use of org.guvnor.ala.ui.model.RuntimeKey in project kie-wb-common by kiegroup.
the class RuntimePresenterActionsTest method testDeleteRuntimeConfirmYesAndSuccessful.
@Test
public void testDeleteRuntimeConfirmYesAndSuccessful() {
prepareRuntimeDelete();
RuntimeKey currentKey = runtime.getKey();
when(translationService.format(RuntimePresenter_RuntimeDeleteSuccessMessage, item.getRuntime().getKey().getId())).thenReturn(SUCCESS_MESSAGE);
when(translationService.getTranslation(RuntimePresenter_RuntimeDeletingMessage)).thenReturn(BUSY_POPUP_MESSAGE);
yesCommandCaptor.getValue().execute();
verify(runtimeService, times(1)).deleteRuntime(currentKey, false);
verify(popupHelper, times(1)).showBusyIndicator(BUSY_POPUP_MESSAGE);
verify(popupHelper, times(1)).hideBusyIndicator();
verify(notificationEvent, times(1)).fire(new NotificationEvent(SUCCESS_MESSAGE, NotificationEvent.NotificationType.SUCCESS));
}
use of org.guvnor.ala.ui.model.RuntimeKey in project kie-wb-common by kiegroup.
the class RuntimePresenterActionsTest method testForceDeleteRuntimeConfirmYesAndFailed.
@Test
public void testForceDeleteRuntimeConfirmYesAndFailed() {
prepareRuntimeForceDelete();
RuntimeKey currentKey = runtime.getKey();
when(translationService.getTranslation(RuntimePresenter_RuntimeDeletingForcedMessage)).thenReturn(BUSY_POPUP_MESSAGE);
doThrow(new RuntimeException(ERROR_MESSAGE)).when(runtimeService).deleteRuntime(currentKey, true);
yesCommandCaptor.getValue().execute();
verify(runtimeService, times(1)).deleteRuntime(currentKey, true);
verify(defaultErrorCallback, times(1)).error(any(Message.class), exceptionCaptor.capture());
assertEquals(ERROR_MESSAGE, exceptionCaptor.getValue().getCause().getMessage());
verify(popupHelper, times(1)).showBusyIndicator(BUSY_POPUP_MESSAGE);
verify(popupHelper, times(1)).hideBusyIndicator();
}
Aggregations