@Test public void stringTooLongWithFinalChar() { char finalChar = '\''; String testStr = fillString('x', stringLength + 1); testStr += finalChar; String resultString = constraint.cropKeepFinalCharacter(testStr, finalChar); String ending = "..." + finalChar; assertThat(resultString.length(), is(stringLength + ending.length())); assertThat(resultString, endsWith(ending)); }
public String cropKeepFinalCharacter(String string, char finalChar) { String cropped = crop(string); if ((null == string) || string.equals(cropped)) { return string; } if (cropped.length() == 0) { return cropped; } return cropped + finalChar; }
StringConstraint { public String cropKeepFinalCharacter(String string, char finalChar) { String cropped = crop(string); if ((null == string) || string.equals(cropped)) { return string; } if (cropped.length() == 0) { return cropped; } return cropped + finalChar; } }
StringConstraint { public String cropKeepFinalCharacter(String string, char finalChar) { String cropped = crop(string); if ((null == string) || string.equals(cropped)) { return string; } if (cropped.length() == 0) { return cropped; } return cropped + finalChar; } StringConstraint(Map<String, Object> parameter); }
StringConstraint { public String cropKeepFinalCharacter(String string, char finalChar) { String cropped = crop(string); if ((null == string) || string.equals(cropped)) { return string; } if (cropped.length() == 0) { return cropped; } return cropped + finalChar; } StringConstraint(Map<String, Object> parameter); String crop(String string); Map<String, String[]> crop(final Map<String, String[]> original); String cropKeepFinalCharacter(String string, char finalChar); }
StringConstraint { public String cropKeepFinalCharacter(String string, char finalChar) { String cropped = crop(string); if ((null == string) || string.equals(cropped)) { return string; } if (cropped.length() == 0) { return cropped; } return cropped + finalChar; } StringConstraint(Map<String, Object> parameter); String crop(String string); Map<String, String[]> crop(final Map<String, String[]> original); String cropKeepFinalCharacter(String string, char finalChar);  }