@Test public void cropStringMapNoCropping() { constraint = new StringConstraint(Collections.<String, Object> singletonMap("stringLength", "20")); final String param1 = "p1"; final String param2 = "p2"; final String param3 = "p3"; final String param1VReal = "value"; final String param2VReal1 = "value5"; final String param2VReal2 = "value6"; final String param3VReal1 = "value7"; final String param3VReal2 = "value8"; final String[] param1V = new String[] { param1VReal }; final String[] param2V = new String[] { param2VReal1, param2VReal2 }; final String[] param3V = new String[] { param3VReal1, param3VReal2 }; final Map<String, String[]> parameterMap = new HashMap<String, String[]>(); MapUtils.putAll(parameterMap, new Object[][] { { param1, param1V }, { param2, param2V }, { param3, param3V } }); Map<String, String[]> result = constraint.crop(parameterMap); assertThat(result.size(), is(equalTo(parameterMap.size()))); assertThat("Same compared by ObjectUtils", ObjectUtils.equals(result, parameterMap)); assertThat(result.get(param1), is(param1V)); assertThat(result.get(param2), is(param2V)); assertThat(result.get(param3), is(param3V)); assertThat(result.get(param1)[0], is(param1VReal)); assertThat(result.get(param2)[0], is(param2VReal1)); assertThat(result.get(param2)[1], is(param2VReal2)); assertThat(result.get(param3)[0], is(param3VReal1)); assertThat(result.get(param3)[1], is(param3VReal2)); }
public String crop(String string) { if ((null == string) || (string.length() <= effectiveStringLength)) { return string; } if (effectiveStringLength == 0) { return ""; } String cropped = string.substring(0, effectiveStringLength); if (USE_TRAILING_DOTS) { cropped = appendTrailingDots(cropped); } return cropped; }
StringConstraint { public String crop(String string) { if ((null == string) || (string.length() <= effectiveStringLength)) { return string; } if (effectiveStringLength == 0) { return ""; } String cropped = string.substring(0, effectiveStringLength); if (USE_TRAILING_DOTS) { cropped = appendTrailingDots(cropped); } return cropped; } }
StringConstraint { public String crop(String string) { if ((null == string) || (string.length() <= effectiveStringLength)) { return string; } if (effectiveStringLength == 0) { return ""; } String cropped = string.substring(0, effectiveStringLength); if (USE_TRAILING_DOTS) { cropped = appendTrailingDots(cropped); } return cropped; } StringConstraint(Map<String, Object> parameter); }
StringConstraint { public String crop(String string) { if ((null == string) || (string.length() <= effectiveStringLength)) { return string; } if (effectiveStringLength == 0) { return ""; } String cropped = string.substring(0, effectiveStringLength); if (USE_TRAILING_DOTS) { cropped = appendTrailingDots(cropped); } return cropped; } 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 crop(String string) { if ((null == string) || (string.length() <= effectiveStringLength)) { return string; } if (effectiveStringLength == 0) { return ""; } String cropped = string.substring(0, effectiveStringLength); if (USE_TRAILING_DOTS) { cropped = appendTrailingDots(cropped); } return cropped; } StringConstraint(Map<String, Object> parameter); String crop(String string); Map<String, String[]> crop(final Map<String, String[]> original); String cropKeepFinalCharacter(String string, char finalChar);  }