@SuppressWarnings("unchecked")
    public static Builder fromMap(final Map<String, Object> data) {
        final String tableName = ObjectHelper.cast(String.class, data.get(TABLE_NAME));
        final StitchSchema schema = StitchSchema.builder()
                .addKeywords(ObjectHelper.cast(Map.class, data.getOrDefault(SCHEMA, Collections.emptyMap())))
                .build();
        final Collection<StitchMessage> messages = (Collection<StitchMessage>) ObjectHelper
                .cast(Collection.class, data.getOrDefault(MESSAGES, Collections.emptyList()))
                .stream()
                .filter(ObjectHelper::isNotEmpty)
                .map(message -> StitchMessage
                        .fromMap(ObjectHelper.cast(Map.class, message))
                        .build())
                .collect(Collectors.toList());
        final Collection<String> keyNames = ObjectHelper.cast(Collection.class, data.get(KEY_NAMES));

        return new Builder()
                .withSchema(schema)
                .withTableName(tableName)
                .withKeyNames(keyNames)
                .withSchema(schema)
                .addMessages(messages);
    }
@Test
    void testIfNotCreateRequestBodyFromInvalidMap() {
        final Map<String, Object> data = new LinkedHashMap<>();
        data.put(StitchRequestBody.TABLE_NAME, "table");
        data.put(StitchRequestBody.SCHEMA, 1);
        data.put(StitchRequestBody.MESSAGES, Collections.emptyList());
        data.put(StitchRequestBody.KEY_NAMES, Collections.emptySet());

        assertThrows(IllegalArgumentException.class, () -> StitchRequestBody.fromMap(data));

        final Map<String, Object> data2 = new LinkedHashMap<>();
        data2.put(StitchRequestBody.TABLE_NAME, "table");
        data2.put(StitchRequestBody.SCHEMA, Collections.emptyMap());
        data2.put(StitchRequestBody.MESSAGES, 12);
        data2.put(StitchRequestBody.KEY_NAMES, Collections.emptySet());

        assertThrows(IllegalArgumentException.class, () -> StitchRequestBody.fromMap(data2));
    }