MappingProcessor implements Mapper { static List<?> prepareDestinationList(Collection<?> srcCollectionValue, Object field) { if (field == null) { return new ArrayList<>(srcCollectionValue.size()); } else { if (CollectionUtils.isList(field.getClass())) { return (List<?>)field; } else if (CollectionUtils.isArray(field.getClass())) { return new ArrayList<>(Arrays.asList((Object[])field)); } else { return new ArrayList<>(srcCollectionValue.size()); } } } protected  MappingProcessor(ClassMappings classMappings, Configuration globalConfiguration, CacheManager cacheMgr,
                               List<CustomConverter> customConverterObjects,
                               EventManager eventManager, CustomFieldMapper customFieldMapper,
                               Map<String, CustomConverter> customConverterObjectsWithId, BeanContainer beanContainer,
                               DestBeanCreator destBeanCreator, DestBeanBuilderCreator destBeanBuilderCreator,
                               BeanMappingGenerator beanMappingGenerator, PropertyDescriptorFactory propertyDescriptorFactory); T map(final Object srcObj, final Class<T> destClass); T map(final Object srcObj, final Class<T> destClass, final String mapId); void map(final Object srcObj, final Object destObj); void map(final Object srcObj, final Object destObj, final String mapId); @Override MapperModelContext getMapperModelContext();  }
@Test public void testPrepareDetinationList_StrangeCase() { List<?> result = MappingProcessor.prepareDestinationList(sourceList, "Hullo"); assertNotNull(result); assertEquals(new ArrayList<>(), result); }
@Test public void testPrepareDetinationList_OK() { List<?> result = MappingProcessor.prepareDestinationList(sourceList, destinationList); assertEquals(destinationList, result); destinationList.add(""); result = MappingProcessor.prepareDestinationList(sourceList, destinationList); assertEquals(destinationList, result); }
@Test public void testPrepareDetinationList_Null() { List<?> result = MappingProcessor.prepareDestinationList(sourceList, null); assertNotNull(result); assertEquals(new ArrayList<>(), result); }
@Test public void testPrepareDetinationList_Array() { List<?> result = MappingProcessor.prepareDestinationList(sourceList, new Object[] {"A"}); assertNotNull(result); assertEquals(1, result.size()); assertEquals("A", result.iterator().next()); }