Package net.sf.autodao.impl

Examples of net.sf.autodao.impl.Book


  private SessionFactory sessionFactory;

  @Test
  public void testJoda() {
    final DateMidnight date = new DateMidnight(1970, 1, 1);
    final Book book = new Book("SpringNamespaceTest", date);
    dao.create(book);
    Assert.assertEquals(dao.findByPublishDate(date), Arrays.asList(book));
  }
View Full Code Here


    Assert.assertEquals(dao.findByPublishDate(date), Arrays.asList(book));
  }

  @Test
  public void testCrud() {
    final Book b = new Book("Crud", new DateMidnight());
    dao.create(b);
    Assert.assertTrue(sessionFactory.getCurrentSession().contains(b));
    dao.update(b);
    Assert.assertTrue(sessionFactory.getCurrentSession().contains(b));
    Assert.assertSame(b, dao.get(b.getPrimaryKey()));
    dao.delete(b);
    Assert.assertFalse(sessionFactory.getCurrentSession().contains(b));
    Assert.assertNull(dao.get(b.getPrimaryKey()));
  }
View Full Code Here

    Assert.assertNull(dao.get(b.getPrimaryKey()));
  }

  @Test
  public void testSaveOrUpdate() {
    final Book b = new Book("SaveOrUpdate", new DateMidnight());
    dao.saveOrUpdate(b);
    Assert.assertTrue(sessionFactory.getCurrentSession().contains(b));
    Assert.assertSame(b, dao.get(b.getPrimaryKey()));
    dao.delete(b);
  }
View Full Code Here

    dao.delete(b);
  }

  @Test
  public void testDao() {
    final Book book = new Book("SpringNamespaceTest", new DateMidnight());
    dao.create(book);
    final Set<Book> books = dao.findAll();
    Assert.assertEquals(books, Collections.singleton(book));
    final Book byTitle = dao.findByTitle("SpringNamespaceTest");
    Assert.assertEquals(byTitle, book);
  }
View Full Code Here

    Assert.assertEquals(byTitle, book);
  }

  @Test
  public void testLimitOffset() {
    final Book b1 = new Book("_aaa", new DateMidnight());
    dao.create(b1);
    final Book b2 = new Book("_bbb", new DateMidnight());
    dao.create(b2);
    final Book b3 = new Book("_ccc", new DateMidnight());
    dao.create(b3);
    final List<Book> books = dao.findLimitOffset(1, 1);
    Assert.assertEquals(books, Arrays.asList(b2));
  }
View Full Code Here

    Assert.assertEquals(books, Arrays.asList(b2));
  }

  @Test
  public void testParameterList() {
    final Book b1 = new Book("param1", new DateMidnight());
    dao.create(b1);
    final Book b2 = new Book("param2", new DateMidnight());
    dao.create(b2);
    final Book b3 = new Book("param3", new DateMidnight());
    dao.create(b3);
    final List<Book> books1 = dao.findByIds(1, new long[] { b1.getPrimaryKey(), b2.getPrimaryKey() });
    Assert.assertEquals(books1, Arrays.asList(b1));
    final List<Book> books2 = dao.findByObjectIds(new Long[] { b1.getPrimaryKey(), b2.getPrimaryKey() });
    Assert.assertEquals(books2, Arrays.asList(b1, b2));
View Full Code Here

TOP

Related Classes of net.sf.autodao.impl.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.