@Test public void stringLengthOf0WithFinalChar() { char finalChar = '\''; parameter.put("stringLength", String.valueOf(0)); StringConstraint constr = new StringConstraint(parameter); String testStr = finalChar + fillString('x', 50) + finalChar; String resultString = constr.cropKeepFinalCharacter(testStr, finalChar); assertThat(resultString, isEmptyString()); }
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);  }