Preconditions { public static void checkState(final boolean expression, @NonNull String errorMessage) { if (!expression) { throw new IllegalStateException(errorMessage); } }  static void checkState(final boolean expression, @NonNull String errorMessage); @NonNull static T checkNotNull(T value, @NonNull String errorMessage); @NonNull static Collection<T> checkNotEmpty(Collection<T> collection, @NonNull String errorMessage);  }
@Test public void testCheckStateTrue_shouldReturn() { Preconditions.checkState(true, "TestError"); }
@Test public void testCheckStateFalse_shouldThrow() { exception.expect(IllegalStateException.class); exception.expectMessage("TestError"); Preconditions.checkState(false, "TestError"); }