Package com.davidsalter.apps.todo.model

Examples of com.davidsalter.apps.todo.model.ToDoItem


     */
    @Before
    public void prepareTest() throws Exception {
        utx.begin();
        for (String title : ITEM_DESCRIPTIONS) {
            ToDoItem item = new ToDoItem(title);
            em.persist(item);
        }
        utx.commit();
    }
View Full Code Here


    /**
     * Test the ToDoItemController.addItem() method.
     */
    @Test
    public void testAddItem() {
        ToDoItem item = new ToDoItem("A test item");
        toDoItemController.addItem(item);
        List<ToDoItem> items = toDoItemController.getItems();
        Assert.assertEquals("Invalid number of items returned after adding an item", ITEM_DESCRIPTIONS.length + 1, items.size());
    }
View Full Code Here

    /**
     * Test the ToDoItemController.editItem() method.
     */
    @Test
    public void testEditItem() {
        ToDoItem item = new ToDoItem("A test item");
        toDoItemController.addItem(item);
        Integer id = item.getId();

        String newDescription = "A new description";
        item.setDescription(newDescription);
        toDoItemController.editItem(item);
        Assert.assertEquals("Invalid edit of item", newDescription, item.getDescription());

        ToDoItem copyItem = toDoItemController.getItem(id);
        Assert.assertEquals("Invalid edit of item", newDescription, copyItem.getDescription());
    }
View Full Code Here

    @Test
    public void testGetItem() {

        List<ToDoItem> items = toDoItemController.getItems();
        for (ToDoItem item : items) {
            ToDoItem fromDatabase = toDoItemController.getItem(item.getId());
            Assert.assertEquals("Invalid id retrieved", fromDatabase.getId(), item.getId());
            Assert.assertEquals("Invalid description retrieved", fromDatabase.getDescription(), item.getDescription());
        }
    }
View Full Code Here

    ToDoItem toDelete = null;
    ToDoItem item = null;
    Date lastRefresh = null;

    public ToDoBean() {
        item = new ToDoItem();
    }
View Full Code Here

     *
     * @return The JSF return navigation.
     */
    public String addConfirmedItem() {
        todoItemController.addItem(item);
        item = new ToDoItem();
        return "items";
    }
View Full Code Here

     *
     * @return The JSF return navigation.
     */
    public String editConfirmedItem() {
        todoItemController.editItem(item);
        item = new ToDoItem();
        return "items";
    }
View Full Code Here

     * Aborts the editing of a confirmed item.
     *
     * @return The JSF return navigation.
     */
    public String cancelConfirmedItem() {
        item = new ToDoItem();
        return "items";
    }
View Full Code Here

     */
    @Before
    public void prepareTest() throws Exception {
        utx.begin();
        for (String title : ITEM_DESCRIPTIONS) {
            ToDoItem item = new ToDoItem(title);
            em.persist(item);
        }
        utx.commit();
    }
View Full Code Here

    public void testDeleteItem() {
        String expectedReturn = "confirm";

        Assert.assertNull(toDoBean.getToDelete());

        ToDoItem item = new ToDoItem();
        String returnValue = toDoBean.deleteItem(item);
        Assert.assertSame("Item to be deleted is not set correctly", item, toDoBean.getToDelete());
        Assert.assertEquals("Return path is incorrectly set", expectedReturn, returnValue);

    }
View Full Code Here

TOP

Related Classes of com.davidsalter.apps.todo.model.ToDoItem

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.