@Test public void AddTest_When_GivenTodoEntityWithNameThatExistedBefore_ExpectFalse(){ TodoEntity alreadyExistingTodo = new TodoEntity(); alreadyExistingTodo.setId(1); alreadyExistingTodo.setStatus(TodoStatusType.OPEN); alreadyExistingTodo.setName("Test already existing name"); TodoEntity todoToAdd = new TodoEntity(); todoToAdd.setName(alreadyExistingTodo.getName()); when(todoDAO.findByName(alreadyExistingTodo.getName())).thenReturn(alreadyExistingTodo); assertThat(todoService.add(todoToAdd)).isFalse(); }
public boolean add(TodoEntity entity) { if(todoDAO.findByName(entity.getName())!=null) return false; entity.setStatus(TodoStatusType.OPEN); todoDAO.saveOrUpdate(entity); return true; }
TodoService { public boolean add(TodoEntity entity) { if(todoDAO.findByName(entity.getName())!=null) return false; entity.setStatus(TodoStatusType.OPEN); todoDAO.saveOrUpdate(entity); return true; } }
TodoService { public boolean add(TodoEntity entity) { if(todoDAO.findByName(entity.getName())!=null) return false; entity.setStatus(TodoStatusType.OPEN); todoDAO.saveOrUpdate(entity); return true; }  }
TodoService { public boolean add(TodoEntity entity) { if(todoDAO.findByName(entity.getName())!=null) return false; entity.setStatus(TodoStatusType.OPEN); todoDAO.saveOrUpdate(entity); return true; }  List<TodoEntity> getAll(); boolean add(TodoEntity entity); boolean edit(TodoEntity entity); boolean delete(long id); }
TodoService { public boolean add(TodoEntity entity) { if(todoDAO.findByName(entity.getName())!=null) return false; entity.setStatus(TodoStatusType.OPEN); todoDAO.saveOrUpdate(entity); return true; }  List<TodoEntity> getAll(); boolean add(TodoEntity entity); boolean edit(TodoEntity entity); boolean delete(long id);  }