@GwtIncompatible("Reflection") public void testAllOverloads_checkNotNull() throws Exception { for (ImmutableList<Class<?>> sig : allSignatures(Object.class)) { Method checkArgumentMethod = Preconditions.class.getMethod("checkNotNull", sig.toArray(new Class<?>[] {})); checkArgumentMethod.invoke( null /* static method */, getParametersForSignature(new Object(), sig)); Object[] failingParams = getParametersForSignature(null, sig); try { checkArgumentMethod.invoke(null /* static method */, failingParams); fail(); } catch (InvocationTargetException ite) { assertFailureCause(ite.getCause(), NullPointerException.class, failingParams); } } }
@GwtIncompatible("Reflection") public void testAllOverloads_checkArgument() throws Exception { for (ImmutableList<Class<?>> sig : allSignatures(boolean.class)) { Method checkArgumentMethod = Preconditions.class.getMethod("checkArgument", sig.toArray(new Class<?>[] {})); checkArgumentMethod.invoke(null /* static method */, getParametersForSignature(true, sig)); Object[] failingParams = getParametersForSignature(false, sig); try { checkArgumentMethod.invoke(null /* static method */, failingParams); fail(); } catch (InvocationTargetException ite) { assertFailureCause(ite.getCause(), IllegalArgumentException.class, failingParams); } } }
@GwtIncompatible("Reflection") public void testAllOverloads_checkState() throws Exception { for (ImmutableList<Class<?>> sig : allSignatures(boolean.class)) { Method checkArgumentMethod = Preconditions.class.getMethod("checkState", sig.toArray(new Class<?>[] {})); checkArgumentMethod.invoke(null /* static method */, getParametersForSignature(true, sig)); Object[] failingParams = getParametersForSignature(false, sig); try { checkArgumentMethod.invoke(null /* static method */, failingParams); fail(); } catch (InvocationTargetException ite) { assertFailureCause(ite.getCause(), IllegalStateException.class, failingParams); } } }
@GwtIncompatible("Reflection") public void testAllOverloads_checkNotNull() throws Exception { for (ImmutableList<Class<?>> sig : allSignatures(Object.class)) { Method checkArgumentMethod = Preconditions.class.getMethod("checkNotNull", sig.toArray(new Class<?>[] {})); checkArgumentMethod.invoke( null /* static method */, getParametersForSignature(new Object(), sig)); Object[] failingParams = getParametersForSignature(null, sig); try { checkArgumentMethod.invoke(null /* static method */, failingParams); fail(); } catch (InvocationTargetException ite) { assertFailureCause(ite.getCause(), NullPointerException.class, failingParams); } } }
@GwtIncompatible("Reflection") public void testAllOverloads_checkArgument() throws Exception { for (ImmutableList<Class<?>> sig : allSignatures(boolean.class)) { Method checkArgumentMethod = Preconditions.class.getMethod("checkArgument", sig.toArray(new Class<?>[] {})); checkArgumentMethod.invoke(null /* static method */, getParametersForSignature(true, sig)); Object[] failingParams = getParametersForSignature(false, sig); try { checkArgumentMethod.invoke(null /* static method */, failingParams); fail(); } catch (InvocationTargetException ite) { assertFailureCause(ite.getCause(), IllegalArgumentException.class, failingParams); } } }
@GwtIncompatible("Reflection") public void testAllOverloads_checkState() throws Exception { for (ImmutableList<Class<?>> sig : allSignatures(boolean.class)) { Method checkArgumentMethod = Preconditions.class.getMethod("checkState", sig.toArray(new Class<?>[] {})); checkArgumentMethod.invoke(null /* static method */, getParametersForSignature(true, sig)); Object[] failingParams = getParametersForSignature(false, sig); try { checkArgumentMethod.invoke(null /* static method */, failingParams); fail(); } catch (InvocationTargetException ite) { assertFailureCause(ite.getCause(), IllegalStateException.class, failingParams); } } }