Source:
<code>public void testGetValidityInfoForSizeCappedNonEmptyString() { String typicalFieldName = "my field"; int typicalLength = 25; try { validator.getValidityInfoForSizeCappedNonEmptyString(typicalFieldName, typicalLength, null); signalFailureToDetectException("not expected to be null"); } catch (AssertionError e) { ignoreExpectedException(); } int maxLength = 50; assertEquals("valid: typical value", "", validator.getValidityInfoForSizeCappedNonEmptyString( typicalFieldName, maxLength, "Dr. Amy-B s/o O'br, & 2nd \t \n (alias 'JB')")); assertEquals("valid: max length", "", validator.getValidityInfoForSizeCappedNonEmptyString( typicalFieldName, maxLength, StringHelper.generateStringOfLength(maxLength))); String tooLongName = StringHelper.generateStringOfLength(maxLength+1); assertEquals("invalid: too long", String.format( SIZE_CAPPED_NON_EMPTY_STRING_ERROR_MESSAGE, tooLongName, typicalFieldName, REASON_TOO_LONG, typicalFieldName, maxLength), validator.getValidityInfoForSizeCappedNonEmptyString( typicalFieldName, maxLength, tooLongName)); String emptyValue = ""; assertEquals("invalid: empty", String.format( SIZE_CAPPED_NON_EMPTY_STRING_ERROR_MESSAGE, emptyValue, typicalFieldName, REASON_EMPTY, typicalFieldName, maxLength), validator.getValidityInfoForSizeCappedNonEmptyString( typicalFieldName, maxLength, emptyValue)); String untrimmedValue = " abc "; <START> assertEquals("invalid: untrimmed","", <END> validator.getValidityInfoForSizeCappedNonEmptyString( typicalFieldName, maxLength, untrimmedValue)); }</code><technical_language>If revert original FieldValidator, test too. In case, new test sense. "" is untrimmed value, is empty value</technical_language>

Target:
public void testGetValidityInfoForSizeCappedNonEmptyString() { String typicalFieldName = "my field"; int typicalLength = 25; try { validator.getValidityInfoForSizeCappedNonEmptyString(typicalFieldName, typicalLength, null); signalFailureToDetectException("not expected to be null"); } catch (AssertionError e) { ignoreExpectedException(); } int maxLength = 50; assertEquals("valid: typical value", "", validator.getValidityInfoForSizeCappedNonEmptyString( typicalFieldName, maxLength, "Dr. Amy-B s/o O'br, & 2nd \t \n (alias 'JB')")); assertEquals("valid: max length", "", validator.getValidityInfoForSizeCappedNonEmptyString( typicalFieldName, maxLength, StringHelper.generateStringOfLength(maxLength))); String tooLongName = StringHelper.generateStringOfLength(maxLength+1); assertEquals("invalid: too long", String.format( SIZE_CAPPED_NON_EMPTY_STRING_ERROR_MESSAGE, tooLongName, typicalFieldName, REASON_TOO_LONG, typicalFieldName, maxLength), validator.getValidityInfoForSizeCappedNonEmptyString( typicalFieldName, maxLength, tooLongName)); String emptyValue = ""; assertEquals("invalid: empty", String.format( SIZE_CAPPED_NON_EMPTY_STRING_ERROR_MESSAGE, emptyValue, typicalFieldName, REASON_EMPTY, typicalFieldName, maxLength), validator.getValidityInfoForSizeCappedNonEmptyString( typicalFieldName, maxLength, emptyValue)); String untrimmedValue = " abc "; assertEquals("invalid: untrimmed", String.format(WHITESPACE_ONLY_OR_EXTRA_WHITESPACE_ERROR_MESSAGE, typicalFieldName), validator.getValidityInfoForSizeCappedNonEmptyString( typicalFieldName, maxLength, untrimmedValue)); }