ConsoleImpl extends Composite implements Console { @Override public void printInfo(@NotNull String line) { MessageBuilder messageBuilder = messageBuilderProvider.get() .type(INFO) .message(INFO.getPrefix() + ' ' + line); print(messageBuilder.build()); } @Inject  ConsoleImpl(RunnerResources resources,
                       Provider<MessageBuilder> messageBuilderProvider,
                       WidgetFactory widgetFactory,
                       @NotNull @Assisted Runner runner); @Override void print(@NotNull String text); @Override void printInfo(@NotNull String line); @Override void printError(@NotNull String line); @Override void printWarn(@NotNull String line); @Override void scrollBottom(); @Override void clear(); @Override void changeWrapTextParam(); @Override boolean isWrapText();  }
@Test public void infoMessageShouldBePrinted() throws Exception { console.printInfo(SOME_TEXT); verify(console.output).add(any(HTML.class)); verify(messageBuilder).type(INFO); verify(messageBuilder).message(INFO.getPrefix() + ' ' + SOME_TEXT); }
@Test public void messageShouldBeCleanedWhenTheAmountIs1000AndLogUrlIsAbsent() throws Exception { when(console.output.getWidgetCount()).thenReturn(1000); console.printInfo(SOME_TEXT); verify(messageBuilder).type(INFO); verify(messageBuilder).message(INFO.getPrefix() + ' ' + SOME_TEXT); verify(console.output, times(100)).remove(0); verify(console.output, never()).insert(any(HTML.class), eq(0)); verify(console.output).add(any(HTML.class)); }
@Test public void messageShouldBeCleanedWhenTheAmountIs1000AndLogHrefIsAbsent() throws Exception { when(console.output.getWidgetCount()).thenReturn(1000); Link logLink = mock(Link.class); when(runner.getLogUrl()).thenReturn(logLink); console.printInfo(SOME_TEXT); verify(messageBuilder).type(INFO); verify(messageBuilder).message(INFO.getPrefix() + ' ' + SOME_TEXT); verify(console.output, times(100)).remove(0); verify(console.output, never()).insert(any(HTML.class), eq(0)); verify(console.output).add(any(HTML.class)); }
@Test public void messageShouldBeCleanedWhenTheAmountIs1000AndLogUrlIsExist() throws Exception { when(console.output.getWidgetCount()).thenReturn(1000); FullLogMessageWidget messageWidget = mock(FullLogMessageWidget.class); when(widgetFactory.createFullLogMessage(anyString())).thenReturn(messageWidget); Link logLink = mock(Link.class); when(logLink.getHref()).thenReturn(SOME_TEXT); when(runner.getLogUrl()).thenReturn(logLink); console.printInfo(SOME_TEXT); verify(messageBuilder).type(INFO); verify(messageBuilder).message(INFO.getPrefix() + ' ' + SOME_TEXT); verify(widgetFactory).createFullLogMessage(anyString()); verify(console.output, times(100)).remove(0); verify(console.output).insert(messageWidget, 0); verify(console.output).add(any(HTML.class)); }