Package se.ironic.modweb.domain.entity

Examples of se.ironic.modweb.domain.entity.TodoList


            userTransaction.begin();
            List all = crudService.findByNamedQuery(TodoList.ALL);
            assertEquals(0, all.size());

            String name = "Testlist";
            TodoList list = new TodoList(name);
            /* Test create */
            TodoList create = crudService.create(list);

            all = crudService.findByNamedQuery(TodoList.ALL);
            assertEquals(1, all.size());

            /* find flushes so after we should have id in "create" */
            assertNotNull(create.getId());
            assertNotNull(create.getVersion());

            assertEquals(name, create.getName());
            name = "Changed";
            create.setName(name);
            /* Test update */
            TodoList update = crudService.update(create);

            /* Test find (and that update worked) */
            TodoList find = crudService.find(TodoList.class, create.getId());
            assertNotNull(find);
            assertEquals(name, find.getName());

            /* Test delete */
            crudService.delete(find);

            all = crudService.findByNamedQuery(TodoList.ALL);
View Full Code Here


    @Test(expected = OptimisticLockException.class)
    public void testFailVersion() throws Exception {
        try {
            userTransaction.begin();
            TodoList todoList = new TodoList("Testlist");
            TodoList create = crudService.create(todoList);

            crudService.flush();
            crudService.getEntityManager().detach(todoList);
            List all = crudService.findByNamedQuery(TodoList.ALL);
            assertEquals(1, all.size());
            TodoList find = crudService.find(TodoList.class, create.getId());

            find.setName("Changed");
            crudService.update(find);
            crudService.flush();

            find = crudService.find(TodoList.class, find.getId());
            assertNotSame(todoList.getVersion(), find.getVersion());

            crudService.update(todoList);
            fail("Should have gotten Optimistic lock Ex.");
        } finally {
            userTransaction.rollback();
View Full Code Here

    @Test
    public void testListWithEntries() throws Exception {
        try {
            userTransaction.begin();
            TodoList todoList = new TodoList("Testlist");

            TodoEntry te1 = creteEntry("#1", "d:#1");
            todoList.getEntries().add(te1);
            TodoList create = crudService.create(todoList);
            crudService.flush();
            List<TodoList> all = crudService.findByNamedQuery(TodoList.ALL);
            assertEquals(1, all.size());
            assertEquals(1, all.iterator().next().getEntries().size());
           
            Long id = create.getId();
           
            crudService.flush();
            TodoList find = crudService.find(TodoList.class, id);
            TodoEntry te2 = creteEntry("#2", "d:#2");
            find.getEntries().add(te2);
           
            crudService.update(find);
            crudService.flush();
            crudService.getEntityManager().clear();
           
            find = crudService.find(TodoList.class, id);
            Iterator<TodoEntry> iterator = find.getEntries().iterator();
            iterator.next();
            iterator.remove();
           
            crudService.flush();
            crudService.getEntityManager().clear();
View Full Code Here

TOP

Related Classes of se.ironic.modweb.domain.entity.TodoList

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.