Assert { public static void hasSize(Collection<?> input, int length, String message) { notNull(input, message); if (input.size() != 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 testHasSize() { Assert.hasSize(Arrays.asList("1", "2", "3"), 3, "Wrong length"); try { Assert.hasSize(null, 4, "null"); fail("Expected exception"); } catch (IllegalArgumentException e) { assertThat(e.getMessage()).isEqualTo("null"); } try { Assert.hasSize(Arrays.asList("1", "2", "3"), 4, "short"); fail("Expected exception"); } catch (IllegalArgumentException e) { assertThat(e.getMessage()).isEqualTo("short"); } }