Objects { static <T> T requireNonNull(final T obj, final String message, final Object... args) { if (obj == null) { throw new NullPointerException(String.format(message, args)); } return obj; } private  Objects();   }
@Test(expected = NullPointerException.class) public void verifyRequireNonNullThrowsOnNull() throws Exception { requireNonNull(null, "foo"); }
@Test public void verifyRequireNonNullReturnsValue() throws Exception { final String value = "foo"; final String returned = requireNonNull(value, "foo"); assertThat(returned, is(value)); }