ObjectsUtils { public static <T> T requireNonNull(T object, String errorMessage) { if (object == null) { throw new NullPointerException(errorMessage); } else { return object; } }  static boolean equals(Object object1, Object object2); static int hash(Object... objects); static T requireNonNull(T object, String errorMessage); static void close(final Closeable closeable);  }
@Test public void testNonNull() { String result = ObjectsUtils.requireNonNull(TEST, ERROR_DESCRIPTION); String expected = TEST; assertThat(result, is(expected)); }
@Test public void testNull() { expectedException.expect(NullPointerException.class); expectedException.expectMessage(ERROR_DESCRIPTION); ObjectsUtils.requireNonNull(null, ERROR_DESCRIPTION); }