### Question:
Preconditions { public static <T> T checkNotNull(T obj) { if (obj == null) { throw new NullPointerException(); } return obj; } private  Preconditions(); static T checkNotNull(T obj); static T checkNotNull(T obj, String errorMsg); static void checkArgument(boolean condition, Object errorMsg);  }### Answer:
@Test public void testCheckNotNull() throws Exception { String testReference = "test object"; Assert.assertEquals(testReference, Preconditions.checkNotNull(testReference)); Assert.assertEquals(testReference,Preconditions.checkNotNull(testReference,"object is null")); try { Preconditions.checkNotNull(null); } catch (NullPointerException ex) { assertNull(ex.getMessage()); } try { Preconditions.checkNotNull(""); } catch (NullPointerException ex) { assertNull(ex.getMessage()); } try { Preconditions.checkNotNull(null,"object is null"); } catch (NullPointerException ex) { assertThat(ex.getMessage(), containsString("object is null")); } try { Preconditions.checkNotNull("","object is null"); } catch (NullPointerException ex) { assertThat(ex.getMessage(), containsString("object is null")); } }