Package ma.glasnost.orika

Examples of ma.glasnost.orika.MapperFacade.map()


        int transforms = 0;
        try {
            for (Parent parent : parents) {
                transforms++;
               
                Parent result = facade.map(parent, Parent.class);
               
                for (One one : result.oneList)
                    for (Two two : one.twos)
                        Assert.assertNotNull(two.getName());
               
View Full Code Here


        MapperFacade mapper = factory.getMapperFacade();
       
        Product p = new Product();
        p.setTempCal(new Date());
       
        ProductDTO result = mapper.map(p, ProductDTO.class);
       
        Assert.assertEquals(p.getTempCal(), result.getTempCal().getTime());
    }
   
    @Test
View Full Code Here

        MapperFacade mapper = factory.getMapperFacade();
       
        Product p = new Product();
        p.setTempCal(new Date());
       
        ProductDTO result = mapper.map(p, ProductDTO.class);
       
        Assert.assertEquals(p.getTempCal(), result.getTempCal().getTime());
    }
   
}
View Full Code Here

        supplier.getContacts().add(ct);
       
        MapperFactory mapperFactory = MappingUtil.getMapperFactory();
        MapperFacade mapper = mapperFactory.getMapperFacade();
       
        SupplierDto result = mapper.map(supplier, SupplierDto.class);
       
        Assert.assertNotNull(result);
        Assert.assertEquals(supplier.getAddresses().size(), result.getAddresses().size());
        Assert.assertEquals(supplier.getContacts().size(), result.getContacts().size());
        for (int i=0; i < supplier.getContacts().size(); ++i) {
View Full Code Here

        dtos.add(dto);
       
        DtoHolder source = new DtoHolder();
        source.setEntities(dtos);
       
        final EntityHolder entities = mapperFacade.map(source, EntityHolder.class);
       
        Assert.assertNotNull(entities);
        Assert.assertEquals(3, entities.getEntities().size());
       
    }
View Full Code Here

    source.setLongValue(System.currentTimeMillis());
    source.setName("PPPPP");
    source.setSex('H');
    source.setVip(true);

    WrapperAttributes destination = mapper.map(source, WrapperAttributes.class);

    Assert.assertEquals(Integer.valueOf(source.getAge()), destination.getAge());
    Assert.assertEquals(source.getName(), destination.getName());
    Assert.assertEquals(Character.valueOf(source.getSex()), destination.getSex());
    Assert.assertEquals(source.getVip(), destination.getVip());
View Full Code Here

    source.setLongValue(System.currentTimeMillis());
    source.setName("PPPPP");
    source.setSex('H');
    source.setVip(true);

    PrimitiveAttributes destination = mapper.map(source, PrimitiveAttributes.class);

    Assert.assertEquals(source.getAge(), Integer.valueOf(destination.getAge()));
    Assert.assertEquals(source.getName(), destination.getName());
    Assert.assertEquals(source.getSex(), Character.valueOf(destination.getSex()));
    Assert.assertEquals(source.getVip(), destination.getVip());
View Full Code Here

  public void testToString_withoutConverter() {
    MapperFactory factory = new DefaultMapperFactory.Builder().useBuiltinConverters(false).build();
    MapperFacade mapper = factory.getMapperFacade();
   
    Date now = new Date();
    String string = mapper.map(now, String.class);
    Assert.assertFalse(now.toString().equals(string));
  }
 
  @Test
  public void testToString() {
View Full Code Here

    source.setLongValue(System.currentTimeMillis());
    source.setName("PPPPP");
    source.setSex('H');
    source.setVip(true);

    OtherWrapperAttributes destination = mapper.map(source, OtherWrapperAttributes.class);

    Assert.assertEquals(source.getAge(), Integer.valueOf(destination.getAge()));
    Assert.assertEquals(source.getName(), destination.getName());
    Assert.assertEquals(source.getSex(), Character.valueOf(destination.getSex()));
    Assert.assertEquals(source.getVip(), destination.getVip());
View Full Code Here

    MapperFactory factory = MappingUtil.getMapperFactory();
    factory.getConverterFactory().registerConverter(new ToStringConverter());
    MapperFacade mapper = factory.getMapperFacade();
   
    Date now = new Date();
    String string = mapper.map(now, String.class);
    Assert.assertEquals(now.toString(), string);
  }
}
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.