Checks { public static void checkNotNullState(Object object, String message) { checkState(object != null, message); }  static T checkNotNull(T value); static void checkArgument(boolean condition, String message); static void checkArgument(boolean condition, String message, Object... args); static void checkState(boolean condition, String message); static void checkState(boolean condition, String message, Object... args); static void checkNotNullState(Object object, String message); static void checkNotNullState(Object object, String message, Object... args); static void checkMinMax(int min, int max); static int checkMin(int min); static int checkMax(int max); static int checkNonNegative(int n, String message);  }
@Test public void checkNotNullState_noThrowIfObjectIsntNull() { Checks.checkNotNullState("1", "whatever"); Checks.checkNotNullState("1", "whatever", 1, 2); Checks.checkNotNullState("1", "bad format %s and %s", 1); }
@Test public void checkNotNullState_throwsIfObjectIsNull() { exception.expect(IllegalStateException.class); exception.expectMessage("object = null"); Checks.checkNotNullState(null, "object = %s", "null"); }