Testing Mapper

Concepts

Sitting on top of the framework described at Value-Object-Testing these tests allows to test a mapper implementing a java.util.function.Function to map a (pseudo-)DTO object based on whatever technology (FHIR, …​) to a DTO object. The actual test-method is verifyMapper(). The mapper-test-configuration is defined with @VerifyMapperConfiguration.

For simple uses-case, like well-designed beans there is no special configuration needed. Again there is a lot of reflection going on under the covers. See Managing Metadata, and Generator System and Reflection System for details.

Usage

@VerifyMapperConfiguration(equals = { "firstname:nameFirst", "lastname:nameLast", "attributeList:listOfAttributes" })
class MapperTestTest extends MapperTest<SimpleMapper, SimpleSourceBean, SimpleTargetBean> {

This test now generates source objects, the actual mapper-instance and maps the source objects through that instance. Then the individual properties will be verified as configured.

Take a look into @VerifyMapperConfiguration for the different ways to configure the verification. In addition the base class de.cuioss.test.valueobjects.MapperTest<M, S, T> provides a number of extension points to deal with trickier structures, see class-documentation for details.