private Object workerTaskMethod(InvocationOnMock invocation) {
        // provide implementations of three methods used during testing
        switch (invocation.getMethod().getName()) {
            case "id":
                return TASK_ID;
            case "loader":
                return pluginLoader;
            case "awaitStop":
                return true;
            default:
                return null;
        }
    }
This method is called in place of methods on WorkerTask subclasses.
connect/runtime/src/test/java/org/apache/kafka/connect/runtime/WorkerTest.java