### Question:
ObjectTruncater { private static String truncString(String value, int maxStringLength) { if (value.length() <= maxStringLength) { return value; } int halfMax = halfSize(maxStringLength); int overlimit = value.length() - maxStringLength; return value.substring(0, halfMax) + "...[skipped " + overlimit + " chars]..." + value.substring(halfMax + overlimit); } private  ObjectTruncater(); static Map<String, Object> truncateMap(Map<String, Object> value, int maxStringLength, int maxArrayLength, int maxDepth); static Object truncate(Object value, int maxStringLength, int maxArrayLength, int maxDepth);  }### Answer:
@Test public void testTruncString() { Map<String, Object> value = new HashMap<>(); value.put("k", "123456"); int maxStringLength = 3; int maxArrayLength = 4; int maxDepth = 2; Object result = ObjectTruncater.truncate(value, maxStringLength, maxArrayLength, maxDepth); assertEquals(Collections.<String, Object>singletonMap("k", "12...[skipped 3 chars]...6"), result); }