Exemplo n.º 1
0
 @Test
 public void find_findsTaskInDatabase_true() {
   Task myTask = new Task("Mow the lawn", 1);
   myTask.save();
   Task savedTask = Task.find(myTask.getId());
   assertTrue(myTask.equals(savedTask));
 }
Exemplo n.º 2
0
  /**
   * Method remove list element in linked task list that contains the task
   *
   * @param task that is searched
   * @return boolean remote task
   */
  public boolean remove(Task task) {
    if (task == null) throw new IllegalArgumentException("task == null");

    if (size() == 0) return false;

    boolean taskFound = false;
    ListEl currentListEl = firstListEl;
    while (currentListEl != null) {
      if (task.equals(currentListEl.getTaskLink())) {
        taskFound = true;
        break;
      }

      currentListEl = currentListEl.getNextListEl();
    }

    if (taskFound) {

      if (size() == 1) {
        firstListEl = null;
        lastListEl = null;
        size--;

        return true;
      } else if (size() == 2) {
        firstListEl = currentListEl.getNextListEl();
        lastListEl = currentListEl.getNextListEl();

        firstListEl.setPreviousListEl(null);
        firstListEl.setNextListEl(null);

        size--;

        return true;
      } else {

        if (currentListEl.equals(firstListEl)) {
          firstListEl = currentListEl.getNextListEl();
          firstListEl.setPreviousListEl(null);
        } else if (currentListEl.equals(lastListEl)) {
          lastListEl = currentListEl.getPreviousListEl();
          lastListEl.setNextListEl(null);
        } else {
          ListEl currLPrevL = currentListEl.getPreviousListEl();
          ListEl currLNextL = currentListEl.getNextListEl();

          currLPrevL.setNextListEl(currLNextL);
          currLNextL.setPreviousListEl(currLPrevL);
        }

        size--;

        return true;
      }

    } else {
      return false;
    }
  }
  @Override
  public LocalTask activateTask(@NotNull final Task origin, boolean clearContext) {
    LocalTask activeTask = getActiveTask();
    if (origin.equals(activeTask)) return activeTask;

    saveActiveTask();

    if (clearContext) {
      myContextManager.clearContext();
    }
    myContextManager.restoreContext(origin);

    final LocalTask task = doActivate(origin, true);

    return restoreVcsContext(task);
  }
Exemplo n.º 4
0
  /**
   * method that delete task from list
   *
   * @param task that need delete
   * @return <code>true</code> if the task delete <code>false</code> if the task does not delete
   */
  public boolean remove(Task task) throws Exception {
    if (task == null) throw new Exception("incoming task is null");

    int i; // to find a match for the entire array
    int j; // to move an item after the first found
    boolean itemFound; // status delete
    itemFound = false;

    for (i = 0; i < numberOfSizeArrayTask; i++) { // Not ArrayTask.length-1!
      if (task.equals(arrayTask[i])) {
        // delete the last element
        if (i == numberOfSizeArrayTask - 1) {
          arrayTask[i] = null;
          numberOfSizeArrayTask--;

          // copy old array in new
          Task tempArrayTask[] = new Task[numberOfSizeArrayTask];
          for (int k = 0; k < numberOfSizeArrayTask; k++) tempArrayTask[k] = arrayTask[k];
          arrayTask = tempArrayTask;

          itemFound = true;
          break;
        }

        // not last element, fist found
        for (j = i; j < numberOfSizeArrayTask - 1; j++) {
          arrayTask[j] = arrayTask[j + 1];
        }
        arrayTask[numberOfSizeArrayTask - 1] = null;
        numberOfSizeArrayTask--;

        // copy old array in new
        Task tempArrayTask[] = new Task[numberOfSizeArrayTask];
        for (int k = 0; k < numberOfSizeArrayTask; k++) tempArrayTask[k] = arrayTask[k];
        arrayTask = tempArrayTask;

        itemFound = true;
        break;
      }
    }
    // task is not found in the array
    if (!itemFound) {
      return false;
    }
    // task delete
    return true;
  }
  /** Test for third service option. Creates and gets a test task. */
  @Test
  public void testCreateTaskWithService3HashCheck() {
    String result = null;
    boolean pass = false;
    Task testTask = JaxbUtils.xmlToTask(testXMLTask);

    // Service 3
    String[] args1 = {testXMLTask, "3"};
    invokeServiceMethod("createTask", args1);
    String[] args2 = {"TestAttendee", "3"};
    result = invokeServiceMethod("getAttendantTasks", args2);
    TaskList taskList = JaxbUtils.xmlToTaskList(result);
    Iterator<Task> it = taskList.list.iterator();
    Task task = null;
    while (it.hasNext()) {
      task = it.next();
      if (task.equals(testTask)) {
        pass = true;
        break;
      }
    }
    assertTrue(pass);
  }
  @Test
  public void testGetTask() {
    Task testTask = new Task(1, "Task2", Priority.HIGH);

    assertTrue(testTask.equals(userstory.getTaskById(1)));
  }
Exemplo n.º 7
0
 @Test
 public void equals_returnsTrueIfDescriptionsAretheSame() {
   Task firstTask = new Task("Mow the lawn", 1);
   Task secondTask = new Task("Mow the lawn", 1);
   assertTrue(firstTask.equals(secondTask));
 }