HonoProtonHelper { public static <T> Future<T> executeOnContext( final Context requiredContext, final Handler<Promise<T>> codeToRun) { Objects.requireNonNull(codeToRun); final Promise<T> result = Promise.promise(); if (requiredContext == null) { result.fail(new IllegalStateException("no context to run on")); } else { final Context currentContext = Vertx.currentContext(); if (currentContext == requiredContext) { codeToRun.handle(result); } else { requiredContext.runOnContext(go -> codeToRun.handle(result)); } } return result.future(); } private  HonoProtonHelper(); static Handler<AsyncResult<T>> setDetachHandler(
            final ProtonLink<T> link,
            final Handler<AsyncResult<T>> handler); static Handler<AsyncResult<T>> setCloseHandler(
            final ProtonLink<T> link,
            final Handler<AsyncResult<T>> handler); static void setDefaultCloseHandler(final ProtonLink<T> link); static void setDefaultCloseHandler(final ProtonSession session); static boolean isLinkEstablished(final ProtonLink<?> link); static Future<T> executeOnContext(
            final Context requiredContext,
            final Handler<Promise<T>> codeToRun); static void closeAndFree(
            final Context context,
            final ProtonLink<?> link,
            final Handler<Void> closeHandler); static void closeAndFree(
            final Context context,
            final ProtonLink<?> link,
            final long detachTimeOut,
            final Handler<Void> closeHandler); static final long DEFAULT_FREE_LINK_AFTER_CLOSE_INTERVAL_MILLIS; }
@SuppressWarnings("unchecked") @Test @Timeout(value = 5, timeUnit = TimeUnit.SECONDS) public void testExecuteOnContextRunsOnGivenContext(final VertxTestContext ctx) { final Context mockContext = mock(Context.class); doAnswer(invocation -> { final Handler<Void> codeToRun = invocation.getArgument(0); codeToRun.handle(null); return null; }).when(mockContext).runOnContext(any(Handler.class)); HonoProtonHelper.executeOnContext(mockContext, result -> result.complete("done")) .onComplete(ctx.succeeding(s -> { ctx.verify(() -> { verify(mockContext).runOnContext(any(Handler.class)); assertThat(s).isEqualTo("done"); }); ctx.completeNow(); })); }