FixedLength { public static String spaces(int n) { if (n > DEFAULT_SPACES.length()) throw new RuntimeException("Unexpectedly large number of spaces to generate: " + n); return DEFAULT_SPACES.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 testSpaces() { assertEquals("", FixedLength.spaces(0)); assertEquals(" ", FixedLength.spaces(1)); assertEquals(" ", FixedLength.spaces(5)); }
@Test(expected = RuntimeException.class) public void testTooManySpaces() { FixedLength.spaces(1000); }