Search in sources :

Example 1 with AddTaskRequest

use of com.cmput301w18t05.taskzilla.request.command.AddTaskRequest in project Taskzilla by CMPUT301W18T05.

the class BidTest method testSetBid.

/**
 * Test for setting the bid
 */
public void testSetBid() {
    User user = new User();
    Task task = new Task();
    AddUserRequest userRequest = new AddUserRequest(user);
    RequestManager.getInstance().invokeRequest(userRequest);
    userRequest.getResult();
    AddTaskRequest request = new AddTaskRequest(task);
    RequestManager.getInstance().invokeRequest(request);
    request.getResult();
    float bidAmount = 10.00f;
    Bid bid = new Bid(user.getId(), task.getId(), 10.00f);
    assertEquals(bid.getBidAmount(), bidAmount);
}
Also used : AddTaskRequest(com.cmput301w18t05.taskzilla.request.command.AddTaskRequest) AddUserRequest(com.cmput301w18t05.taskzilla.request.command.AddUserRequest)

Example 2 with AddTaskRequest

use of com.cmput301w18t05.taskzilla.request.command.AddTaskRequest in project Taskzilla by CMPUT301W18T05.

the class RequestManagerTest method testAddTaskRequest.

public void testAddTaskRequest() {
    AddTaskRequest addTaskRequest = new AddTaskRequest(task);
    RequestManager.getInstance().invokeRequest(ctx, addTaskRequest);
    assertTrue(addTaskRequest.getResult());
}
Also used : AddTaskRequest(com.cmput301w18t05.taskzilla.request.command.AddTaskRequest)

Example 3 with AddTaskRequest

use of com.cmput301w18t05.taskzilla.request.command.AddTaskRequest in project Taskzilla by CMPUT301W18T05.

the class Task method setStatus.

/**
 * changes task status to bidded if it is previously requested
 * or changes it to requested if there are no longer any bids
 * @param newStatus incoming new status that may be the new task status
 */
public void setStatus(String newStatus) {
    if ((this.status.equals("requested") && newStatus.equals("bidded")) || (this.status.equals("bidded") && newStatus.equals("requested")) && this.getBids().size() == 1) {
        this.status = newStatus;
        AddTaskRequest request = new AddTaskRequest(this);
        RequestManager.getInstance().invokeRequest(request);
    }
// if newStatus == "assigned" delete all bids under this task
}
Also used : AddTaskRequest(com.cmput301w18t05.taskzilla.request.command.AddTaskRequest)

Example 4 with AddTaskRequest

use of com.cmput301w18t05.taskzilla.request.command.AddTaskRequest in project Taskzilla by CMPUT301W18T05.

the class UserTest method testGetTasksRequested.

// Test for getting a list of tasks that the user has requested
public void testGetTasksRequested() {
    User user = new User();
    user.setUsername("abc");
    AddUserRequest addUserRequest = new AddUserRequest(user);
    RequestManager.getInstance().invokeRequest(getActivity(), addUserRequest);
    Task task1 = new Task("Task name", user, "Task description");
    AddTaskRequest addTaskRequest1 = new AddTaskRequest(task1);
    RequestManager.getInstance().invokeRequest(getActivity(), addTaskRequest1);
    Task task2 = new Task("Task name", user, "Task description");
    AddTaskRequest addTaskRequest2 = new AddTaskRequest(task2);
    RequestManager.getInstance().invokeRequest(getActivity(), addTaskRequest2);
    ArrayList<Task> tasks = new ArrayList<>();
    tasks.add(task1);
    tasks.add(task2);
    ArrayList<Task> result = new ArrayList<>();
    result = user.getTasksRequested();
    assertTrue(tasks.containsAll(result) && result.containsAll(tasks));
}
Also used : ArrayList(java.util.ArrayList) AddTaskRequest(com.cmput301w18t05.taskzilla.request.command.AddTaskRequest) AddUserRequest(com.cmput301w18t05.taskzilla.request.command.AddUserRequest)

Example 5 with AddTaskRequest

use of com.cmput301w18t05.taskzilla.request.command.AddTaskRequest in project Taskzilla by CMPUT301W18T05.

the class Task method updateThis.

public void updateThis() {
    AddTaskRequest req = new AddTaskRequest(this);
    req.setUpdate(true);
    RequestManager.getInstance().invokeRequest(req);
}
Also used : AddTaskRequest(com.cmput301w18t05.taskzilla.request.command.AddTaskRequest)

Aggregations

AddTaskRequest (com.cmput301w18t05.taskzilla.request.command.AddTaskRequest)10 AddUserRequest (com.cmput301w18t05.taskzilla.request.command.AddUserRequest)3 Intent (android.content.Intent)2 EditText (android.widget.EditText)2 Task (com.cmput301w18t05.taskzilla.Task)2 ArrayList (java.util.ArrayList)1