Utils { public String trimToSize(String str, int maxStringLength) { if(str == null) return null; if(str.length() > maxStringLength) { StringBuilder sb = new StringBuilder(str); sb.setLength(maxStringLength); str = sb.toString(); } return str; }  boolean isBlank(final CharSequence cs); boolean isNotBlank(final CharSequence cs); String trimToSize(String str, int maxStringLength); void sleep(int ms); void logIssue(String message, Throwable ex); String getApplicationName(Context context); String getVersionName(Context context); int getVersionCode(Context context); String getApplicationPackageName(Context context); @NonNull String getAndroidId(Context context); boolean isOnWifi(Context context);  }
@Test public void testTrimToSize() { assertEquals("", utils.trimToSize("test", 0)); assertEquals("t", utils.trimToSize("test", 1)); assertEquals("test", utils.trimToSize("test", 4)); assertEquals("test", utils.trimToSize("test", 5)); assertEquals(" ", utils.trimToSize(" test ", 4)); }