### Question:
ParamUtils { public static <T> T nonNull(final T object, final Supplier<String> message) { if (object != null) { return object; } throw new IllegalArgumentException(message.get()); } private  ParamUtils(); static void validate(final boolean condition, final Supplier<String> message); static int validateIndex(final int index, final int length); static T nonNull(final T object, final Supplier<String> message); static T nonNull(final T object); static T nonEmpty(final T collection, final Supplier<String> message); static T nonEmpty(final T collection);  }### Answer:
@Test public void testNonNullWithNullObject() { final String message = "is null"; try { ParamUtils.nonNull(null, () -> message); Assert.fail(); } catch (final IllegalArgumentException e) { Assert.assertEquals(e.getMessage(), message); } }
@Test public void testNonNullWithNullObjectWithoutMessage() { try { ParamUtils.nonNull((String) null); Assert.fail(); } catch (final IllegalArgumentException e) { Assert.assertEquals(e.getMessage(), "object cannot be null"); } }
@Test public void testNonNullReturnSame() { final String myString = "hello world"; final String returned = ParamUtils.nonNull(myString, () -> "Should not throw"); Assert.assertSame(returned, myString); }