Utils { public static String logString(final String string) { if (string == null || string.length() == 0) { return string; } String ret = string.replaceAll("[^\\p{Print}]", "?"); ret = ret.substring(0, Math.min(ret.length(), MAX_LOG_STRING_LENGTH)) + (ret.length() > MAX_LOG_STRING_LENGTH ? "..." : ""); return ret; } private  Utils(); static String generateParameterHash(String path, String func, List<String> args); static String generateDirectoryHash(String rootDir, String chaincodeDir, String hash); static byte[] generateTarGz(File sourceDirectory, String pathPrefix); static byte[] readFile(File input); static String generateUUID(); static Timestamp generateTimestamp(); static void deleteFileOrDirectory(File file); static byte[] hash(byte[] input, Digest digest); static String combinePaths(String first, String... other); static byte[] readFileFromClasspath(String fileName); static Properties parseGrpcUrl(String url); static Exception checkGrpcUrl(String url); static boolean isNullOrEmpty(String url); static String logString(final String string); static byte[] generateNonce(); static String toHexString(ByteString byteString); static String toHexString(byte[] bytes);  }
@Test public void testLogString() { Assert.assertEquals(null, Utils.logString(null)); Assert.assertEquals("", Utils.logString("")); Assert.assertEquals("ab??c", Utils.logString("ab\r\nc")); Assert.assertEquals("ab?c", Utils.logString("ab\tc")); }