Package ma.glasnost.orika

Examples of ma.glasnost.orika.MapperFactory


    private MapperFacade mapper;
    private MapperFacade addressMapper;

    public OrikaListMapper() {
        final MapperFactory factory = new DefaultMapperFactory.Builder().build();
        factory.registerClassMap(factory.classMap(Address.class, AddressDTO.class).
            field("addressLine1", "addressLine1").
            field("addressLine2", "addressLine2").
            field("postCode", "postCode").
            field("city", "city").
            field("country.name", "countryName").
            toClassMap()
        );
        factory.registerClassMap(factory.classMap(Person.class, PersonWithHistoryDTO.class).
            field("id", "id").
            field("name.firstname", "firstName").
            field("name.surname", "lastName").
            field("currentAddress", "currentAddress").
            field("previousAddresses", "previousAddresses").
            toClassMap()
        );
        this.mapper = factory.getMapperFacade();
    }
View Full Code Here


    private MapperFacade mapper;
    private MapperFacade addressMapper;

    public OrikaBasicMapper() {
        final MapperFactory factory = new DefaultMapperFactory.Builder().build();
        factory.registerClassMap(factory.classMap(Address.class, AddressDTO.class).
            field("addressLine1", "addressLine1").
            field("addressLine2", "addressLine2").
            field("postCode", "postCode").
            field("city", "city").
            field("country.name", "countryName").
            toClassMap()
        );
        factory.registerClassMap(factory.classMap(Person.class, PersonDTO.class).
            field("id", "id").
            field("name.firstname", "firstName").
            field("name.surname", "lastName").
            field("currentAddress", "currentAddress").
            toClassMap()
        );
        this.mapper = factory.getMapperFacade();
    }
View Full Code Here

    Assert.assertEquals(now, reverse);
  }
 
  @Test
  public void testDateToXmlGregorianCalendarConverter() {
    MapperFactory factory = MappingUtil.getMapperFactory();
    factory.getConverterFactory().registerConverter(new DateToXmlGregorianCalendarConverter());
    MapperFacade mapper = factory.getMapperFacade();
   
    Date now = new Date();
    XMLGregorianCalendar xml = mapper.map(now, XMLGregorianCalendar.class);
    Assert.assertEquals(now, xml.toGregorianCalendar().getTime());
   
View Full Code Here

    Assert.assertEquals(now, reverse);
  }
 
  @Test
  public void testCalendarToXmlGregorianCalendarConverter() {
    MapperFactory factory = MappingUtil.getMapperFactory();
    factory.getConverterFactory().registerConverter(new CalendarToXmlGregorianCalendarConverter());
    MapperFacade mapper = factory.getMapperFacade();
   
    Calendar cal = Calendar.getInstance();
    XMLGregorianCalendar xml = mapper.map(cal, XMLGregorianCalendar.class);
    Assert.assertEquals(cal.getTime(), xml.toGregorianCalendar().getTime());
   
View Full Code Here

    Assert.assertEquals(cal, reverse);
  }

  @Test
  public void testLongToXmlGregorianCalendarConverter() {
    MapperFactory factory = MappingUtil.getMapperFactory();
    factory.getConverterFactory().registerConverter(new LongToXmlGregorianCalendarConverter());
    MapperFacade mapper = factory.getMapperFacade();
   
    long now = System.currentTimeMillis();
    XMLGregorianCalendar xml = mapper.map(now, XMLGregorianCalendar.class);
   
    Assert.assertEquals(now, xml.toGregorianCalendar().getTimeInMillis());
View Full Code Here

    Assert.assertEquals(now, reverse);
  }
 
  @Test
  public void testLongToDateConverter() {
    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());
   
View Full Code Here

    Assert.assertEquals(now, reverse);
  }

  @Test
  public void testLongToCalendarConverter() {
    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());
   
View Full Code Here

        people.add(person);
        person = new Person();
        person.setName("B");
        people.add(person);
       
        MapperFactory factory = MappingUtil.getMapperFactory();
        factory.getConverterFactory().registerConverter(new ListConverter());
       
        PersonGroup group = factory.getMapperFacade().map(people, PersonGroup.class);
        Assert.assertNotNull(group);
        Assert.assertTrue(people.containsAll(group.getPeople()));
        Assert.assertTrue(group.getPeople().containsAll(people));
    }
View Full Code Here

        people.add(person);
       
        Type<Collection<Person>> personCollectionType = new TypeBuilder<Collection<Person>>(){}.build();
        Type<PersonGroup> personGroupType = TypeFactory.valueOf(PersonGroup.class);
       
        MapperFactory factory = MappingUtil.getMapperFactory();
        factory.getConverterFactory().registerConverter(new ListConverter());
       
        PersonGroup group = factory.getMapperFacade().map(people, personCollectionType, personGroupType);
        Assert.assertNotNull(group);
        Assert.assertTrue(people.containsAll(group.getPeople()));
        Assert.assertTrue(group.getPeople().containsAll(people));
    }
View Full Code Here

public class Issue53TestCase {
   
    @Test
    public void subClassSetterOrikaTest() {
        final MapperFactory mapperFactory = MappingUtil.getMapperFactory();/*new DefaultMapperFactory.Builder().build();*/
        final MapperFacade mapper = mapperFactory.getMapperFacade();
       
        final SearchRecord sr = new SearchRecord();
        sr.setScore(88);
       
        final Result result = new Result();
View Full Code Here

TOP

Related Classes of ma.glasnost.orika.MapperFactory

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.