DozerBeanMapper implements Mapper, MapperModelContext { @Override public void map(Object source, Object destination, String mapId) throws MappingException { getMappingProcessor().map(source, destination, mapId); } DozerBeanMapper(List<String> mappingFiles,
                    BeanContainer beanContainer,
                    DestBeanCreator destBeanCreator,
                    DestBeanBuilderCreator destBeanBuilderCreator,
                    BeanMappingGenerator beanMappingGenerator,
                    PropertyDescriptorFactory propertyDescriptorFactory,
                    List<CustomConverter> customConverters,
                    List<MappingFileData> mappingsFileData,
                    List<EventListener> eventListeners,
                    CustomFieldMapper customFieldMapper,
                    Map<String, CustomConverter> customConvertersWithId,
                    ClassMappings customMappings,
                    Configuration globalConfiguration,
                    CacheManager cacheManager); @Override void map(Object source, Object destination, String mapId); @Override T map(Object source, Class<T> destinationClass, String mapId); @Override T map(Object source, Class<T> destinationClass); @Override void map(Object source, Object destination); @Override MappingMetadata getMappingMetadata(); @Override MapperModelContext getMapperModelContext(); @Override List<String> getMappingFiles(); @Override List<CustomConverter> getCustomConverters(); @Override Map<String, CustomConverter> getCustomConvertersWithId(); @Override List<? extends EventListener> getEventListeners(); @Override CustomFieldMapper getCustomFieldMapper();  }
@Test public void shouldBeThreadSafe() throws Exception { Mapper mapper = DozerBeanMapperBuilder.create() .withMappingFiles("mappings/testDozerBeanMapping.xml") .build(); final CountDownLatch latch = new CountDownLatch(THREAD_COUNT); for (int i = 0; i < THREAD_COUNT; i++) { new Thread(new Runnable() { public void run() { try { mapper.map(new TestObject(), TestObjectPrime.class); } finally { latch.countDown(); } } }).start(); } latch.await(); assertTrue(exceptions.isEmpty()); }
@Test public void shouldReturnImmutableResources() throws Exception { mapper.map("Hello", String.class); assertImmutable("mappingFiles", mapper); assertImmutable("customConverters", mapper); assertImmutable("customConvertersWithId", mapper); assertImmutable("eventListeners", mapper); }
@Test public void shouldSetEventListeners() { EventListener listener = mock(EventListener.class); Mapper beanMapper = DozerBeanMapperBuilder.create() .withEventListener(listener) .build(); beanMapper.map(new Object(), new Object()); verify(listener).onMappingStarted(any()); verify(listener).onMappingFinished(any()); verifyNoMoreInteractions(listener); }