コード例 #1
0
  @Test
  public void testAddTask() {
    final String name = "test123";

    Task t = service.addTask(name);

    // check
    assertNotNull(t);
    assertEquals(name, t.getName());
    assertTrue(t.getId() > 0);
  }
コード例 #2
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) {
    }
  }