private void preparePipeline() { trace = mockPipelineExecutionTrace(EXECUTION_ID, mockPipeline(PIPELINE_NAME, STAGE_NUMBER), mock(PipelineStatus.class), mock(PipelineStatus.class)); item = new RuntimeListItem(RUNTIME_NAME, trace); presenter.setup(item); } }
private void prepareRuntime() { runtime = mockRuntime(); item = new RuntimeListItem(RUNTIME_NAME, runtime); presenter.setup(item); }
private void preparePipelineStop() { preparePipeline(); when(translationService.getTranslation(RuntimePresenter_PipelineExecutionConfirmStopTitle)).thenReturn(TITLE); when(translationService.getTranslation(RuntimePresenter_PipelineExecutionConfirmStopMessage)).thenReturn(CONFIRM_MESSAGE); presenter.stopPipeline(); verify(popupHelper, times(1)).showYesNoPopup(eq(TITLE), eq(CONFIRM_MESSAGE), yesCommandCaptor.capture(), noCommandCaptor.capture()); }
private void prepareRuntimeDelete() { prepareRuntime(); when(translationService.getTranslation(RuntimePresenter_RuntimeConfirmDeleteTitle)).thenReturn(TITLE); when(translationService.getTranslation(RuntimePresenter_RuntimeConfirmDeleteMessage)).thenReturn(CONFIRM_MESSAGE); presenter.deleteRuntime(); verify(popupHelper, times(1)).showYesNoPopup(eq(TITLE), eq(CONFIRM_MESSAGE), yesCommandCaptor.capture(), noCommandCaptor.capture()); }
@Test public void testDeleteRuntimeConfirmNo() { prepareRuntimeDelete(); noCommandCaptor.getValue().execute(); verify(runtimeService, never()).deleteRuntime(any(RuntimeKey.class), anyBoolean()); }
@Test public void testStopPipelineConfirmNo() { preparePipelineStop(); noCommandCaptor.getValue().execute(); verify(runtimeService, never()).stopPipelineExecution(any(PipelineExecutionTraceKey.class)); }
@Test public void testForceDeleteRuntimeConfirmNo() { prepareRuntimeForceDelete(); noCommandCaptor.getValue().execute(); verify(runtimeService, never()).deleteRuntime(any(RuntimeKey.class), anyBoolean()); }
@Test public void testDeletePipelineConfirmNo() { preparePipelineDelete(); noCommandCaptor.getValue().execute(); verify(runtimeService, never()).deletePipelineExecution(any(PipelineExecutionTraceKey.class)); }
@Test public void testOnOtherPipelineExecutionStopped() { preparePipelineExecutionTraceSetup(); PipelineExecutionTraceKey otherKey = mock(PipelineExecutionTraceKey.class); RuntimeListItem item = new RuntimeListItem(RUNTIME_NAME, trace); presenter.setup(item); presenter.onPipelineExecutionChange(new PipelineExecutionChangeEvent(PipelineExecutionChange.STOPPED, otherKey)); verify(presenter, never()).refresh(any(PipelineExecutionTraceKey.class)); }
private void prepareRuntimeDelete() { prepareRuntime(); when(translationService.getTranslation(RuntimePresenter_RuntimeConfirmDeleteTitle)).thenReturn(TITLE); when(translationService.getTranslation(RuntimePresenter_RuntimeConfirmDeleteMessage)).thenReturn(CONFIRM_MESSAGE); presenter.deleteRuntime(); verify(popupHelper, times(1)).showYesNoPopup(eq(TITLE), eq(CONFIRM_MESSAGE), yesCommandCaptor.capture(), noCommandCaptor.capture()); }
@Test public void testDeleteRuntimeConfirmNo() { prepareRuntimeDelete(); noCommandCaptor.getValue().execute(); verify(runtimeService, never()).deleteRuntime(any(RuntimeKey.class), anyBoolean()); }
@Test public void testStopPipelineConfirmNo() { preparePipelineStop(); noCommandCaptor.getValue().execute(); verify(runtimeService, never()).stopPipelineExecution(any(PipelineExecutionTraceKey.class)); }
@Test public void testForceDeleteRuntimeConfirmNo() { prepareRuntimeForceDelete(); noCommandCaptor.getValue().execute(); verify(runtimeService, never()).deleteRuntime(any(RuntimeKey.class), anyBoolean()); }
@Test public void testDeletePipelineConfirmNo() { preparePipelineDelete(); noCommandCaptor.getValue().execute(); verify(runtimeService, never()).deletePipelineExecution(any(PipelineExecutionTraceKey.class)); }
@Test public void testOnOtherPipelineExecutionStopped() { preparePipelineExecutionTraceSetup(); PipelineExecutionTraceKey otherKey = mock(PipelineExecutionTraceKey.class); RuntimeListItem item = new RuntimeListItem(RUNTIME_NAME, trace); presenter.setup(item); presenter.onPipelineExecutionChange(new PipelineExecutionChangeEvent(PipelineExecutionChange.STOPPED, otherKey)); verify(presenter, never()).refresh(any(PipelineExecutionTraceKey.class)); }
private void prepareRuntimeForceDelete() { prepareRuntime(); when(translationService.getTranslation(RuntimePresenter_RuntimeConfirmForcedDeleteTitle)).thenReturn(TITLE); when(translationService.getTranslation(RuntimePresenter_RuntimeConfirmForcedDeleteMessage)).thenReturn(CONFIRM_MESSAGE); presenter.forceDeleteRuntime(); verify(popupHelper, times(1)).showYesNoPopup(eq(TITLE), eq(CONFIRM_MESSAGE), yesCommandCaptor.capture(), noCommandCaptor.capture()); }
private void preparePipeline() { trace = mockPipelineExecutionTrace(EXECUTION_ID, mockPipeline(PIPELINE_NAME, STAGE_NUMBER), mock(PipelineStatus.class), mock(PipelineStatus.class)); item = new RuntimeListItem(RUNTIME_NAME, trace); presenter.setup(item); } }
@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)); }
@Test public void testStopPipelineConfirmYesAndFailed() { preparePipelineStop(); PipelineExecutionTraceKey currentKey = trace.getKey(); doThrow(new RuntimeException(ERROR_MESSAGE)) .when(runtimeService) .stopPipelineExecution(currentKey); yesCommandCaptor.getValue().execute(); verify(runtimeService, times(1)).stopPipelineExecution(currentKey); verify(defaultErrorCallback, times(1)).error(any(Message.class), exceptionCaptor.capture()); assertEquals(ERROR_MESSAGE, exceptionCaptor.getValue().getMessage()); }
@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().getMessage()); verify(popupHelper, times(1)).showBusyIndicator(BUSY_POPUP_MESSAGE); verify(popupHelper, times(1)).hideBusyIndicator(); }