mardi 24 mars 2015

How to unit test xml based dozer mappings

I have a system where mapping of backend to frontend objects (DTOs) is mainly done by applying Dozer mappings selectively. Those mappings are configured via XML.


The code looks like this:



scope2hits.get(scope)
.add(getMapper().map(srcElement, TargetElement.class));


"Unfortunately" I wrote unit tests for the class containing the above code and since getMapper() returns a mocked (Mockito) Mapper, the resulting element is null. This is okay for testing amounts but not identity of returned elements.


Is there a way to unit test the class without building the complete context (including not copying the xml files to test context)?


Aucun commentaire:

Enregistrer un commentaire