@Override
    public ExecutionResult execute(final TaskConfig config, final TaskExecutionContext taskExecutionContext) {
        return pluginRequestHelper.submitRequest(pluginId, TaskExtension.EXECUTION_REQUEST, new DefaultPluginInteractionCallback<>() {
            @Override
            public String requestBody(String resolvedExtensionVersion) {
                return handlerMap.get(resolvedExtensionVersion).getTaskExecutionBody(config, taskExecutionContext);
            }

            @Override
            public ExecutionResult onSuccess(String responseBody, Map<String, String> responseHeaders, String resolvedExtensionVersion) {
                return handlerMap.get(resolvedExtensionVersion).toExecutionResult(responseBody);
            }
        });
    }
@Test
    public void shouldExecuteAndReturnSuccessfulExecutionResultTaskThroughPlugin() {
        when(pluginManager.submitTo(eq(pluginId), eq(PLUGGABLE_TASK_EXTENSION), any(GoPluginApiRequest.class))).thenReturn(response);
        when(handler.toExecutionResult(response.responseBody())).thenReturn(ExecutionResult.success("message1"));

        ExecutionResult result = new JsonBasedTaskExecutor(pluginId, pluginRequestHelper, handlerHashMap).execute(config(), context);

        assertThat(result.isSuccessful(), is(true));
        assertThat(result.getMessagesForDisplay(), is("message1"));

        ArgumentCaptor<GoPluginApiRequest> argument = ArgumentCaptor.forClass(GoPluginApiRequest.class);
        verify(pluginManager).submitTo(eq(pluginId), eq(PLUGGABLE_TASK_EXTENSION), argument.capture());
        assertThat(argument.getValue().extension(), is(PLUGGABLE_TASK_EXTENSION));
        assertThat(argument.getValue().extensionVersion(), is(extensionVersion));
        assertThat(argument.getValue().requestName(), is(TaskExtension.EXECUTION_REQUEST));
    }