RunnerWidget implements RunnerItems<Runner> { @Override public void update(@NotNull Runner runner) { this.runner = runner; this.runnerStatus = runner.getStatus(); changeRunnerStatusIcon(); itemWidget.setName(runner.getTitle()); itemWidget.setDescription(runner.getRAM() + "MB"); itemWidget.setStartTime(runner.getCreationTime()); } @Inject  RunnerWidget(ItemWidget itemWidget,
                        RunnerResources resources,
                        PartStackUIResources buttonIcons,
                        final SelectionManager selectionManager); @Override void select(); @Override void unSelect(); @Override void update(@NotNull Runner runner); @Override Widget asWidget(); void setDelegate(@NotNull ActionDelegate delegate);  }
@Test public void onMouseOutEventShouldBePerformed() throws Exception { when(runner.getStatus()).thenReturn(IN_PROGRESS); runnerWidget.update(runner); reset(itemWidget); verify(imagePanel).addDomHandler(mouseOutCaptor.capture(), eq(MouseOutEvent.getType())); mouseOutCaptor.getValue().onMouseOut(mouseOutEvent); verify(itemWidget).setImage(any(SVGImage.class)); }
@Test public void imageShouldNotBeSetWhenStatusIsNotFailedOrStopped() throws Exception { when(runner.getStatus()).thenReturn(DONE); runnerWidget.update(runner); reset(itemWidget); verify(imagePanel).addDomHandler(mouseOverCaptor.capture(), eq(MouseOverEvent.getType())); mouseOverCaptor.getValue().onMouseOver(mouseOverEvent); verify(itemWidget, never()).setImage(any(SVGImage.class)); }
@Test public void clickEventShouldBePerformedWhenRunnerStatusIsNotFailedOrStopped() throws Exception { when(runner.getStatus()).thenReturn(DONE); runnerWidget.update(runner); reset(itemWidget); verify(imagePanel).addDomHandler(clickCaptor.capture(), eq(ClickEvent.getType())); clickCaptor.getValue().onClick(clickEvent); verify(delegate, never()).removeRunnerWidget(runner); }
@Test public void shouldUpdateRunnerWithStatusInProgress() { when(runner.getStatus()).thenReturn(IN_PROGRESS); when(css.blueColor()).thenReturn(TEXT); runnerWidget.update(runner); verify(css).blueColor(); shouldUpdateItemWidgetParameter(); }
@Test public void shouldUpdateRunnerWithStatusQueue() { when(runner.getStatus()).thenReturn(Runner.Status.IN_QUEUE); when(css.blueColor()).thenReturn(TEXT); runnerWidget.update(runner); verify(css).yellowColor(); shouldUpdateItemWidgetParameter(); }
@Test public void shouldUpdateRunnerWithStatusFailed() { when(runner.getStatus()).thenReturn(Runner.Status.FAILED); when(css.blueColor()).thenReturn(TEXT); runnerWidget.update(runner); verify(css).redColor(); shouldUpdateItemWidgetParameter(); }
@Test public void shouldUpdateRunnerWithStatusTimeOut() { when(runner.getStatus()).thenReturn(Runner.Status.TIMEOUT); when(css.blueColor()).thenReturn(TEXT); runnerWidget.update(runner); verify(css).whiteColor(); shouldUpdateItemWidgetParameter(); }
@Test public void shouldUpdateRunnerWithStatusStopped() { when(runner.getStatus()).thenReturn(Runner.Status.STOPPED); when(css.blueColor()).thenReturn(TEXT); runnerWidget.update(runner); verify(css).redColor(); shouldUpdateItemWidgetParameter(); }
@Test public void shouldUpdateRunnerWithStatusDone() { when(runner.getStatus()).thenReturn(Runner.Status.DONE); when(css.blueColor()).thenReturn(TEXT); runnerWidget.update(runner); verify(css).greenColor(); shouldUpdateItemWidgetParameter(); }