Preconditions { public static <T> T assertNotNull(T object, String message) { if (object == null) { throw new NullPointerException(message); } return object; }  static void assertNull(Object object, String message); static T assertNotNull(T object, String message); static void assertTrue(boolean argument, String message);  }
@Test public void testAssertNotNullPass() { String test = "hi there"; String result = Preconditions.assertNotNull(test, "shouldnt be null"); assertThat(result).isEqualTo(test); }
@Test(expected = NullPointerException.class) public void testAssertNotNullFail() { String test = null; Preconditions.assertNotNull(test, "should fail."); }