Source:
public void testGetValidityInfoForSizeCappedNonEmptyString() { String typicalFieldName = "my field"; int typicalLength = 25; try { TestStringHelper.getValidityInfoForSizeCappedNonEmptyString(typicalFieldName, typicalLength, null); signalFailureToDetectException("not expected to be null"); } catch (AssertionError e) { ignoreExpectedException(); } int maxLength = 50; assertEquals("valid: typical value", "", TestStringHelper.getValidityInfoForSizeCappedNonEmptyString( typicalFieldName, maxLength, "Dr. Amy-B s/o O'br, & 2nd \t \n (alias 'JB')")); assertEquals("valid: max length", "", TestStringHelper.getValidityInfoForSizeCappedNonEmptyString( typicalFieldName, maxLength, TestStringHelper.generateStringOfLength(maxLength))); String tooLongName = TestStringHelper.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.", TestStringHelper.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.", TestStringHelper.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.", TestStringHelper.getValidityInfoForSizeCappedNonEmptyString(typicalFieldName, maxLength, untrimmedValue)); }

Target:
public void testGetValidityInfoForSizeCappedNonEmptyString() { String typicalFieldName = "my field"; int typicalLength = 25; try { FieldValidatorExtension.getValidityInfoForSizeCappedNonEmptyString(typicalFieldName, typicalLength, null); signalFailureToDetectException("not expected to be null"); } catch (AssertionError e) { ignoreExpectedException(); } int maxLength = 50; assertEquals("valid: typical value", "", FieldValidatorExtension.getValidityInfoForSizeCappedNonEmptyString( typicalFieldName, maxLength, "Dr. Amy-B s/o O'br, & 2nd \t \n (alias 'JB')")); assertEquals("valid: max length", "", FieldValidatorExtension.getValidityInfoForSizeCappedNonEmptyString( typicalFieldName, maxLength, StringHelperExtension.generateStringOfLength(maxLength))); String tooLongName = StringHelperExtension.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.", FieldValidatorExtension.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.", FieldValidatorExtension.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.", FieldValidatorExtension.getValidityInfoForSizeCappedNonEmptyString(typicalFieldName, maxLength, untrimmedValue)); }