-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
60 additions
and
0 deletions.
There are no files selected for viewing
60 changes: 60 additions & 0 deletions
60
.../use_cases/project_viewing_and_modification_use_cases/ChangeTaskCompletionStatusTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package b_application_business_rules.use_cases.project_viewing_and_modification_use_cases; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertNull; | ||
|
||
import b_application_business_rules.use_cases.project_viewing_and_modification_use_cases.ChangeTaskCompletionStatus; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import a_enterprise_business_rules.entities.Column; | ||
import a_enterprise_business_rules.entities.Project; | ||
import a_enterprise_business_rules.entities.Task; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.UUID; | ||
|
||
public class ChangeTaskCompletionStatusTest { | ||
|
||
private Project project; | ||
private ChangeTaskCompletionStatus changeTaskCompletionStatus; | ||
|
||
@BeforeEach | ||
public void setUp() { | ||
// Set up your test environment here, including creating a sample project and tasks | ||
// For example: | ||
List<Task> tasks = new ArrayList<>(); | ||
tasks.add(new Task("Task 1", UUID.randomUUID(), "", false, null)); | ||
tasks.add(new Task("Task 2", UUID.randomUUID(), "", true, null)); | ||
|
||
List<Column> columns = new ArrayList<>(); | ||
columns.add(new Column("Column 1", tasks, UUID.randomUUID())); | ||
|
||
project = new Project("Sample Project",UUID.randomUUID(),"", columns); | ||
|
||
changeTaskCompletionStatus = new ChangeTaskCompletionStatus(project); | ||
} | ||
|
||
@Test | ||
public void testChangeCompletionStatus() { | ||
// Test changing the completion status of an existing task | ||
Task taskToUpdate = project.getColumns().get(0).getTasks().get(0); | ||
UUID taskID = taskToUpdate.getID(); | ||
|
||
Task updatedTask = changeTaskCompletionStatus.changeCompletionStatus(taskID); | ||
|
||
assertEquals(taskToUpdate, updatedTask, "Task should have been updated"); | ||
assertEquals(!taskToUpdate.getCompletionStatus(), updatedTask.getCompletionStatus(), "Completion status should be toggled"); | ||
} | ||
|
||
@Test | ||
public void testChangeCompletionStatusNonExistentTask() { | ||
// Test changing the completion status of a non-existent task | ||
UUID nonExistentTaskID = UUID.randomUUID(); | ||
|
||
Task updatedTask = changeTaskCompletionStatus.changeCompletionStatus(nonExistentTaskID); | ||
|
||
assertNull(updatedTask, "No task should be updated for a non-existent task ID"); | ||
} | ||
} |