Preconditions { static void checkNotNull(final Object object, final String message) { if (object == null) { throw new NullPointerException(message); } } private  Preconditions();   }
@Test public void shouldNotThrowAnyExceptionWhenObjectIsNotNull() { Object object = new Object(); try { Preconditions.checkNotNull(object, "object == null"); } catch (Exception e) { fail(e.getMessage()); } }
@Test(expected = NullPointerException.class) public void shouldThrowAnExceptionWhenObjectIsNull() { Object object = null; Preconditions.checkNotNull(object, "object == null"); }