### Question:
Preconditions { public static <T> T checkNotNull(final T reference) { if (reference == null) { throw new NullPointerException(); } return reference; } private  Preconditions(); @NonNull static T get(@Nullable final T reference); static T checkNotNull(final T reference); static T checkNotNull(final T reference, @NonNull final String errorMessage);  }### Answer:
@Test public void checkNotNull_doesNotThrowException_whenNonNull() { Preconditions.checkNotNull(new Object()); }
@Test public void checkNotNull_throwsNullPointerException_whenNull() { thrown.expect(NullPointerException.class); Preconditions.checkNotNull(null); }
@Test public void checkNotNullWithMessage_doesNotThrowException_whenNonNull() { Preconditions.checkNotNull(new Object(), "Unused message"); }
@Test public void checkNotNullWithMessage_throwsNullPointerExceptionWithMessage_whenNull() { final String message = "message"; thrown.expect(NullPointerException.class); thrown.expectMessage(message); Preconditions.checkNotNull(null, message); }