TaskServiceImpl implements TaskService { @Override public void addOrUpdate(Task task) { if (task.getId() == null) { throw new IllegalArgumentException("Id property must be set"); } tasks.put(task.getId(), task); } TaskServiceImpl(); @Override Task getById(Integer id); @Override void addOrUpdate(Task task); @Override Collection<Task> getAll(); @Override void delete(Integer id);  }
@Test(expected = IllegalArgumentException.class) public void testAddIllegal() { Task task = new Task(); taskService.addOrUpdate(task); }