ProgressLog implements Serializable { @Override public String toString() { String result; if (receivedMessagesFailed > 0) { result = String .format("%s: [success:% 4d, failed:% 4d, total:% 4d]", name, receivedMessagesSuccess, receivedMessagesFailed, toReceiveMessages); } else { result = String.format("%s: [success:% 4d, total:% 4d]", name, receivedMessagesSuccess, toReceiveMessages); } return result; } ProgressLog(String name, int receivedMessagesSuccess, int receivedMessagesFailed,
      int toReceiveMessages); @Override String toString();  }
@Test public void toString_withNoFailedMessages_expectMessageWithoutFailed() { ProgressLog progressLog = new ProgressLog("name", 105, 0, 105); assertThat(progressLog.toString(), is("name: [success: 105, total: 105]")); }
@Test public void toString_withFailedMessages_expectMessageWithFailed() { ProgressLog progressLog = new ProgressLog("name", 33, 1, 34); assertThat(progressLog.toString(), is("name: [success: 33, failed: 1, total: 34]")); }