Package ma.glasnost.orika

Examples of ma.glasnost.orika.MapperFacade


   
    @Test
    public void testDoubleToShortConverter() {
        MapperFactory factory = MappingUtil.getMapperFactory();
        factory.getConverterFactory().registerConverter(new DoubleToShortConverter(false));
        MapperFacade mapper = factory.getMapperFacade();
       
        Double value = (double) Short.MAX_VALUE;
        Short result = mapper.map(value, Short.class);
        Assert.assertEquals(value.doubleValue(), result.doubleValue());
       
        Double reverse = mapper.map(result, Double.class);
        Assert.assertEquals(result.doubleValue(), reverse.doubleValue());
    }
View Full Code Here


   
    @Test
    public void testDoubleToIntegerConverter() {
        MapperFactory factory = MappingUtil.getMapperFactory();
        factory.getConverterFactory().registerConverter(new DoubleToIntegerConverter(false));
        MapperFacade mapper = factory.getMapperFacade();
       
        Double value = (double) Integer.MAX_VALUE;
        Integer result = mapper.map(value, Integer.class);
        Assert.assertEquals(value.doubleValue(), result.doubleValue());
       
        Double reverse = mapper.map(result, Double.class);
        Assert.assertEquals(result.doubleValue(), reverse.doubleValue());
    }
View Full Code Here

   
    @Test
    public void testDoubleToLongConverter() {
        MapperFactory factory = MappingUtil.getMapperFactory();
        factory.getConverterFactory().registerConverter(new DoubleToLongConverter(false));
        MapperFacade mapper = factory.getMapperFacade();
       
        Double value = (double) Long.MAX_VALUE;
        Long result = mapper.map(value, Long.class);
        Assert.assertEquals(value.doubleValue(), result.doubleValue());
       
        Double reverse = mapper.map(result, Double.class);
        Assert.assertEquals(result.doubleValue(), reverse.doubleValue());
    }
View Full Code Here

   
    @Test
    public void testFloatToShortConverter() {
        MapperFactory factory = MappingUtil.getMapperFactory();
        factory.getConverterFactory().registerConverter(new FloatToShortConverter(false));
        MapperFacade mapper = factory.getMapperFacade();
       
        Float value = (float) Short.MAX_VALUE;
        Short result = mapper.map(value, Short.class);
        Assert.assertEquals(value.floatValue(), result.floatValue());
       
        Float reverse = mapper.map(result, Float.class);
        Assert.assertEquals(result.floatValue(), reverse.floatValue());
    }
View Full Code Here

   
    @Test
    public void testFloatToIntegerConverter() {
        MapperFactory factory = MappingUtil.getMapperFactory();
        factory.getConverterFactory().registerConverter(new FloatToIntegerConverter(false));
        MapperFacade mapper = factory.getMapperFacade();
       
        Float value = (float) Integer.MAX_VALUE;
        Integer result = mapper.map(value, Integer.class);
        Assert.assertEquals(value.floatValue(), result.floatValue());
       
        Float reverse = mapper.map(result, Float.class);
        Assert.assertEquals(result.floatValue(), reverse.floatValue());
    }
View Full Code Here

   
    @Test
    public void testFloatToLongConverter() {
        MapperFactory factory = MappingUtil.getMapperFactory();
        factory.getConverterFactory().registerConverter(new FloatToLongConverter(false));
        MapperFacade mapper = factory.getMapperFacade();
       
        Float value = (float) Long.MAX_VALUE;
        Long result = mapper.map(value, Long.class);
        Assert.assertEquals(value.floatValue(), result.floatValue());
       
        Float reverse = mapper.map(result, Float.class);
        Assert.assertEquals(result.floatValue(), reverse.floatValue());
    }
View Full Code Here

   
    @Test(expected = MappingException.class)
    public void testLongToShortConverter_overflow() {
        MapperFactory factory = MappingUtil.getMapperFactory();
        factory.getConverterFactory().registerConverter(new LongToShortConverter(false));
        MapperFacade mapper = factory.getMapperFacade();
       
        Long value = (long) Short.MAX_VALUE + 1;
        Short result = mapper.map(value, Short.class);
        Assert.assertEquals(value.longValue(), result.longValue());
       
        Long reverse = mapper.map(result, Long.class);
        Assert.assertEquals(result.longValue(), reverse.longValue());
    }
View Full Code Here

   
    @Test(expected = MappingException.class)
    public void testLongToIntegerConverter_overflow() {
        MapperFactory factory = MappingUtil.getMapperFactory();
        factory.getConverterFactory().registerConverter(new LongToIntegerConverter(false));
        MapperFacade mapper = factory.getMapperFacade();
       
        Long value = (long) Integer.MAX_VALUE + 1;
        Integer result = mapper.map(value, Integer.class);
        Assert.assertEquals(value.longValue(), result.longValue());
       
        Long reverse = mapper.map(result, Long.class);
        Assert.assertEquals(result.longValue(), reverse.longValue());
    }
View Full Code Here

  public void testBooleanMapping() {
    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

   
    @Test(expected = MappingException.class)
    public void testIntegerToShortConverter_overflow() {
        MapperFactory factory = MappingUtil.getMapperFactory();
        factory.getConverterFactory().registerConverter(new IntegerToShortConverter(false));
        MapperFacade mapper = factory.getMapperFacade();
       
        Integer value = (int) Short.MAX_VALUE + 1;
        Short result = mapper.map(value, Short.class);
        Assert.assertEquals(value.intValue(), result.intValue());
       
        Integer reverse = mapper.map(result, Integer.class);
        Assert.assertEquals(result.intValue(), reverse.intValue());
    }
View Full Code Here

TOP

Related Classes of ma.glasnost.orika.MapperFacade

Copyright © 2018 www.massapicom. 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.