public static <InputT, OutputT> DoFnInvoker<InputT, OutputT> invokerFor(
      DoFn<InputT, OutputT> fn) {
    return ByteBuddyDoFnInvokerFactory.only().newByteBuddyInvoker(fn);
  }
@Test
  public void testProcessElementExceptionWithReturn() throws Exception {
    thrown.expect(UserCodeException.class);
    thrown.expectMessage("bogus");
    DoFnInvokers.invokerFor(
            new DoFn<Integer, Integer>() {
              @ProcessElement
              public ProcessContinuation processElement(
                  @SuppressWarnings("unused") ProcessContext c,
                  RestrictionTracker<SomeRestriction, Void> tracker) {
                throw new IllegalArgumentException("bogus");
              }

              @GetInitialRestriction
              public SomeRestriction getInitialRestriction(@Element Integer element) {
                return null;
              }

              @NewTracker
              public SomeRestrictionTracker newTracker(@Restriction SomeRestriction restriction) {
                return null;
              }
            })
        .invokeProcessElement(
            new FakeArgumentProvider<Integer, Integer>() {
              @Override
              public DoFn.ProcessContext processContext(DoFn<Integer, Integer> doFn) {
                return null; // will not be touched
              }

              @Override
              public RestrictionTracker<?, ?> restrictionTracker() {
                return null; // will not be touched
              }
            });
  }