ValidationResultBuilderImpl implements ValidationResultBuilder { @Override public String toString() { return ValidationUtils.validationResultToString(this); }  @Override ValidationResultBuilder addErrorMessage(final String message); @Override ValidationResultBuilder addErrorMessage(final String message, final Throwable t); @Override boolean isValid(); @Override boolean hasErrors(); @Override List<ErrorMessage> getErrorMessages(); @Override String toString();  }
@Test public void testToString() throws Exception { ValidationResultBuilderImpl validationResultBuilder = new ValidationResultBuilderImpl(); assertThat(ValidationUtils.validationResultToString(validationResultBuilder), is(StringUtils.EMPTY)); validationResultBuilder.addErrorMessage("MSG_1"); assertThat(ValidationUtils.validationResultToString(validationResultBuilder), containsString("1 errors were found")); assertThat(ValidationUtils.validationResultToString(validationResultBuilder), containsString("Message: MSG_1")); validationResultBuilder.addErrorMessage("MSG_2"); assertThat(ValidationUtils.validationResultToString(validationResultBuilder), containsString("2 errors were found")); assertThat(ValidationUtils.validationResultToString(validationResultBuilder), containsString("Message: MSG_1")); assertThat(ValidationUtils.validationResultToString(validationResultBuilder), containsString("Message: MSG_2")); validationResultBuilder.addErrorMessage("MSG_3", new NoSuchFieldException()); assertThat(ValidationUtils.validationResultToString(validationResultBuilder), containsString("3 errors were found")); assertThat(ValidationUtils.validationResultToString(validationResultBuilder), containsString("Message: MSG_1")); assertThat(ValidationUtils.validationResultToString(validationResultBuilder), containsString("Message: MSG_2")); assertThat(ValidationUtils.validationResultToString(validationResultBuilder), containsString("Message: MSG_3")); assertThat(ValidationUtils.validationResultToString(validationResultBuilder), containsString("Caused by: java.lang.NoSuchFieldException")); }