Assert { public static void hasLength(String input, int length, String message) { notNull(input, message); if (input.trim().length() != length) { throw new IllegalArgumentException(message); } }  static void isTrue(boolean condition, String message); static void notNull(Object object, String message); static void hasLength(String input, int length, String message); static void hasSize(Collection<?> input, int length, String message);  }
@Test public void testHasLength() { Assert.hasLength("Test", 4, "Wrong length"); try { Assert.hasLength(null, 4, "null"); fail("Expected exception"); } catch (IllegalArgumentException e) { assertThat(e.getMessage()).isEqualTo("null"); } try { Assert.hasLength("", 4, "short"); fail("Expected exception"); } catch (IllegalArgumentException e) { assertThat(e.getMessage()).isEqualTo("short"); } }