Package ma.glasnost.orika

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


       
        final Result result = new Result();
        result.setBaseRecords(new Record());
        result.setResult(sr);
       
        final Result2 mappedResult = mapper.map(result, Result2.class);
       
        assertEquals(88, mappedResult.getResult().getScore());
    }
   
    public static class Record {
View Full Code Here


  public void testConvertToEnum() {
    MapperFactory factory = MappingUtil.getMapperFactory();
    factory.getConverterFactory().registerConverter(new FromStringConverter());
    MapperFacade mapper = factory.getMapperFacade();
   
    Fruit fruit = mapper.map("TOMATO", Fruit.class);
    Assert.assertEquals(Fruit.TOMATO, fruit);
   
  }
 
  @Test
View Full Code Here

   
    MapperFactory factory = MappingUtil.getMapperFactory();
    factory.getConverterFactory().registerConverter(new FromStringConverter());
    MapperFacade mapper = factory.getMapperFacade();
   
    int age = mapper.map("21", int.class);
    Assert.assertEquals(21, age);
  }
 
  @Test
  public void testConvertToWrapper() {
View Full Code Here

  public void testConvertToWrapper() {
    MapperFactory factory = MappingUtil.getMapperFactory();
    factory.getConverterFactory().registerConverter(new FromStringConverter());
    MapperFacade mapper = factory.getMapperFacade();
   
    Integer age = mapper.map("21", Integer.class);
    Assert.assertEquals(Integer.valueOf(21), age);
  }
 
  enum Fruit {
    APPLE,
View Full Code Here

        MapperFacade mapperFacade = factory.getMapperFacade();
       
        C c = new C();
        c.setDate(new Date());
       
        A a = mapperFacade.map(c, A.class);
       
        Assert.assertEquals(new SimpleDateFormat("dd-MM-yyyy").format(c.getDate()), a.getDate());
       
        B b = new B();
        b.setDate(new Date());
View Full Code Here

        Assert.assertEquals(new SimpleDateFormat("dd-MM-yyyy").format(c.getDate()), a.getDate());
       
        B b = new B();
        b.setDate(new Date());
       
        a = mapperFacade.map(b, A.class);
       
        Assert.assertEquals(new SimpleDateFormat("dd/MM/yyyy").format(b.getDate()), a.getDate());
       
    }
}
View Full Code Here

        Book book = createBook(BookParent.class);
        book.setAuthor(createAuthor(AuthorParent.class));
        Library lib = createLibrary(LibraryParent.class);
        lib.getBooks().add(book);
       
        LibraryMyDTO mappedLib = mapper.map(lib, LibraryMyDTO.class);
       
        Assert.assertNotNull(mappedLib);
        Assert.assertTrue(mappedLib.getMyBooks().isEmpty());
    }
   
View Full Code Here

        Book book = createBook(BookParent.class);
        book.setAuthor(createAuthor(AuthorParent.class));
        Library lib = createLibrary(LibraryParent.class);
        lib.getBooks().add(book);
       
        LibraryMyDTO mappedLib = mapper.map(lib, LibraryMyDTO.class);
       
        Assert.assertEquals(lib.getTitle(), mappedLib.getMyTitle());
        Assert.assertEquals(book.getTitle(), mappedLib.getMyBooks().get(0).getMyTitle());
        Assert.assertEquals(book.getAuthor().getName(), mappedLib.getMyBooks().get(0).getMyAuthor().getMyName());
    }
View Full Code Here

        Book book = createBook(BookParent.class);
        book.setAuthor(createAuthor(AuthorParent.class));
        Library lib = createLibrary(LibraryParent.class);
        lib.getBooks().add(book);
       
        LibraryMyDTO mappedLib = mapper.map(lib, LibraryMyDTO.class);
       
        Assert.assertEquals(lib.getTitle(), mappedLib.getMyTitle());
        Assert.assertEquals(book.getTitle(), mappedLib.getMyBooks().get(0).getMyTitle());
        Assert.assertEquals(book.getAuthor().getName(), mappedLib.getMyBooks().get(0).getMyAuthor().getMyName());
       
View Full Code Here

        Assert.assertEquals(book.getTitle(), mappedLib.getMyBooks().get(0).getMyTitle());
        Assert.assertEquals(book.getAuthor().getName(), mappedLib.getMyBooks().get(0).getMyAuthor().getMyName());
       
        // Now, map it back to the original...
       
        Library lib2 = mapper.map(mappedLib, Library.class);
        Assert.assertEquals(lib.getTitle(), lib2.getTitle());
        Assert.assertEquals(book.getTitle(), lib2.getBooks().get(0).getTitle());
        Assert.assertEquals(book.getAuthor().getName(), lib2.getBooks().get(0).getAuthor().getName());
       
    }
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.