### Question:
StringUtil { public static String sanitizeStringValue(String value, int maxLength) { char[] chars = value.toCharArray(); int length = chars.length; int limit = Math.min(length, maxLength); for (int i = 0; i < limit; i++) { if (chars[i] == NULL_CHARACTER) { return new String(chars, 0, i); } } if (limit < length) { return new String(chars, 0, limit); } else { return value; } }  static String join(String separator, String... keys); static String sanitizeStringValue(String value, int maxLength); static byte[] encodeUtf8(String s); static String decodeUtf8(byte[] bytes); static String decodeUtf8(byte[] bytes, int startIndex, int length);  }### Answer:
@Test public void testSanitizeStringValue() { assertEquals(StringUtil.sanitizeStringValue("pot\0ato", 3), "pot"); assertEquals(StringUtil.sanitizeStringValue("pot\0ato", 6), "pot"); assertEquals(StringUtil.sanitizeStringValue("potato", 2), "po"); assertEquals(StringUtil.sanitizeStringValue("pot\0ato", 2), "po"); String value = "potato"; assertSame(StringUtil.sanitizeStringValue(value, 6), value); assertSame(StringUtil.sanitizeStringValue(value, 7), value); }