Search in sources :

Example 16 with User

use of com.cmput301w18t05.taskzilla.User 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 17 with User

use of com.cmput301w18t05.taskzilla.User in project Taskzilla by CMPUT301W18T05.

the class UserProfileIntentTest method testkTaskProfile.

public void testkTaskProfile() {
    MainActivity activity = (MainActivity) solo.getCurrentActivity();
    solo.assertCurrentActivity("Wrong Activity", MainActivity.class);
    solo.clickOnText("Sign Up");
    solo.assertCurrentActivity("Wrong Activity", SignUpActivity.class);
    solo.enterText((EditText) solo.getView(R.id.usernameField), "TestUser");
    solo.enterText((EditText) solo.getView(R.id.nameField), "TestName");
    solo.enterText((EditText) solo.getView(R.id.emailField), "Test@Email.com");
    solo.enterText((EditText) solo.getView(R.id.passwordField), "a");
    solo.enterText((EditText) solo.getView(R.id.phoneField), "1234567890");
    solo.clickOnButton("Sign Up");
    // valid login
    solo.enterText((EditText) solo.getView(R.id.usernameText), "TestUser");
    solo.enterText((EditText) solo.getView(R.id.passwordText), "a");
    solo.clickOnButton("Log In");
    solo.assertCurrentActivity("Wrong Activity", WelcomeActivity.class);
    // create new task
    solo.waitForText("Tasks");
    View fab = solo.getView(R.id.fab);
    solo.clickOnView(fab);
    solo.assertCurrentActivity("Wrong Activity", NewTaskActivity.class);
    // validate info
    solo.enterText((EditText) solo.getView(R.id.TaskName), "Test Task Name");
    solo.enterText((EditText) solo.getView(R.id.Description), "Test Description");
    solo.clickOnButton("Add Task");
    assertTrue(solo.waitForText("Test Task Name"));
    // check intent of other user profile
    solo.clickInList(0);
    solo.assertCurrentActivity("Wrong Activity", ViewTaskActivity.class);
    solo.waitForText("Test Task Name");
    ImageButton editButton = (ImageButton) solo.getView(R.id.RequesterPicture);
    solo.clickOnView(editButton);
    solo.sleep(500);
    solo.assertCurrentActivity("Wrong Activity", ProfileActivity.class);
    // checks if name of user matches name in profile
    assertTrue(solo.waitForText(currentUser.getInstance().getName()));
    // checks if email of user matches email in profile
    assertTrue(solo.waitForText(currentUser.getInstance().getEmail().toString()));
    // checks if phone of user matches phone in profile
    assertTrue(solo.waitForText(currentUser.getInstance().getPhone().toString()));
}
Also used : ImageButton(android.widget.ImageButton) MainActivity(com.cmput301w18t05.taskzilla.activity.MainActivity) View(android.view.View)

Example 18 with User

use of com.cmput301w18t05.taskzilla.User in project Taskzilla by CMPUT301W18T05.

the class TasksRequesterFragment method updateRequested.

/**
 * if filter is requested, retrieve all requests owned by current user
 * from elastic search that have status 'requested'
 */
public void updateRequested() {
    ArrayList<Task> res = cUser.getTasksRequested();
    taskList.clear();
    for (Task t : res) {
        if (t.getStatus().equalsIgnoreCase("requested")) {
            taskList.add(t);
        }
    }
    adapter.notifyDataSetChanged();
}
Also used : Task(com.cmput301w18t05.taskzilla.Task)

Example 19 with User

use of com.cmput301w18t05.taskzilla.User in project Taskzilla by CMPUT301W18T05.

the class TasksRequesterFragment method updateAssigned.

/**
 * if filter is assigned, retrieve all requests owned by current user from
 * elastic search that have status 'assigned'
 */
public void updateAssigned() {
    ArrayList<Task> res = cUser.getTasksRequested();
    taskList.clear();
    for (Task t : res) {
        if (t.getStatus().equalsIgnoreCase("assigned")) {
            taskList.add(t);
        }
    }
    adapter.notifyDataSetChanged();
}
Also used : Task(com.cmput301w18t05.taskzilla.Task)

Example 20 with User

use of com.cmput301w18t05.taskzilla.User in project Taskzilla by CMPUT301W18T05.

the class TasksRequesterFragment method updateCompleted.

/**
 * if filter is completed, retrieve all requests owned by current user from
 * elastic search that have status 'completed'
 */
public void updateCompleted() {
    ArrayList<Task> res = cUser.getTasksRequested();
    taskList.clear();
    for (Task t : res) {
        if (t.getStatus().equalsIgnoreCase("completed")) {
            taskList.add(t);
        }
    }
    adapter.notifyDataSetChanged();
}
Also used : Task(com.cmput301w18t05.taskzilla.Task)

Aggregations

View (android.view.View)13 Task (com.cmput301w18t05.taskzilla.Task)11 AddUserRequest (com.cmput301w18t05.taskzilla.request.command.AddUserRequest)8 AlertDialog (android.support.v7.app.AlertDialog)6 ListView (android.widget.ListView)6 TextView (android.widget.TextView)6 Photo (com.cmput301w18t05.taskzilla.Photo)6 EditText (android.widget.EditText)5 AddTaskRequest (com.cmput301w18t05.taskzilla.request.command.AddTaskRequest)5 ArrayList (java.util.ArrayList)5 Intent (android.content.Intent)4 ColorDrawable (android.graphics.drawable.ColorDrawable)4 ActionBar (android.support.v7.app.ActionBar)4 RecyclerView (android.support.v7.widget.RecyclerView)4 AdapterView (android.widget.AdapterView)4 ImageButton (android.widget.ImageButton)4 User (com.cmput301w18t05.taskzilla.User)4 DialogInterface (android.content.DialogInterface)3 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)3 ArrayAdapter (android.widget.ArrayAdapter)3