use of ma.glasnost.orika.MapperFactory in project tutorials by eugenp.
the class OrikaUnitTest method givenSrcWithNullAndGlobalConfigForNoNull_whenFailsToMap_ThenCorrect.
@Test
public void givenSrcWithNullAndGlobalConfigForNoNull_whenFailsToMap_ThenCorrect() {
MapperFactory mapperFactory = new DefaultMapperFactory.Builder().mapNulls(false).build();
mapperFactory.classMap(Source.class, Dest.class);
MapperFacade mapper = mapperFactory.getMapperFacade();
Source src = new Source(null, 10);
Dest dest = new Dest("Clinton", 55);
mapper.map(src, dest);
assertEquals(dest.getAge(), src.getAge());
assertEquals(dest.getName(), "Clinton");
}
use of ma.glasnost.orika.MapperFactory in project useful-java-links by Vedenin.
the class OrikaHelloWorld method main.
public static void main(String[] args) {
// init mapper
MapperFactory mapperFactory = new DefaultMapperFactory.Builder().build();
mapperFactory.classMap(Source.class, Destination.class).field("message", "text").register();
MapperFacade mapper = mapperFactory.getMapperFacade();
// convert
Source source = new Source("Hello World!");
Destination destObject = mapper.map(source, Destination.class);
// print Hello World!
destObject.print();
}
Aggregations