Added Tests for TaskState Changes. Actually added functionality to pass that test.
This commit is contained in:
@@ -54,4 +54,19 @@ public class AssignmentManager {
|
||||
}
|
||||
taskMap.remove(taskId);
|
||||
}
|
||||
public void finishTask(int workerId, int taskId) {
|
||||
if (!workerMap.containsKey(workerId) || !taskMap.containsKey(taskId)) {
|
||||
throw new IllegalArgumentException("Task Id or Worker Id does not exist");
|
||||
}
|
||||
Task task = taskMap.get(taskId);
|
||||
task.setTaskState(TaskState.FINISHED);
|
||||
}
|
||||
public void unfinishTask(int workerId, int taskId) {
|
||||
if (!workerMap.containsKey(workerId) || !taskMap.containsKey(taskId)) {
|
||||
throw new IllegalArgumentException("Task Id or Worker Id does not exist");
|
||||
}
|
||||
Task task = taskMap.get(taskId);
|
||||
task.setTaskState(TaskState.IN_PROGRESS);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -6,12 +6,14 @@ public class Task {
|
||||
int taskId;
|
||||
int workerId;
|
||||
AssignmentManager manager;
|
||||
TaskState state;
|
||||
public Task(int taskId, int workerId, String name, String description, AssignmentManager manager) {
|
||||
this.manager = manager;
|
||||
this.name = name;
|
||||
this.description = description;
|
||||
this.taskId = taskId;
|
||||
this.workerId = workerId;
|
||||
this.state = TaskState.IN_PROGRESS;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
@@ -32,5 +34,11 @@ public class Task {
|
||||
public int getWorkerId() {
|
||||
return workerId;
|
||||
}
|
||||
public void setTaskState(TaskState state) {
|
||||
this.state = state;
|
||||
}
|
||||
public TaskState getTaskState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user