Source:
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", "\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\" is not acceptable to TEAMMATES as " + "a/an my field because it is too long. The value of a/an my field should be no longer than 50 " + "characters. It should not be empty.", validator.getValidityInfoForSizeCappedNonEmptyString( typicalFieldName, maxLength, tooLongName)); String emptyValue = ""; assertEquals("invalid: empty", "\"\" is not acceptable to TEAMMATES as a/an my field because it is empty. The value of a/an my field " + "should be no longer than 50 characters. It should not be empty.", validator.getValidityInfoForSizeCappedNonEmptyString( typicalFieldName, maxLength, emptyValue)); String untrimmedValue = " abc "; assertEquals("invalid: untrimmed", "The provided my field is not acceptable to TEAMMATES as it contains only whitespace or " + "contains extra spaces at the beginning or at the end of the text.", validator.getValidityInfoForSizeCappedNonEmptyString( typicalFieldName, maxLength, untrimmedValue)); }

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", "\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\" is not acceptable to TEAMMATES " + "as a/an my field because it is too long. The value of a/an my field should be no " + "longer than 50 characters. It should not be empty.", validator.getValidityInfoForSizeCappedNonEmptyString(typicalFieldName, maxLength, tooLongName)); String emptyValue = ""; assertEquals("invalid: empty", "\"\" is not acceptable to TEAMMATES as a/an my field because it is empty. The value of " + "a/an my field should be no longer than 50 characters. It should not be empty.", validator.getValidityInfoForSizeCappedNonEmptyString(typicalFieldName, maxLength, emptyValue)); String untrimmedValue = " abc "; assertEquals("invalid: untrimmed", "The provided my field is not acceptable to TEAMMATES as it contains only whitespace or " + "contains extra spaces at the beginning or at the end of the text.", validator.getValidityInfoForSizeCappedNonEmptyString(typicalFieldName, maxLength, untrimmedValue)); }