@Override
    public ExecutionResult toExecutionResult(String responseBody) {
        ExecutionResult executionResult = new ExecutionResult();
        ArrayList<String> exceptions = new ArrayList<>();
        try {
            Map result = (Map) GSON.fromJson(responseBody, Object.class);
            if (!(result.containsKey("success") && result.get("success") instanceof Boolean)) {
                exceptions.add("The Json for Execution Result must contain a not-null 'success' field of type Boolean");
            }
            if (result.containsKey("message") && (!(result.get("message") instanceof String))) {
                exceptions.add("If the 'message' key is present in the Json for Execution Result, it must contain a not-null message of type String");
            }
            if (!exceptions.isEmpty()) {
                throw new RuntimeException(StringUtils.join(exceptions, ", "));
            }
            if ((Boolean) result.get("success")) {
                executionResult.withSuccessMessages((String) result.get("message"));
            } else {
                executionResult.withErrorMessages((String) result.get("message"));
            }
            return executionResult;
        } catch (Exception e) {
            LOGGER.error("Error occurred while converting the Json to Execution Result. Error: {}. The Json received was '{}'.", e.getMessage(), responseBody);
            throw new RuntimeException(String.format("Error occurred while converting the Json to Execution Result. Error: %s.", e.getMessage()));
        }
    }
@Test
    public void shouldConstructExecutionResultFromFailureExecutionResponse() {
        GoPluginApiResponse response = mock(GoPluginApiResponse.class);
        when(response.responseBody()).thenReturn("{\"success\":false,\"message\":\"error1\"}");

        ExecutionResult result = new JsonBasedTaskExtensionHandler_V1().toExecutionResult(response.responseBody());
        assertThat(result.isSuccessful(), is(false));
        assertThat(result.getMessagesForDisplay(), is("error1"));
    }