Preconditions { public static void checkState(final boolean expression, @NonNull final String errorMessage) { if (!expression) { throw new IllegalStateException(errorMessage); } } private  Preconditions(); static void checkState(final boolean expression, @NonNull final String errorMessage); static void checkArgument(final boolean expression, @NonNull final String errorMessage); @SuppressWarnings("ConstantConditions") @NonNull static T checkNotNull(@NonNull final T object);  }
@Test(expected = IllegalStateException.class) public void shouldThrowIllegalStateExceptionForCheckStateWithFalseExpression() { checkState(false, ""); }
@Test public void shouldNotThrowExceptionForCheckStateWithTrueExpression() { checkState(true, ""); }