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 returnsNullOnVoidEntityClass() {
        assertNull(toTest.convertValue(new Object(), Void.class));
        assertNull(toTest.convertValue("Lalala", void.class));
    }