ClientRuntimeErrorPopupPresenter extends ErrorPopupPresenter { public void showMessage( final ClientRuntimeError error) { StringBuilder result = new StringBuilder(DataSetExplorerConstants.INSTANCE.error()); if (error != null) { final String message = error.getMessage(); Throwable t = error.getRootCause(); String localizedMessage = t != null ? t.getLocalizedMessage() : null; result = new StringBuilder(message); if (localizedMessage != null) { result.append(" ").append(DataSetExplorerConstants.INSTANCE.cause()). append(": ").append(localizedMessage); } } showMessage(result.toString()); } @Inject  ClientRuntimeErrorPopupPresenter(View view); void showMessage( final ClientRuntimeError error);  }
@Test public void testShowMessage() throws Exception { final ClientRuntimeError error = mock(ClientRuntimeError.class); final String message = "message"; final Throwable cause = mock(Throwable.class); final String localizedMessage = "localizedMessage"; when(cause.getLocalizedMessage()).thenReturn(localizedMessage); when(error.getMessage()).thenReturn(message); when(error.getRootCause()).thenReturn(cause); presenter.showMessage(error); verify(view, times(1)).showMessage(anyString(), any(Command.class), any(Command.class)); }