Exemplo n.º 1
0
  @Test
  public void dateEqualityTest() throws ParseException {
    Book book = new Book();
    book.setId(1);
    book.setReciever("Mario");
    book.setAmountSent(2);
    SimpleDateFormat sdf = new SimpleDateFormat("dd/M/yyyy");
    Date date = sdf.parse("24/11/2014");
    book.setDateRecieved(date);

    Dao<Integer, Book> dao = dbLite.getDao(Book.class);
    long rowID = dao.create(book);
    Assert.assertEquals(book.getId(), rowID);

    Book book2 = new Book();
    book2.setId(2);
    book2.setReciever("Mario");
    book2.setAmountSent(2);
    book2.setDateRecieved(new Date());

    long rowID2 = dao.create(book2);
    Assert.assertEquals(book2.getId(), rowID2);

    List<Book> books = dao.findAll(null, null, "dateRecieved > ?", date);
    Assert.assertTrue(books.size() > 0);
  }
Exemplo n.º 2
0
  @Test
  public void createMethodGetterAndSetterTest() {
    Book book = new Book();
    book.setDateRecieved(new Date());
    book.setRecieved(true);
    book.setReciever("some");

    Dao<Integer, Book> dao = dbLite.getDao(Book.class);
    long id = dao.create(book);
    Assert.assertTrue(id > 0);
  }
Exemplo n.º 3
0
  @Test
  public void privateFieldsGetterAndSetterMethodTest() {
    Book book = new Book();
    book.setId(1);
    book.setReciever("Mario");
    book.setAmountSent(2);
    book.setDateRecieved(new Date());
    book.setRecieved(true);

    Dao<Integer, Book> dao = dbLite.getDao(Book.class);
    long rowID = dao.create(book);
    Assert.assertEquals(book.getId(), rowID);

    Book bookDB = dao.findById(book.getId());
    Assert.assertEquals(book.getReciever(), bookDB.getReciever());
    Assert.assertEquals(book.getAmountSent(), bookDB.getAmountSent());
    Assert.assertEquals(book.isRecieved(), bookDB.isRecieved());
    Assert.assertEquals(book.getDateRecieved(), bookDB.getDateRecieved());
  }