public Map<String, Object> convertValue(final Object entity, final Class<?> entityClass) {
        if (entityClass.equals(String.class)) {
            return Collections.singletonMap("data", objectMapper.convertValue(entity, String.class));
        } else if (!entityClass.equals(Void.class) && !entityClass.equals(void.class)) {
            final TypeReference<Map<String, Object>> typeRef = new TypeReference<>() {
            };
            try {
                return objectMapper.convertValue(entity, typeRef);
            } catch (IllegalArgumentException e) {
                // Try to convert the response to a list if converting to a map failed.
                final TypeReference<List<Object>> arrayTypeRef = new TypeReference<>() {
                };
                return Collections.singletonMap("data", objectMapper.convertValue(entity, arrayTypeRef));
            }
        }
        return null;
    }
@Test
    public void convertsSingleEntity() {
        final Map<String, Object> result = toTest.convertValue(new SimpleEntity("Text", 1), SimpleEntity.class);
        assertNotNull(result);
        assertEquals("Text", result.get("text"));
        assertEquals(1, result.get("number"));
    }