Closed
Description
Describe the bug
BeanTableSchema does not correctly convert document beans when they are used in a collection (eg: List, Map<String, DocumentBean>).
Expected Behavior
These items should be converted correctly.
Current Behavior
An exception is thrown stating a converter cannot be found for the DocumentBean class.
Repro
@Test
public void documentBean_list_correctlyMapsAttributes() {
BeanTableSchema<DocumentBean> beanTableSchema = BeanTableSchema.create(DocumentBean.class);
AbstractBean abstractBean1 = new AbstractBean();
abstractBean1.setAttribute2("two");
AbstractBean abstractBean2 = new AbstractBean();
abstractBean2.setAttribute2("three");
DocumentBean documentBean = new DocumentBean();
documentBean.setId("id-value");
documentBean.setAttribute1("one");
documentBean.setAbstractBeanList(Arrays.asList(abstractBean1, abstractBean2));
AttributeValue expectedDocument1 = AttributeValue.builder()
.m(singletonMap("attribute2", stringValue("two")))
.build();
AttributeValue expectedDocument2 = AttributeValue.builder()
.m(singletonMap("attribute2", stringValue("three")))
.build();
AttributeValue expectedList = AttributeValue.builder().l(expectedDocument1, expectedDocument2).build();
Map<String, AttributeValue> itemMap = beanTableSchema.itemToMap(documentBean, false);
assertThat(itemMap.size(), is(3));
assertThat(itemMap, hasEntry("id", stringValue("id-value")));
assertThat(itemMap, hasEntry("attribute1", stringValue("one")));
assertThat(itemMap, hasEntry("abstractBeanList", expectedList));
}