Package ma.glasnost.orika

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


    MapperFactory factory = MappingUtil.getMapperFactory();
    factory.getConverterFactory().registerConverter(new LongToDateConverter());
    MapperFacade mapper = factory.getMapperFacade();
   
    long now = System.currentTimeMillis();
    Date date = mapper.map(now, Date.class);
    Assert.assertEquals(now, date.getTime());
   
    long reverse = mapper.map(date, Long.class);
    Assert.assertEquals(now, reverse);
  }
View Full Code Here


   
    long now = System.currentTimeMillis();
    Date date = mapper.map(now, Date.class);
    Assert.assertEquals(now, date.getTime());
   
    long reverse = mapper.map(date, Long.class);
    Assert.assertEquals(now, reverse);
  }

  @Test
  public void testLongToCalendarConverter() {
View Full Code Here

    MapperFactory factory = MappingUtil.getMapperFactory();
    factory.getConverterFactory().registerConverter(new LongToCalendarConverter());
    MapperFacade mapper = factory.getMapperFacade();
   
    long now = System.currentTimeMillis();
    Calendar cal = mapper.map(now, Calendar.class);
    Assert.assertEquals(now, cal.getTimeInMillis());
   
    long reverse = mapper.map(cal, Long.class);
    Assert.assertEquals(now, reverse);
  }
View Full Code Here

   
    long now = System.currentTimeMillis();
    Calendar cal = mapper.map(now, Calendar.class);
    Assert.assertEquals(now, cal.getTimeInMillis());
   
    long reverse = mapper.map(cal, Long.class);
    Assert.assertEquals(now, reverse);
  }

 
}
View Full Code Here

    SpecialCase sc = new SpecialCase();
    sc.setChecked(true);
    sc.totalCost = new BigDecimal("42.50");
   
    MapperFacade mapper = MappingUtil.getMapperFactory().getMapperFacade();
    SpecialCaseDto dto = mapper.map(sc, SpecialCaseDto.class);
   
    Assert.assertEquals(sc.isChecked(), Boolean.valueOf(dto.isChecked()));
    //Assert.assertEquals(sc.totalCost.doubleValue(), dto.getTotalCost(), 0.01d);
  }
 
View Full Code Here

        MapperFacade mapper = factory.getMapperFacade();
       
        Wrapper source = new Wrapper();
        source.setWrapper(true);
       
        Primitive destination = mapper.map(source, Primitive.class);
        Assert.assertEquals(Boolean.TRUE, destination.isPrimitive());
       
    }
   
    @Test
View Full Code Here

        MapperFacade mapper = factory.getMapperFacade();
       
        Primitive source = new Primitive();
        source.setPrimitive(true);
       
        Wrapper destination = mapper.map(source, Wrapper.class);
        Assert.assertEquals(true, destination.getWrapper());
       
    }
   
    public static class Primitive {
View Full Code Here

        address.postalCode = "A1234FG";
        address.street = "1234 Easy St.";
        a.setAddress(address);
       
       
        B b = mapper.map(a, B.class);
       
        Assert.assertNotNull(b);
       
        A mapBack = mapper.map(b, A.class);
       
View Full Code Here

       
        B b = mapper.map(a, B.class);
       
        Assert.assertNotNull(b);
       
        A mapBack = mapper.map(b, A.class);
       
        Assert.assertEquals(a, mapBack);
       
    }
}
View Full Code Here

        MapperFacade mapper = factory.getMapperFacade();
       
        Book book = createBook(BookChild.class);
        book.setAuthor(createAuthor(AuthorChild.class));
       
        BookMyDTO mappedBook = mapper.map(book, BookMyDTO.class);
        Book mapBack = mapper.map(mappedBook, Book.class);
       
        Assert.assertNotNull(mappedBook);
        Assert.assertNotNull(mapBack);
       
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.