use of org.guvnor.ala.ui.model.RuntimeKey in project kie-wb-common by kiegroup.
the class ProviderStatusPresenterTest method testRemoveExistingRuntime.
@Test
public void testRemoveExistingRuntime() {
RuntimeKey keyToRemove = mock(RuntimeKey.class);
List<RuntimeListItem> items = mockItems(ITEMS_COUNT);
// pick an arbitrary element as the existing runtime.
int index = 1;
RuntimeListItem item = items.get(index);
Runtime runtime = mock(Runtime.class);
when(runtime.getKey()).thenReturn(keyToRemove);
when(item.isRuntime()).thenReturn(true);
when(item.getRuntime()).thenReturn(runtime);
presenter.setupItems(items);
for (int i = 0; i < ITEMS_COUNT; i++) {
when(runtimePresenters.get(i).getItem()).thenReturn(items.get(i));
}
assertTrue(presenter.removeItem(keyToRemove));
verify(runtimePresenterInstance, times(1)).destroy(runtimePresenters.get(index));
verify(view, times(1)).removeListItem(runtimePresenters.get(index).getView());
}
use of org.guvnor.ala.ui.model.RuntimeKey in project kie-wb-common by kiegroup.
the class ProviderStatusPresenterTest method testRemoveNonExistingRuntime.
@Test
public void testRemoveNonExistingRuntime() {
RuntimeKey keyToRemove = mock(RuntimeKey.class);
List<RuntimeListItem> items = mockItems(ITEMS_COUNT);
presenter.setupItems(items);
for (int i = 0; i < ITEMS_COUNT; i++) {
when(runtimePresenters.get(i).getItem()).thenReturn(items.get(i));
}
assertFalse(presenter.removeItem(keyToRemove));
verify(runtimePresenterInstance, never()).destroy(anyObject());
verify(view, never()).removeListItem(anyObject());
}
use of org.guvnor.ala.ui.model.RuntimeKey in project kie-wb-common by kiegroup.
the class RuntimePresenterActionsTest method testDeleteRuntimeConfirmYesAndFailedAndForceDeletion.
@Test
public void testDeleteRuntimeConfirmYesAndFailedAndForceDeletion() {
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_RuntimeConfirmForcedDeleteTitle)).thenReturn(TITLE_3);
when(translationService.getTranslation(RuntimePresenter_RuntimeConfirmForcedDeleteMessage)).thenReturn(CONFIRM_MESSAGE_3);
when(translationService.getTranslation(RuntimePresenter_RuntimeDeletingMessage)).thenReturn(BUSY_POPUP_MESSAGE);
when(translationService.getTranslation(RuntimePresenter_RuntimeDeletingForcedMessage)).thenReturn(BUSY_POPUP_MESSAGE_2);
doThrow(deleteException).when(runtimeService).deleteRuntime(currentKey, false);
yesCommandCaptor.getValue().execute();
verify(runtimeService, times(1)).deleteRuntime(currentKey, false);
// dialog asking if forced deletion is wanted
verify(popupHelper, times(1)).showYesNoPopup(eq(TITLE_2), eq(CONFIRM_MESSAGE_2), yesCommandCaptor.capture(), noCommandCaptor.capture());
// say yes
yesCommandCaptor.getValue().execute();
// last dialog confirming the forced deletion
verify(popupHelper, times(1)).showYesNoPopup(eq(TITLE_3), eq(CONFIRM_MESSAGE_3), yesCommandCaptor.capture(), noCommandCaptor.capture());
yesCommandCaptor.getValue().execute();
// forced deletion will be produced.
verify(runtimeService, times(1)).deleteRuntime(currentKey, true);
verify(popupHelper, times(1)).showBusyIndicator(BUSY_POPUP_MESSAGE);
verify(popupHelper, times(1)).showBusyIndicator(BUSY_POPUP_MESSAGE_2);
verify(popupHelper, times(2)).hideBusyIndicator();
}
use of org.guvnor.ala.ui.model.RuntimeKey in project kie-wb-common by kiegroup.
the class RuntimePresenterActionsTest method testOnOtherRuntimeStarted.
@Test
public void testOnOtherRuntimeStarted() {
prepareRuntime();
RuntimeKey otherKey = mock(RuntimeKey.class);
presenter.onRuntimeChangeEvent(new RuntimeChangeEvent(RuntimeChange.STARTED, otherKey));
verify(presenter, never()).refresh(any(RuntimeKey.class));
}
use of org.guvnor.ala.ui.model.RuntimeKey in project kie-wb-common by kiegroup.
the class RuntimePresenterActionsTest method testOnOtherRuntimeStopped.
@Test
public void testOnOtherRuntimeStopped() {
prepareRuntime();
RuntimeKey otherKey = mock(RuntimeKey.class);
presenter.onRuntimeChangeEvent(new RuntimeChangeEvent(RuntimeChange.STOPPED, otherKey));
verify(presenter, never()).refresh(any(RuntimeKey.class));
}
Aggregations