public static Map<String, Object> convert(FormData data) {
        Map<String, Object> map = new HashMap<>();
        for (String key : data) {

            if (data.get(key).size() == 1) {
                // If the form data is file, read it as FileItem, else read as String.
                if (data.getFirst(key).getFileName() == null) {
                    String value = data.getFirst(key).getValue();
                    map.put(key, value);
                } else {
                    FormData.FileItem value = data.getFirst(key).getFileItem();
                    map.put(key, value);
                }
            } else if (data.get(key).size() > 1) {
                List<Object> list = new ArrayList<>();
                for (FormData.FormValue value : data.get(key)) {
                    // If the form data is file, read it as FileItem, else read as String.
                    if (value.getFileName() == null) {
                        list.add(value.getValue());
                    } else {
                        list.add(value.getFileItem());
                    }
                }
                map.put(key, list);
            }
            // ignore size == 0
        }
        return map;
    }
@Test
    public void shouldToGetConvertedFormDataInAMapGroupedByKey() {
        String aKey = "aKey";
        String aValue = "aValue";
        String anotherValue = "anotherValue";

        FormData formData = new FormData(99);
        formData.add(aKey, aValue);
        formData.add(aKey, anotherValue);

        Map<String, Object> bodyMap = BodyConverter.convert(formData);

        Assert.assertEquals(1, bodyMap.size());

        List<Object> aConvertedListvalue = (List<Object>) bodyMap.get(aKey);
        Assert.assertEquals(2, aConvertedListvalue.size());

        Assert.assertTrue(aConvertedListvalue.get(0) instanceof String);
        Assert.assertEquals(aValue, aConvertedListvalue.get(0));

        Assert.assertTrue(aConvertedListvalue.get(1) instanceof String);
        Assert.assertEquals(anotherValue, aConvertedListvalue.get(1));
    }