public Result toResult(String responseBody) {
        try {
            Result result = new Result();

            Map<String, Object> map;
            try {
                map = GSON.fromJson(responseBody, new TypeToken<Map<String, Object>>() {}.getType());
            } catch (Exception e) {
                throw new RuntimeException("Check connection result should be returned as map, with status represented as string and messages represented as list");
            }
            if (map == null || map.isEmpty()) {
                throw new RuntimeException("Empty response body");
            }

            String status;
            try {
                status = (String) map.get("status");
            } catch (Exception e) {
                throw new RuntimeException("Check connection 'status' should be of type string");
            }

            if (isEmpty(status)) {
                throw new RuntimeException("Check connection 'status' is a required field");
            }

            if ("success".equalsIgnoreCase(status)) {
                result.withSuccessMessages(new ArrayList<>());
            } else {
                result.withErrorMessages(new ArrayList<>());
            }

            if (map.containsKey("messages") && map.get("messages") != null) {
                List<?> messages;
                try {
                    messages = (List<?>) map.get("messages");
                } catch (Exception e) {
                    throw new RuntimeException("Check connection 'messages' should be of type list of string");
                }

                if (!messages.isEmpty()) {
                    for (Object message : messages) {
                        if (!(message instanceof String)) {
                            throw new RuntimeException("Check connection 'message' should be of type string");
                        }
                    }

                    if (result.isSuccessful()) {
                        //noinspection unchecked
                        result.withSuccessMessages((List<String>) messages);
                    } else {
                        //noinspection unchecked
                        result.withErrorMessages((List<String>) messages);
                    }
                }
            }

            return result;
        } catch (Exception e) {
            throw new RuntimeException(format("Unable to de-serialize json response. %s", e.getMessage()));
        }
    }
@Test
    public void shouldBuildSuccessResultFromResponseBody() {
        String responseBody = "{\"status\":\"success\",messages=[\"message-one\",\"message-two\"]}";
        Result result = messageHandler.toResult(responseBody);
        assertSuccessResult(result, List.of("message-one", "message-two"));
    }