@Test public void testAddTask() { final String name = "test123"; Task t = service.addTask(name); // check assertNotNull(t); assertEquals(name, t.getName()); assertTrue(t.getId() > 0); }
@Test public void testAddDuplicateTask() { final String name = "test123"; Task t = service.addTask(name); // check assertNotNull(t); assertEquals(name, t.getName()); assertTrue(t.getId() > 0); try { service.addTask(name); fail("it shouldn't allow add the same task name into list"); } catch (IllegalArgumentException ex) { } }