Search in sources :

Example 1 with RuntimeKey

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());
}
Also used : Runtime(org.guvnor.ala.ui.model.Runtime) RuntimeListItem(org.guvnor.ala.ui.model.RuntimeListItem) RuntimeKey(org.guvnor.ala.ui.model.RuntimeKey) Test(org.junit.Test)

Example 2 with RuntimeKey

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());
}
Also used : RuntimeListItem(org.guvnor.ala.ui.model.RuntimeListItem) RuntimeKey(org.guvnor.ala.ui.model.RuntimeKey) Test(org.junit.Test)

Example 3 with RuntimeKey

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();
}
Also used : RuntimeKey(org.guvnor.ala.ui.model.RuntimeKey) Test(org.junit.Test)

Example 4 with RuntimeKey

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));
}
Also used : RuntimeKey(org.guvnor.ala.ui.model.RuntimeKey) RuntimeChangeEvent(org.guvnor.ala.ui.events.RuntimeChangeEvent) Test(org.junit.Test)

Example 5 with RuntimeKey

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));
}
Also used : RuntimeKey(org.guvnor.ala.ui.model.RuntimeKey) RuntimeChangeEvent(org.guvnor.ala.ui.events.RuntimeChangeEvent) Test(org.junit.Test)

Aggregations

RuntimeKey (org.guvnor.ala.ui.model.RuntimeKey)24 Test (org.junit.Test)21 RuntimeChangeEvent (org.guvnor.ala.ui.events.RuntimeChangeEvent)9 ProviderKey (org.guvnor.ala.ui.model.ProviderKey)7 RuntimeListItem (org.guvnor.ala.ui.model.RuntimeListItem)5 NotificationEvent (org.uberfire.workbench.events.NotificationEvent)5 RuntimePresenter_PipelineExecutionAlreadyStoppedMessage (org.guvnor.ala.ui.client.resources.i18n.GuvnorAlaUIConstants.RuntimePresenter_PipelineExecutionAlreadyStoppedMessage)3 RuntimePresenter_PipelineExecutionConfirmDeleteMessage (org.guvnor.ala.ui.client.resources.i18n.GuvnorAlaUIConstants.RuntimePresenter_PipelineExecutionConfirmDeleteMessage)3 RuntimePresenter_PipelineExecutionConfirmStopMessage (org.guvnor.ala.ui.client.resources.i18n.GuvnorAlaUIConstants.RuntimePresenter_PipelineExecutionConfirmStopMessage)3 RuntimePresenter_PipelineExecutionDeleteSuccessMessage (org.guvnor.ala.ui.client.resources.i18n.GuvnorAlaUIConstants.RuntimePresenter_PipelineExecutionDeleteSuccessMessage)3 RuntimePresenter_PipelineExecutionStopSuccessMessage (org.guvnor.ala.ui.client.resources.i18n.GuvnorAlaUIConstants.RuntimePresenter_PipelineExecutionStopSuccessMessage)3 RuntimePresenter_RuntimeConfirmDeleteMessage (org.guvnor.ala.ui.client.resources.i18n.GuvnorAlaUIConstants.RuntimePresenter_RuntimeConfirmDeleteMessage)3 RuntimePresenter_RuntimeConfirmForcedDeleteMessage (org.guvnor.ala.ui.client.resources.i18n.GuvnorAlaUIConstants.RuntimePresenter_RuntimeConfirmForcedDeleteMessage)3 RuntimePresenter_RuntimeConfirmStopMessage (org.guvnor.ala.ui.client.resources.i18n.GuvnorAlaUIConstants.RuntimePresenter_RuntimeConfirmStopMessage)3 RuntimePresenter_RuntimeDeleteFailedMessage (org.guvnor.ala.ui.client.resources.i18n.GuvnorAlaUIConstants.RuntimePresenter_RuntimeDeleteFailedMessage)3 RuntimePresenter_RuntimeDeleteSuccessMessage (org.guvnor.ala.ui.client.resources.i18n.GuvnorAlaUIConstants.RuntimePresenter_RuntimeDeleteSuccessMessage)3 RuntimePresenter_RuntimeDeletingForcedMessage (org.guvnor.ala.ui.client.resources.i18n.GuvnorAlaUIConstants.RuntimePresenter_RuntimeDeletingForcedMessage)3 RuntimePresenter_RuntimeDeletingMessage (org.guvnor.ala.ui.client.resources.i18n.GuvnorAlaUIConstants.RuntimePresenter_RuntimeDeletingMessage)3 RuntimePresenter_RuntimeStartSuccessMessage (org.guvnor.ala.ui.client.resources.i18n.GuvnorAlaUIConstants.RuntimePresenter_RuntimeStartSuccessMessage)3 RuntimePresenter_RuntimeStartingMessage (org.guvnor.ala.ui.client.resources.i18n.GuvnorAlaUIConstants.RuntimePresenter_RuntimeStartingMessage)3