Package ma.glasnost.orika

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


       
        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);
       
        Assert.assertEquals(book.getAuthor().getName(), mappedBook.getMyAuthor().getMyName());
View Full Code Here


        Order order = new Order();
        order.setNumber("CPC6128");
        order.setCustomer(customer);
       
        MapperFacade mapperFacade = mapperFactory.getMapperFacade();
        OrderDTO orderDto = mapperFacade.map(order, OrderDTO.class);
       
        Assert.assertEquals(address.line1 + " " + address.line2, orderDto.getShippingAddress());
    }
   
    public static class Address {
View Full Code Here

        MapperFacade mapper = MappingUtil.getMapperFactory().getMapperFacade();
       
        Book book = createBook(BookChild.class);
        book.setAuthor(createAuthor(AuthorChild.class));
       
        BookMyDTO mappedBook = mapper.map(book, BookMyDTO.class);
       
        Assert.assertNotNull(mappedBook);
        Assert.assertNull(mappedBook.getMyTitle());
        Assert.assertNull(mappedBook.getMyAuthor());
    }
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(BookChild.class);
        book.setAuthor(createAuthor(AuthorChild.class));
        Library lib = createLibrary(LibraryChild.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

        MapperFacade mapper = factory.getMapperFacade();
       
        Book book = createBook(BookChild.class);
        book.setAuthor(createAuthor(AuthorChild.class));
       
        BookMyDTO mappedBook = mapper.map(book, BookMyDTO.class);
       
        Assert.assertEquals(book.getTitle(), mappedBook.getMyTitle());
        Assert.assertEquals(book.getAuthor().getName(), mappedBook.getMyAuthor().getMyName());
    }
   
View Full Code Here

        ClassMapBuilder<Order, OrderData> builder = ClassMapBuilder.map(Order.class, OrderData.class);
        ClassMap<Order, OrderData> classMap = builder.field("id", "number").byDefault().toClassMap();
        mapperFactory.registerClassMap(classMap);
        MapperFacade facade = mapperFactory.getMapperFacade();
        OrderData data = new OrderData(1234l);
        Order order = facade.map(data, Order.class);
        Assert.assertEquals(Long.valueOf(1234l), order.getId());
    }
   
    public static class OrderIdConverter extends CustomConverter<Long, OrderID> {
       
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);
       
        Assert.assertEquals(book.getTitle(), mappedBook.getMyTitle());
        Assert.assertEquals(book.getAuthor().getName(), mappedBook.getMyAuthor().getMyName());
    }
   
View Full Code Here

       
        Address adress = new Address();
        adress.setCountry("Morocco");
        adress.setCity("Marrakesh");
       
        AddressDTO adressDTO = mapper.map(adress, AddressDTO.class);
       
        Assert.assertEquals(adress.getCountry(), adressDTO.getCountryName());
        Assert.assertEquals(adress.getCity(), adressDTO.getCityName());
    }
   
View Full Code Here

        MyEntity child = new MyEntity("child");
        root.getChildren().add(child);
        root.getChildren().add(root);
        child.addChild(root);
       
        MyDto myDto = mapperFacade.map(root, MyDto.class);
        Assert.assertEquals(myDto.getCaption(), root.getCaption());
       
        // System.out.println("myDto = " + myDto);
       
    }
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.