@Test
public void testMapToArrayGeneration() throws Exception {
MapperFactory factory = MappingUtil.getMapperFactory();
factory.registerClassMap(
factory.classMap(MapWithSetter.class, GenericDto.class)
.field("testScores", "stringArray").byDefault());
/*
* Tell Orika how we should convert the map entries to the result array component type (String)
*/
factory.getConverterFactory().registerConverter(new CustomConverter<Map.Entry<String, Integer>, String>() {
public String convert(Map.Entry<String, Integer> source,
Type<? extends String> destinationType) {
return source.getKey();
}});
BoundMapperFacade<MapWithSetter, GenericDto> mapper = factory.getMapperFacade(MapWithSetter.class, GenericDto.class);
MapWithSetter source = new MapWithSetter();
Map<String, Integer> testScores = new LinkedHashMap<String, Integer>();
testScores.put("A", 90);