### Question:
NotificationPresenter { public void setup(final Message message) { checkNotNull("message", message); final NotificationType notificationType = toNotificationType(message.getSeverity()); if (notificationType.equals(NotificationType.OK)) { view.setupOk(); } else { if (message.getMessages().isEmpty()) { view.setup(notificationType, "0"); } else { final StringBuilder sb = new StringBuilder(); int i = 0; for (final String msg : message.getMessages()) { if (!msg.trim().isEmpty()) { i++; sb.append(i).append(": ").append(msg).append('\n'); } } view.setup(notificationType, String.valueOf(i), clean(sb)); } } } @Inject  NotificationPresenter(final View view); View getView(); void setupOk(); void setup(final Message message);  }### Answer:
@Test public void testSetup() { presenter.setupOk(); verify( view ).setupOk(); }
@Test public void testSetupEmptyMessage() { final Message message = new Message(); message.setSeverity( Severity.ERROR ); presenter.setup( message ); verify( view ).setup( NotificationType.ERROR, "0" ); }
@Test public void testSetupSingleMessage() { final Message message = new Message( Severity.ERROR, "single error" ); presenter.setup( message ); verify( view ).setup( NotificationType.ERROR, "1", "1: single error" ); }
@Test public void testSetupSingleEmptyMessage() { final Message message = new Message( Severity.ERROR, "" ); presenter.setup( message ); verify( view ).setup( NotificationType.ERROR, "0", "" ); }
@Test public void testSetupMultiMessage() { final Message message = new Message( Severity.WARN, Arrays.asList( "first error", "second error" ) ); presenter.setup( message ); verify( view ).setup( NotificationType.WARNING, "2", "1: first error\n2: second error" ); }