Package ma.glasnost.orika.impl

Examples of ma.glasnost.orika.impl.ConfigurableMapper


public class Issue41TestCase {
   
    @Test
    public void test_converter_string_to_enum_direct_working() {
       
        ConfigurableMapper mapper = new ConfigurableMapper() {
           
            @Override
            public void configure(MapperFactory factory) {
               
                factory.registerClassMap(factory.classMap(MySourceObject.class, MyTargetObject.class).field("e", "directE")
               
                .toClassMap());
               
                factory.getConverterFactory().registerConverter(new MyEnumConverter());
            }
        };
       
        MySourceObject s = new MySourceObject();
        s.setE("un");
        MyTargetObject t = mapper.map(s, MyTargetObject.class);
        Assert.assertEquals(MyEnum.one, t.getDirectE());
    }
View Full Code Here


   
    @Test
    @Concurrent(200)
    public void test_converter_string_to_string_nested_not_working() {
       
        ConfigurableMapper mapper = new ConfigurableMapper() {
           
            @Override
            public void configure(MapperFactory factory) {
               
                factory.registerClassMap(factory.classMap(MySourceObject.class, MyTargetObject.class)//
                        .field("e", "sub.s")
                        .toClassMap());
               
                factory.getConverterFactory().registerConverter(new MyEnumConverter());
            }
        };
       
        MySourceObject s = new MySourceObject();
        s.setE("un");
        MyTargetObject t = mapper.map(s, MyTargetObject.class);
        Assert.assertEquals("un", t.getSub().getS());
    }
View Full Code Here

    }
   
    @Test
    public void test_converter_string_to_enum_nested_not_working() {
       
        ConfigurableMapper mapper = new ConfigurableMapper() {
           
            @Override
            public void configure(MapperFactory factory) {
                factory.getConverterFactory().registerConverter(new MyEnumConverter());
               
                factory.registerClassMap( //
                    factory.classMap(MySourceObject.class, MyTargetObject.class)//
                          .field("e", "sub.e")
                          .toClassMap());
               
            }
        };
       
        MySourceObject s = new MySourceObject();
        s.setE("un");
        MyTargetObject t = mapper.map(s, MyTargetObject.class);
        Assert.assertEquals(MyEnum.one, t.getSub().getE());
    }
View Full Code Here

public class Issue68TestCase {

  @Test
  public void testSimpleReverceCase() {
    ConfigurableMapper mapper = new ConfigurableMapper() {
      @Override
      public void configure(MapperFactory mapperFactory) {
        mapperFactory.classMap(InvoiceItem.class, InvoiceItemVO.class).byDefault().register();
        mapperFactory.classMap(ProjectItem.class, ProjectItemVO.class).byDefault().register();
        mapperFactory.classMap(Project.class, ProjectVO.class).byDefault().register();     
      }

    };

    ProjectVO projectVO = new ProjectVO();
    ProjectItemVO projectItemVO = new ProjectItemVO();
    InvoiceItemVO invoiceitemVO = new InvoiceItemVO();

    projectItemVO.project = projectVO;
    invoiceitemVO.project = projectVO;

    projectVO.getProjectItems().add(projectItemVO);
    projectVO.name = "Great project";
    projectItemVO.getInvoiceItems().add(invoiceitemVO);

    invoiceitemVO.getProjectItems().add(projectItemVO);

    InvoiceItemProxy invoiceItemProxy = BeanFactory
        .createInvoiceItemProxy();
    mapper.map(invoiceitemVO, invoiceItemProxy);


  }
View Full Code Here

TOP

Related Classes of ma.glasnost.orika.impl.ConfigurableMapper

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.