Exemplo n.º 1
0
 @Test
 public void testFind() {
   task = new Task();
   dao.insert(task);
   // verify task was created
   assertNotNull(task.getId());
   // find the added task
   Task found = (Task) dao.find(task.getId());
   assertEquals(task, found);
 }
Exemplo n.º 2
0
 @Test
 public void testInsert() {
   Project project = new Project(1l);
   task = new Task(project);
   dao.insert(task);
   assertNotNull(task.getId());
 }
Exemplo n.º 3
0
 @Test
 public void testDelete() {
   task = new Task();
   dao.insert(task);
   Long id = task.getId();
   // verify task was created
   assertNotNull(id);
   // delete the task
   dao.delete(task);
   // try to find it by id
   Task t = dao.find(id);
   // verify task was not found
   assertNull(t);
 }
Exemplo n.º 4
0
  @Test
  public void testUpdate() {
    task = new Task();
    dao.insert(task);
    Long id = task.getId();

    // modify the task
    String desc = "new description";
    task.setDescription(desc);
    int duration = 1;
    task.setDuration(duration);
    dao.merge(task);

    // test update
    Task t = (Task) dao.find(id);
    assertEquals(desc, t.getDescription());
    assertEquals(duration, t.getDuration());
  }