FixedLength { public static String zeroes(int n) { if (n > DEFAULT_ZEROES.length()) throw new RuntimeException("Unexpectedly large number of zeroes to generate: " + n); return DEFAULT_ZEROES.substring(0, Math.max(n, 0)); }  static String valueOf(int value, int size); static String valueOf(String value, int size); static String leadingZeros(String value, int size); static String spaces(int n); static String zeroes(int n); static boolean isPresent(String value); static boolean isPresent(List<?> list); static String emptyIfNull(String value);  }
@Test public void testZeroes() { assertEquals("", FixedLength.zeroes(0)); assertEquals("0", FixedLength.zeroes(1)); assertEquals("00000", FixedLength.zeroes(5)); }
@Test(expected = RuntimeException.class) public void testTooManyZeroes() { FixedLength.zeroes(1000); }