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

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


    return book;
  }
 
  private Library createLibrary() throws InstantiationException, IllegalAccessException {
   
    Library lib = EasyMock.createNiceMock(LibraryParent.class);
    EasyMock.expect(lib.getTitle()).andReturn("Test Library").anyTimes();
    List<Book> books = new ArrayList<Book>();
    Book book = createBook();
    books.add(book);
    EasyMock.expect(lib.getBooks()).andReturn(books).anyTimes();
   
    EasyMock.replay(lib);
   
    return lib;
  }
View Full Code Here


  @Test
  public void testSuperTypeMappingForInaccessibleClasses() throws Exception {
   
    MapperFactory factory = MappingUtil.getMapperFactory();

    Library lib = createLibrary();
    Book book = lib.getBooks().get(0);
   
    LibraryDTO mappedLib = factory.getMapperFacade(Library.class, LibraryDTO.class).map(lib);
   
    Assert.assertNotNull(mappedLib);

    Assert.assertEquals(lib.getTitle(),mappedLib.getTitle());
    Assert.assertEquals(book.getTitle(),mappedLib.getBooks().get(0).getTitle());
    Assert.assertEquals(book.getAuthor().getName(),mappedLib.getBooks().get(0).getAuthor().getName());
   
  }
View Full Code Here

       
        return book;
    }
   
    private Library createLibrary(Class<? extends Library> type) throws InstantiationException, IllegalAccessException {
        Library lib = type.newInstance();
        lib.setTitle("Test Library");
       
        return lib;
    }
View Full Code Here

       
        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

       
        // 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

        // that are accessible to this loader
        // -----------------------------------------------------------------------------
       
        Book book = createBook(hiddenBookType);
        book.setAuthor(createAuthor(hiddenAuthorType));
        Library lib = createLibrary(hiddenLibraryType);
        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

    return book;
  }
 
  private Library createLibrary() throws InstantiationException, IllegalAccessException {
   
    Library lib = EasyMock.createNiceMock(LibraryParent.class);
    EasyMock.expect(lib.getTitle()).andReturn("Test Library").anyTimes();
    List<Book> books = new ArrayList<Book>();
    Book book = createBook();
    books.add(book);
    EasyMock.expect(lib.getBooks()).andReturn(books).anyTimes();
   
    EasyMock.replay(lib);
   
    return lib;
  }
View Full Code Here

  @Test
  public void testSuperTypeMappingForInaccessibleClasses() throws Exception {
   
    MapperFactory factory = MappingUtil.getMapperFactory();

    Library lib = createLibrary();
    Book book = lib.getBooks().get(0);
   
    LibraryDTO mappedLib = factory.getMapperFacade().map(lib, LibraryDTO.class);
   
    Assert.assertNotNull(mappedLib);

    Assert.assertEquals(lib.getTitle(),mappedLib.getTitle());
    Assert.assertEquals(book.getTitle(),mappedLib.getBooks().get(0).getTitle());
    Assert.assertEquals(book.getAuthor().getName(),mappedLib.getBooks().get(0).getAuthor().getName());
   
  }
View Full Code Here

TOP

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

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.