@SuppressWarnings("unchecked")
    // visible for testing
    public StitchRequestBody createStitchRequestBody(final Message inMessage) {
        if (inMessage.getBody() instanceof StitchRequestBody) {
            return createStitchRequestBodyFromStitchRequestBody(inMessage.getBody(StitchRequestBody.class), inMessage);
        }

        if (inMessage.getBody() instanceof StitchMessage) {
            return createStitchRequestBodyFromStitchMessages(Collections.singletonList(inMessage.getBody(StitchMessage.class)),
                    inMessage);
        }

        if (inMessage.getBody() instanceof Iterable) {
            return createStitchRequestBodyFromIterable(inMessage.getBody(Iterable.class), inMessage);
        }

        if (inMessage.getBody() instanceof Map) {
            return createStitchRecordFromMap(inMessage.getBody(Map.class), inMessage);
        }

        throw new IllegalArgumentException("Message body data `" + inMessage.getBody() + "` type is not supported");
    }
@Test
    void testIfCreateIfStitchRequestBodySet() {
        final StitchConfiguration configuration = new StitchConfiguration();
        configuration.setTableName("table_2");

        final StitchMessage message1 = StitchMessage.builder()
                .withData("field_1", "test_2")
                .withSequence(0)
                .build();

        final StitchRequestBody requestBody = StitchRequestBody.builder()
                .addMessage(message1)
                .withSchema(StitchSchema.builder().addKeyword("field_1", "integer").build())
                .withTableName("table_1")
                .withKeyNames(Collections.singleton("field_1"))
                .build();

        final Exchange exchange = new DefaultExchange(context);
        exchange.getMessage().setBody(requestBody);

        final StitchProducerOperations operations = new StitchProducerOperations(new TestClient(), configuration);

        assertEquals("{\"table_name\":\"table_2\",\"schema\":{\"field_1\":\"integer\"},\"messages\":"
                     + "[{\"action\":\"upsert\",\"sequence\":0,\"data\":{\"field_1\":\"test_2\"}}],\"key_names\":[\"field_1\"]}",
                JsonUtils.convertMapToJson(operations.createStitchRequestBody(exchange.getMessage()).toMap()));
    }