### Question:
ReflectionHelper { public static void invokeFunction(Object mediator, Method method) { method = ReflectionHelper.makeAccessibleIfNot(method); List<Flowable<Object>> sources = getFlowableForParameters(method); Function function = method.getAnnotation(Function.class); Sink<Object> sink = null; if (function.outbound().length() != 0) { sink = getSinkOrFail(function.outbound()); } Method methodToBeInvoked = method; Sink<Object> theSink = sink; Flowable<Optional<Object>> result; if (sources.size() == 1) { result = sources.get(0) .map(item -> Optional.ofNullable(methodToBeInvoked.invoke(mediator, item))); } else { result = Flowable.zip(sources, args -> args) .map(args -> Optional.ofNullable(methodToBeInvoked.invoke(mediator, args))); } result .flatMapCompletable(maybeResult -> { if (! maybeResult.isPresent()) { return Completable.complete(); } else { return propagateResult(maybeResult.get(), theSink); } }) .doOnError(Throwable::printStackTrace) .subscribe(); } private  ReflectionHelper(); static void set(Object mediator, Field field, Object source); static void invokeFunction(Object mediator, Method method); static void invokeTransformationMethod(Object mediator, Method method); static Object getSourceToInject(Class<?> clazz, Type type, Source<Object> source); static void inject(Object mediator);  }### Answer:
@Test(expected = IllegalArgumentException.class) public void testFunctionWithNotAnnotatedParameter() throws NoSuchMethodException { InvalidBecauseOfBadParams test = new InvalidBecauseOfBadParams(); Method method = test.getClass().getMethod("function", String.class); ReflectionHelper.invokeFunction(test, method); }
@Test(expected = IllegalArgumentException.class) public void testFunctionWithoutParam() throws NoSuchMethodException { InvalidBecauseOfBadParams test = new InvalidBecauseOfBadParams(); Method method = test.getClass().getMethod("functionWithoutParam"); ReflectionHelper.invokeFunction(test, method); }