Skip to content

Commit

Permalink
refactored addTask method to need column id and task model paraeters,…
Browse files Browse the repository at this point in the history
… not the class itself
  • Loading branch information
wennapengooin committed Aug 10, 2023
1 parent b99d722 commit cc9b426
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,17 @@
* A use case class for creating new tasks in a column
*/
public class AddTask {
private TaskModel taskModel;
private UUID idOfColumn;

private Project currentProject;

public AddTask(UUID idOfColumn, TaskModel model, Project currentProject) {
this.taskModel = model;
this.idOfColumn = idOfColumn;
public AddTask(Project currentProject) {
this.currentProject = currentProject;
}

/**
* This method creates the task and adds it to the column
*/
public void addTask() {
public void addTask(UUID idOfColumn, TaskModel taskModel) {
Task task = createTaskEntity(taskModel);

List<Column> listOfColumns = currentProject.getColumns();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ public void addNewTask(UUID idOfColumn, String taskName, String taskDescription,
.getProjectEntity();

// initialize use case class
AddTask useCase = new AddTask(idOfColumn, newTaskModel, currentProject);
AddTask useCase = new AddTask(currentProject);
// call use case class to create a new task and save it to the database
useCase.addTask();
useCase.addTask(idOfColumn, newTaskModel);
// Initialize TaskViewModel
TaskViewModel newTask = new TaskViewModel(newTaskModel);
// calls presenter to display message
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ public void setUp() {
@Test
public void testAddTask() {

AddTask addTaskUseCase = new AddTask(c.getID(), t, p);
AddTask addTaskUseCase = new AddTask(p);

addTaskUseCase.addTask();
addTaskUseCase.addTask(c.getID(), t);

assertEquals("t", c.getTasks().get(0).getName());
}
Expand Down

0 comments on commit cc9b426

Please sign in to comment.