public class IncludeReturnDataStrategyTest {
@Test
public void testBuildSerializationMap() {
IncludeReturnDataStrategy strategy = new IncludeReturnDataStrategy(new DirectReturnIncludeStrategy() {
@Override
public String[] fieldPatterns() {
return new String[]{"prop1", "prop2", "multiple.prop1"};
}
@Override
public Class<? extends Annotation> annotationType() {
return DirectReturnIncludeStrategy.class;
}
});
ResultObject result = new ResultObject("prop", 2, new ResultObject("nestedProp", 1));
ResultObject multipleItem1 = new ResultObject("multipleProp1", 3);
ResultObject multipleItem2 = new ResultObject("multipleProp2", 4);
result.addMultiple(multipleItem1);
result.addMultiple(multipleItem2);
Map<Object, List<String>> serializationMap = strategy.buildSerializationMap(result);
assertNotNull(serializationMap);
assertEquals(3, serializationMap.size());
List<String> rootFieldList = serializationMap.get(result);
assertNotNull(rootFieldList);
assertEquals(3, rootFieldList.size());