Package ma.glasnost.orika.test.unenhance.SuperTypeTestCaseClasses

Examples of ma.glasnost.orika.test.unenhance.SuperTypeTestCaseClasses.Book


        factory.registerClassMap(ClassMapBuilder.map(Book.class, BookMyDTO.class).byDefault().toClassMap());
       
        factory.build();
        MapperFacade mapper = factory.getMapperFacade();
       
        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);
       
View Full Code Here


        factory.registerClassMap(ClassMapBuilder.map(Book.class, BookMyDTO.class).byDefault(myHint).toClassMap());
       
        factory.build();
        MapperFacade mapper = factory.getMapperFacade();
       
        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

        factory.registerMappingHint(myHint);
        factory.build();
       
        MapperFacade mapper = factory.getMapperFacade();
       
        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());
       
        // 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

   
    // Now, these types are hidden from the current class-loader, but they implement types
    // that are accessible to this loader
    // -----------------------------------------------------------------------------
   
    Book book = createBook(hiddenBookType);
    book.setAuthor(createAuthor(hiddenAuthorType));
    Library lib = createLibrary(hiddenLibraryType);
    lib.getBooks().add(book);
   
    SoftReference<ClassLoader> ref = new SoftReference<ClassLoader>(childLoader);
   
View Full Code Here

      }
      // Now, these types are hidden from the current class-loader, but they implement types
      // that are accessible to this loader
      // -----------------------------------------------------------------------------
     
      Book book = createBook(hiddenBookType);
      book.setAuthor(createAuthor(hiddenAuthorType));
      Library lib = createLibrary(hiddenLibraryType);
      lib.getBooks().add(book);
     
      mappedLib = mapper.map(lib, LibraryMyDTO.class);
     
      // Just to be sure things mapped as expected
      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());
   
      // Now, set the soft reference before our hard references go out of scope
      childLoaderRef = new SoftReference<ClassLoader>(childLoader);
   
      book = null;
View Full Code Here

   
    return author;
  }
 
  private Book createBook(Class<? extends Book> type) throws InstantiationException, IllegalAccessException {
    Book book = (Book)type.newInstance();
    book.setTitle("The Prophet");
   
    return book;
  }
View Full Code Here

       
        return author;
    }
   
    private Book createBook(Class<? extends Book> type) throws InstantiationException, IllegalAccessException {
        Book book = type.newInstance();
        book.setTitle("The Prophet");
       
        return book;
    }
View Full Code Here

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

                .byDefault()
                .toClassMap());
       
        MapperFacade mapper = factory.getMapperFacade();
       
        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

       
        MapperFacade mapper = factory.getMapperFacade();
       
        // BookChild, AuthorChild, LibraryChild don't directly
        // implement Book, Author and Library
        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

TOP

Related Classes of ma.glasnost.orika.test.unenhance.SuperTypeTestCaseClasses.Book

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.