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));
}
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()));
}
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();
}
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();
}
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();
}
Aggregations