Package dao

Examples of dao.ContactDao


    @Test
    public void baseDaoTest() {
        running(fakeApplication(inMemoryDatabase()), new Runnable() {
            public void run() {
                try {
                    ContactDao dao = DaoManager.getContactDao();
                    Contact c1 = new Contact();
                    c1.setFirstName("Jack");
                    c1.setLastName("Jones");
                    dao.persist(c1);

                    assertNotNull("saved contact id is null", c1.getId());
                    Contact c2 = dao.findById(c1.getId());
                    assertEquals("names are not equal", c2.getFirstName(), c1.getFirstName());
                    dao.remove(c2);
                    Contact c3 = dao.findById(c1.getId());
                    assertNull("removed contact is not null", c3);
                } catch (DataAccessException e) {
                    e.printStackTrace();
                }
            }
View Full Code Here


    @Test
    public void getBatchTest() {
        running(fakeApplication(inMemoryDatabase()), new Runnable() {
            public void run() {
                ContactDao dao = DaoManager.getContactDao();
                for (int i = 0; i < 18; i++) {
                    Contact c = new Contact();
                    c.setFirstName("Contact" + i);
                    c.setLastName("Jones" + i);
                    try {
                        dao.persist(c);
                    } catch (DataAccessException e) {
                        e.printStackTrace();
                    }
                }

                List<Contact> batch1 = null;
                List<Contact> batch2 = null;
                List<Contact> batch3 = null;
                try {
                    batch1 = dao.getBatch(0, 10);
                    batch2 = dao.getBatch(1, 10);
                    batch3 = dao.getBatch(4, 10);
                } catch (DataAccessException e) {
                    e.printStackTrace();
                }
                assertTrue(batch1.size() == 10);
                assertTrue(batch2.size() == 8);
View Full Code Here

TOP

Related Classes of dao.ContactDao

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.