@SuppressWarnings("unchecked")
    public static List<String> createRobotVariablesFromCamelExchange(Exchange exchange, boolean allowContextMapAll)
            throws TypeConversionException, NoTypeConversionAvailableException {
        Map<String, Object> variablesMap = ExchangeHelper.createVariableMap(exchange, allowContextMapAll);
        List<String> variableKeyValuePairList = new ArrayList<>();
        for (Map.Entry<String, Object> variableEntry : variablesMap.entrySet()) {
            if (ROBOT_VAR_CAMEL_BODY.equals(variableEntry.getKey())) {
                String bodyVariable = variableEntry.getKey() + ROBOT_VAR_FIELD_SEPERATOR
                                      + exchange.getContext().getTypeConverter().mandatoryConvertTo(String.class,
                                              variableEntry.getValue());
                variableKeyValuePairList.add(bodyVariable);
            } else if (ROBOT_VAR_CAMEL_HEADERS.equals(variableEntry.getKey())) {
                // here the param is the headers map
                createStringValueOfVariablesFromMap(variableKeyValuePairList,
                        ObjectHelper.cast(Map.class, variableEntry.getValue()), exchange, new StringBuilder(),
                        ROBOT_VAR_CAMEL_HEADERS, true);
            } else if (ROBOT_VAR_CAMEL_VARIABLES.equals(variableEntry.getKey())) {
                // here the param is the headers map
                createStringValueOfVariablesFromMap(variableKeyValuePairList, exchange.getVariables(),
                        exchange, new StringBuilder(), ROBOT_VAR_CAMEL_VARIABLES, true);
            } else if (ROBOT_CAMEL_EXCHANGE_NAME.equals(variableEntry.getKey())) {
                // here the param is camel exchange
                createStringValueOfVariablesFromMap(variableKeyValuePairList, exchange.getProperties(),
                        ObjectHelper.cast(Exchange.class, variableEntry.getValue()),
                        new StringBuilder(), ROBOT_VAR_CAMEL_PROPERTIES, true);
            }
        }
        return variableKeyValuePairList;
    }
@SuppressWarnings("unchecked")
    @Test
    public void testCreateRobotVariablesFromCamelExchange() throws Exception {
        MockEndpoint mock = getMockEndpoint("mock:result");
        mock.expectedMinimumMessageCount(1);
        Map<String, Object> headers = new HashMap<>();
        headers.put("stringKey", "str1");
        headers.put("numericIntKey", 1);
        headers.put("numericBigDecimalKey", new BigDecimal(2));

        Map<String, Object> inner1 = new HashMap<>();
        inner1.put("innerStringKey", "str1");
        inner1.put("innerNumericIntKey", 1);
        inner1.put("innerNumericBigDecimalKey", new BigDecimal(2));

        headers.put("inner", inner1);

        exchange.getIn().setHeaders(headers);
        exchange.setProperty("stringKey", "str1");
        exchange.setProperty("numericIntKey", 1);
        exchange.setProperty("numericBigDecimalKey", new BigDecimal(2));
        exchange.setProperty("inner", inner1);

        Exchange responseExchange = template.send("direct:setVariableCamelExchange", exchange);

        List<String> camelRobotVariables = ObjectHelper.cast(List.class,
                responseExchange.getIn().getHeader(RobotFrameworkCamelConstants.CAMEL_ROBOT_VARIABLES));
        for (String camelRobotVariable : camelRobotVariables) {
            if (!camelRobotVariable.contains("headers") && !camelRobotVariable.contains("properties")
                    && camelRobotVariable.contains("body")) {
                assertEquals("body:Hello Robot", camelRobotVariable, "Body variable content should be [body:<body_value>]");
            }
            if (camelRobotVariable.contains("headers") && camelRobotVariable.contains("stringKey")) {
                assertEquals("headers.stringKey:str1", camelRobotVariable,
                        "Header variable content should be [headers.stringKey:<header_value>]");
            }
            if (camelRobotVariable.contains("headers") && camelRobotVariable.contains("numericIntKey")) {
                assertEquals("headers.numericIntKey:1", camelRobotVariable,
                        "Header variable content should be [headers.numericIntKey:<header_value>]");
            }
            if (camelRobotVariable.contains("headers") && camelRobotVariable.contains("numericBigDecimalKey")) {
                assertEquals("headers.numericBigDecimalKey:2", camelRobotVariable,
                        "Header variable content should be [headers.numericIntKey:<header_value>]");
            }
            if (camelRobotVariable.contains("headers") && camelRobotVariable.contains("innerStringKey")) {
                assertEquals("headers.inner.innerStringKey:str1", camelRobotVariable,
                        "Header variable content should be [headers.stringKey:<header_value>]");
            }
            if (camelRobotVariable.contains("headers") && camelRobotVariable.contains("innerNumericIntKey")) {
                assertEquals("headers.inner.innerNumericIntKey:1", camelRobotVariable,
                        "Header variable content should be [headers.numericIntKey:<header_value>]");
            }
            if (camelRobotVariable.contains("headers") && camelRobotVariable.contains("innerNumericBigDecimalKey")) {
                assertEquals("headers.inner.innerNumericBigDecimalKey:2", camelRobotVariable,
                        "Header variable content should be [headers.numericIntKey:<header_value>]");
            }
            if (camelRobotVariable.contains("properties") && camelRobotVariable.contains("stringKey")) {
                assertEquals("properties.stringKey:str1", camelRobotVariable,
                        "Header variable content should be [properties.stringKey:<header_value>]");
            }
            if (camelRobotVariable.contains("properties") && camelRobotVariable.contains("numericIntKey")) {
                assertEquals("properties.numericIntKey:1", camelRobotVariable,
                        "Header variable content should be [properties.numericIntKey:<header_value>]");
            }
            if (camelRobotVariable.contains("properties") && camelRobotVariable.contains("numericBigDecimalKey")) {
                assertEquals("properties.numericBigDecimalKey:2", camelRobotVariable,
                        "Header variable content should be [properties.numericIntKey:<header_value>]");
            }
            if (camelRobotVariable.contains("properties") && camelRobotVariable.contains("innerStringKey")) {
                assertEquals("properties.inner.innerStringKey:str1", camelRobotVariable,
                        "Header variable content should be [properties.stringKey:<header_value>]");
            }
            if (camelRobotVariable.contains("properties") && camelRobotVariable.contains("innerNumericIntKey")) {
                assertEquals("properties.inner.innerNumericIntKey:1", camelRobotVariable,
                        "Header variable content should be [properties.numericIntKey:<header_value>]");
            }
            if (camelRobotVariable.contains("properties") && camelRobotVariable.contains("innerNumericBigDecimalKey")) {
                assertEquals("properties.inner.innerNumericBigDecimalKey:2", camelRobotVariable,
                        "Header variable content should be [properties.numericIntKey:<header_value>]");
            }
        }

        MockEndpoint.assertIsSatisfied(context);

        Exchange exchange = mock.getExchanges().get(0);
        assertEquals(0, (int) ObjectHelper.cast(Integer.class,
                exchange.getIn().getHeader(RobotFrameworkCamelConstants.CAMEL_ROBOT_RETURN_CODE)));
    }