Package org.jrest.dao.test.entities

Examples of org.jrest.dao.test.entities.Book


            new JpaGuiceModuleProvider(),
            (new DaoModuleProvider("org.jrest4guice.dao.test.jpa", "org.jrest4guice.dao.jpa"))
                    .addActionContextProviders(new JpaContextProvider())).init();
    bookDao = context.getBean(BookDao.class);
   
    Book b0 = getNewBook("Book 0", 10f, 10);
    Book b1 = getNewBook("Book 1", 10f, 20);
    Book b2 = getNewBook("Book 2", 10f, 30);
    Book b3 = getNewBook("Book 3", 10f, 40);
    Book b4 = getNewBook("Book 4", 10f, 50);
    Book b5 = getNewBook("Book 5", 20f, 60);
    Book b6 = getNewBook("Book 6", 20f, 70);
    Book b7 = getNewBook("Book 7", 20f, 80);
    Book b8 = getNewBook("Book 8", 20f, 90);
    Book b9 = getNewBook("Book 9", 20f, 100);
    bookDao.create(b0, b1, b2, b3, b4, b5, b6, b7, b8, b9);
   
    pk = b0.getId();
    Assert.assertNotNull(b0.getId());
    Assert.assertNotNull(b1.getId());
    Assert.assertNotNull(b2.getId());
    Assert.assertNotNull(b3.getId());
    Assert.assertNotNull(b4.getId());
    Assert.assertNotNull(b5.getId());
    Assert.assertNotNull(b6.getId());
    Assert.assertNotNull(b7.getId());
    Assert.assertNotNull(b8.getId());
    Assert.assertNotNull(b9.getId());
   
    dao = context.getBean(RetrieveDao.class);
    Assert.assertNotNull(dao);
  }
View Full Code Here


    Assert.assertNotNull(dao);
  }
 
  @Test
  public void testLoadByPk() {
    Book book = dao.loadByPk(pk);
    Assert.assertNotNull(book);
    Assert.assertEquals(pk, book.getId());
  }
View Full Code Here

    Assert.assertEquals(pk, book.getId());
  }
 
  @Test
  public void testLoadByTitle() {
    Book book = dao.loadByTitle("Book 0");
    Assert.assertNotNull(book);
    Assert.assertEquals(pk, book.getId());
  }
View Full Code Here

    Assert.assertEquals(pk, book.getId());
  }
 
  @Test
  public void testLoadByQuery() {
    Book book = dao.loadByQuery("Book 0");
    Assert.assertNotNull(book);
    Assert.assertEquals(pk, book.getId());
  }
View Full Code Here

    Assert.assertEquals(pk, book.getId());
  }
 
  @Test
  public void testLoadByNamedQuery() {
    Book book = dao.loadByNamedQuery("Book 0");
    Assert.assertNotNull(book);
    Assert.assertEquals(pk, book.getId());
  }
View Full Code Here

  private static Book getNewBook(String title, float price, int length) {
    PackingInfo info = new PackingInfo("平装", "铜版纸", length);
    List<Author> authors = new ArrayList<Author>();
    authors.add(new Author("gzYangfan"));
   
    Book book = new Book();
    book.setTitle(title);
    book.setSummary("java");
    book.setPrice(price);
    book.setPackingInfo(info);
    book.setAuthors(authors);
   
    return book;
  }
View Full Code Here

            (new DaoModuleProvider("org.jrest4guice.dao.test.jpa", "org.jrest4guice.dao.jpa"))
                    .addActionContextProviders(new JpaContextProvider()),
            new JpaGuiceModuleProvider()).init();
    dao = context.getBean(BookDao.class);
   
    Book b0 = getNewBook("Book 0", 10f, 10);
    Book b1 = getNewBook("Book 1", 10f, 20);
    Book b2 = getNewBook("Book 2", 10f, 30);
    Book b3 = getNewBook("Book 3", 10f, 40);
    Book b4 = getNewBook("Book 4", 10f, 50);
    Book b5 = getNewBook("Book 5", 20f, 60);
    Book b6 = getNewBook("Book 6", 20f, 70);
    Book b7 = getNewBook("Book 7", 20f, 80);
    Book b8 = getNewBook("Book 8", 20f, 90);
    Book b9 = getNewBook("Book 9", 20f, 100);
    dao.create(b0, b1, b2, b3, b4, b5, b6, b7, b8, b9);
    Assert.assertNotNull(b0.getId());
    Assert.assertNotNull(b1.getId());
    Assert.assertNotNull(b2.getId());
    Assert.assertNotNull(b3.getId());
    Assert.assertNotNull(b4.getId());
    Assert.assertNotNull(b5.getId());
    Assert.assertNotNull(b6.getId());
    Assert.assertNotNull(b7.getId());
    Assert.assertNotNull(b8.getId());
    Assert.assertNotNull(b9.getId());
  }
View Full Code Here

  private static Book getNewBook(String title, float price, int length) {
    PackingInfo info = new PackingInfo("平装", "铜版纸", length);
    List<Author> authors = new ArrayList<Author>();
    authors.add(new Author("gzYangfan"));
   
    Book book = new Book();
    book.setTitle(title);
    book.setSummary("java");
    book.setPrice(price);
    book.setPackingInfo(info);
    book.setAuthors(authors);
   
    return book;
  }
View Full Code Here

  @Test
  public void test() {
    BookDao dao = (BookDao) dynamicProxy.createDao(BookDao.class);
   
    Book b1 = getNewBook("Book 1", 10f, 10);
    Book b2 = getNewBook("Book 2", 20f, 20);

    dao.create(b1, b2);
    log.debug("Book1 ID:" + b1.getId());
    log.debug("Book2 ID:" + b2.getId());
   
    Book o1 = dao.load(b1.getId());
    Book o2 = dao.load(b2.getId());
    Assert.assertNotNull(o1);
    Assert.assertNotNull(o2);
   
    b1.setTitle("Edited 1");
    b2.setTitle("Edited 2");
    dao.update(b1, b2);
    o1 = dao.load(b1.getId());
    o2 = dao.load(b2.getId());
    Assert.assertEquals(b1.getTitle(), o1.getTitle());
    Assert.assertEquals(b2.getTitle(), o2.getTitle());
   
    dao.delete(b1, b2);
    o1 = dao.load(b1.getId());
    o2 = dao.load(b2.getId());
    Assert.assertNull(o1);
View Full Code Here

  private Book getNewBook(String title, float price, int length) {
    PackingInfo info = new PackingInfo("平装", "铜版纸", length);
    List<Author> authors = new ArrayList<Author>();
    authors.add(new Author("gzYangfan"));
   
    Book book = new Book();
    book.setTitle(title);
    book.setSummary("java");
    book.setPrice(price);
    book.setPackingInfo(info);
    book.setAuthors(authors);
   
    return book;
  }
View Full Code Here

TOP

Related Classes of org.jrest.dao.test.entities.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.