FileSize implements Comparable<FileSize> { public static String convertToStringRepresentation(final long value) { final long[] dividers = new long[]{T, G, M, K, 1}; final String[] units = new String[]{"TB", "GB", "MB", "KB", "B"}; if (value == 0) { return format(0, 1, "B"); } else if (value < 1) { return "Folder"; } String result = null; for (int i = 0; i < dividers.length; i++) { final long divider = dividers[i]; if (value >= divider) { result = format(value, divider, units[i]); break; } } return result; } FileSize(String string);  FileSize(long bytes); long getBytes(); void setBytes(long bytes); @Override String toString(); long getMultiplier(char multiplierChar); static String convertToStringRepresentation(final long value); @Override int compareTo(FileSize o); @Override boolean equals(Object o); @Override int hashCode();  }
@Test (dataProvider = "testToStringDataProvider") public void testConvertToStringRepresentation(long size, String expectedResult) throws Exception { Assert.assertEquals(FileSize.convertToStringRepresentation(size), expectedResult); }