ReflectionBodyGenerator implements FormUrlEncodedBodyGenerator { @Override public <T extends KanbaneryResource> String asString(T entity) { String resourceId = entity.getResourceId(); log.info("Preparing form encoded data for: {}", resourceId); Collection<Field> fields = getAllFields(entity); log.info("{} has {} fields in total.", resourceId, fields.size()); Collection<Field> fieldsToBeSet = filter(fields, new SettableNotNullFieldsPredicate<T>(entity)); log.info("{} has {} fields to be set (not null and @Settable)", resourceId, fieldsToBeSet.size()); Collection<String> fieldsWithValues = transform(fieldsToBeSet, new FieldNameToArrayNotationWithValueFunction<T>(entity)); log.info("Prepared array notation of data for {}", resourceId); return joinDataParts(fieldsWithValues); } ReflectionBodyGenerator(); @Override String asString(T entity);  }
@Test public void testAsString() throws Exception { String title = "Title"; String taskTypeName = "Bug"; Task task = new Task(title, taskTypeName); String encodedString = reflectionBodyGenerator.asString(task); assertThat(encodedString).contains("task[title]=Title"); assertThat(encodedString).contains("&"); assertThat(encodedString).contains("task[task_type_name]=Bug"); }