diff --git a/src/test/java/b_application_business_rules/entity_models/ColumnModelTest.java b/src/test/java/b_application_business_rules/entity_models/ColumnModelTest.java index 160fa82..d80f048 100644 --- a/src/test/java/b_application_business_rules/entity_models/ColumnModelTest.java +++ b/src/test/java/b_application_business_rules/entity_models/ColumnModelTest.java @@ -1,66 +1,480 @@ package b_application_business_rules.entity_models; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; -import static org.junit.jupiter.api.Assertions.*; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +/** + * A class to test the ColumnModel entity. + */ class ColumnModelTest { - @BeforeEach - void setUp() { - } - - @AfterEach - void tearDown() { - } - @Test + /** + * Tests getName + */ void getName() { + List sampleTaskModels1 = new ArrayList(); + sampleTaskModels1.add(new TaskModel("t1 name", UUID.randomUUID(), "t1 desc", false, + LocalDateTime.of(2024, 03, 28, 14, 33, 48, 0))); + sampleTaskModels1.add(new TaskModel("t2 name", UUID.randomUUID(), "t2 desc", true, + LocalDateTime.of(2023, 02, 18, 11, 10, 5, 2))); + sampleTaskModels1.add(new TaskModel("t3 name", UUID.randomUUID(), "t3 desc", false, + LocalDateTime.of(1985, 10, 1, 19, 13, 9, 6))); + ColumnModel c = new ColumnModel("testing ColumnModel name", sampleTaskModels1, UUID.randomUUID()); + + Assertions.assertEquals(c.getName(), "testing ColumnModel name"); } @Test + /** + * Tests setName + */ void setName() { + List sampleTaskModels1 = new ArrayList(); + sampleTaskModels1.add(new TaskModel("t1 name", UUID.randomUUID(), "t1 desc", false, + LocalDateTime.of(2024, 03, 28, 14, 33, 48, 0))); + sampleTaskModels1.add(new TaskModel("t2 name", UUID.randomUUID(), "t2 desc", true, + LocalDateTime.of(2023, 02, 18, 11, 10, 5, 2))); + sampleTaskModels1.add(new TaskModel("t3 name", UUID.randomUUID(), "t3 desc", false, + LocalDateTime.of(1985, 10, 1, 19, 13, 9, 6))); + ColumnModel c = new ColumnModel("testing ColumnModel name", sampleTaskModels1, UUID.randomUUID()); + + c.setName("new test ColumnModel name"); + + Assertions.assertEquals(c.getName(), "new test ColumnModel name"); } @Test + /** + * Tests getID + */ void getID() { + UUID currID = UUID.randomUUID(); + List sampleTaskModels1 = new ArrayList(); + sampleTaskModels1.add(new TaskModel("t1 name", UUID.randomUUID(), "t1 desc", false, + LocalDateTime.of(2024, 03, 28, 14, 33, 48, 0))); + sampleTaskModels1.add(new TaskModel("t2 name", UUID.randomUUID(), "t2 desc", true, + LocalDateTime.of(2023, 02, 18, 11, 10, 5, 2))); + sampleTaskModels1.add(new TaskModel("t3 name", UUID.randomUUID(), "t3 desc", false, + LocalDateTime.of(1985, 10, 1, 19, 13, 9, 6))); + ColumnModel c = new ColumnModel("testing ColumnModel name", sampleTaskModels1, currID); + + Assertions.assertEquals(c.getID(), currID); } @Test + /** + * Tests setID + */ void setID() { + List sampleTaskModels1 = new ArrayList(); + sampleTaskModels1.add(new TaskModel("t1 name", UUID.randomUUID(), "t1 desc", false, + LocalDateTime.of(2024, 03, 28, 14, 33, 48, 0))); + sampleTaskModels1.add(new TaskModel("t2 name", UUID.randomUUID(), "t2 desc", true, + LocalDateTime.of(2023, 02, 18, 11, 10, 5, 2))); + sampleTaskModels1.add(new TaskModel("t3 name", UUID.randomUUID(), "t3 desc", false, + LocalDateTime.of(1985, 10, 1, 19, 13, 9, 6))); + ColumnModel c = new ColumnModel("testing ColumnModel name", sampleTaskModels1, UUID.randomUUID()); + + UUID currID = UUID.randomUUID(); + + Assertions.assertEquals(c.getID(), currID); } @Test + /** + * Tests getTaskModels + */ void getTaskModels() { + List sampleTaskModels1 = new ArrayList(); + UUID u1 = UUID.randomUUID(); + UUID u2 = UUID.randomUUID(); + UUID u3 = UUID.randomUUID(); + sampleTaskModels1.add(new TaskModel("t1 name", u1, "t1 desc", false, + LocalDateTime.of(2024, 03, 28, 14, 33, 48, 0))); + sampleTaskModels1.add(new TaskModel("t2 name", u2, "t2 desc", true, + LocalDateTime.of(2023, 02, 18, 11, 10, 5, 2))); + sampleTaskModels1.add(new TaskModel("t3 name", u3, "t3 desc", false, + LocalDateTime.of(1985, 10, 1, 19, 13, 9, 6))); + ColumnModel c = new ColumnModel("testing ColumnModel name", sampleTaskModels1, UUID.randomUUID()); + + List sampleTaskModels2 = new ArrayList(); + sampleTaskModels2.add(new TaskModel("t1 name", u1, "t1 desc", false, + LocalDateTime.of(2024, 03, 28, 14, 33, 48, 0))); + sampleTaskModels2.add(new TaskModel("t2 name", u2, "t2 desc", true, + LocalDateTime.of(2023, 02, 18, 11, 10, 5, 2))); + sampleTaskModels2.add(new TaskModel("t3 name", u3, "t3 desc", false, + LocalDateTime.of(1985, 10, 1, 19, 13, 9, 6))); + + Assertions.assertEquals(c.getTaskModels(), sampleTaskModels2); } @Test + /** + * Tests setTaskModels + */ void setTaskModels() { + List sampleTaskModels1 = new ArrayList(); + UUID u1 = UUID.randomUUID(); + UUID u2 = UUID.randomUUID(); + UUID u3 = UUID.randomUUID(); + sampleTaskModels1.add(new TaskModel("t1 name", u1, "t1 desc", false, + LocalDateTime.of(2024, 03, 28, 14, 33, 48, 0))); + sampleTaskModels1.add(new TaskModel("t2 name", u2, "t2 desc", true, + LocalDateTime.of(2023, 02, 18, 11, 10, 5, 2))); + sampleTaskModels1.add(new TaskModel("t3 name", u3, "t3 desc", false, + LocalDateTime.of(1985, 10, 1, 19, 13, 9, 6))); + ColumnModel c = new ColumnModel("testing ColumnModel name", sampleTaskModels1, UUID.randomUUID()); + + UUID newu1 = UUID.randomUUID(); + UUID newu2 = UUID.randomUUID(); + UUID newu3 = UUID.randomUUID(); + List sampleTaskModels2 = new ArrayList(); + sampleTaskModels2.add(new TaskModel("new t1 name", newu1, "new t1 desc", false, + LocalDateTime.of(2024, 03, 28, 14, 33, 48, 0))); + sampleTaskModels2.add(new TaskModel("new t2 name", newu2, "new t2 desc", true, + LocalDateTime.of(2023, 02, 18, 11, 10, 5, 2))); + sampleTaskModels2.add(new TaskModel("new t3 name", newu3, "new t3 desc", false, + LocalDateTime.of(1985, 10, 1, 19, 13, 9, 6))); + + c.setTaskModels(sampleTaskModels2); + + List sampleTaskModels3 = new ArrayList(); + sampleTaskModels3.add(new TaskModel("new t1 name", newu1, "new t1 desc", false, + LocalDateTime.of(2024, 03, 28, 14, 33, 48, 0))); + sampleTaskModels3.add(new TaskModel("new t2 name", newu2, "new t2 desc", true, + LocalDateTime.of(2023, 02, 18, 11, 10, 5, 2))); + sampleTaskModels3.add(new TaskModel("new t3 name", newu3, "new t3 desc", false, + LocalDateTime.of(1985, 10, 1, 19, 13, 9, 6))); + + Assertions.assertEquals(c.getTaskModels(), sampleTaskModels3); } @Test + /** + * Tests addTaskModel + */ void addTaskModel() { + List sampleTaskModels1 = new ArrayList(); + UUID u1 = UUID.randomUUID(); + UUID u2 = UUID.randomUUID(); + UUID u3 = UUID.randomUUID(); + sampleTaskModels1.add(new TaskModel("t1 name", u1, "t1 desc", false, + LocalDateTime.of(2024, 03, 28, 14, 33, 48, 0))); + sampleTaskModels1.add(new TaskModel("t2 name", u2, "t2 desc", true, + LocalDateTime.of(2023, 02, 18, 11, 10, 5, 2))); + sampleTaskModels1.add(new TaskModel("t3 name", u3, "t3 desc", false, + LocalDateTime.of(1985, 10, 1, 19, 13, 9, 6))); + ColumnModel c = new ColumnModel("testing ColumnModel name", sampleTaskModels1, UUID.randomUUID()); + + UUID newUUID = UUID.randomUUID(); + + TaskModel newTaskModel = new TaskModel("new t1 name", newUUID, "new t1 desc", false, + LocalDateTime.of(2024, 03, 28, 14, 33, 48, 0)); + TaskModel newTaskModelCopy = new TaskModel("new t1 name", newUUID, "new t1 desc", false, + LocalDateTime.of(2024, 03, 28, 14, 33, 48, 0)); + + c.addTaskModel(newTaskModel); + + List sampleTaskModels2 = new ArrayList(); + sampleTaskModels2.add(new TaskModel("t1 name", u1, "t1 desc", false, + LocalDateTime.of(2024, 03, 28, 14, 33, 48, 0))); + sampleTaskModels2.add(new TaskModel("t2 name", u2, "t2 desc", true, + LocalDateTime.of(2023, 02, 18, 11, 10, 5, 2))); + sampleTaskModels2.add(new TaskModel("t3 name", u3, "t3 desc", false, + LocalDateTime.of(1985, 10, 1, 19, 13, 9, 6))); + sampleTaskModels2.add(newTaskModelCopy); + + Assertions.assertEquals(c.getTaskModels(), sampleTaskModels2); } @Test + /** + * Tests addTaskModelToPosition + */ void addTaskModelToPosition() { + List sampleTaskModels1 = new ArrayList(); + UUID u1 = UUID.randomUUID(); + UUID u2 = UUID.randomUUID(); + UUID u3 = UUID.randomUUID(); + sampleTaskModels1.add(new TaskModel("t1 name", u1, "t1 desc", false, + LocalDateTime.of(2024, 03, 28, 14, 33, 48, 0))); + sampleTaskModels1.add(new TaskModel("t2 name", u2, "t2 desc", true, + LocalDateTime.of(2023, 02, 18, 11, 10, 5, 2))); + sampleTaskModels1.add(new TaskModel("t3 name", u3, "t3 desc", false, + LocalDateTime.of(1985, 10, 1, 19, 13, 9, 6))); + ColumnModel c = new ColumnModel("testing ColumnModel name", sampleTaskModels1, UUID.randomUUID()); + + UUID newUUID = UUID.randomUUID(); + + TaskModel newTaskModel = new TaskModel("new t1 name", newUUID, "new t1 desc", false, + LocalDateTime.of(2024, 03, 28, 14, 33, 48, 0)); + TaskModel newTaskModelCopy = new TaskModel("new t1 name", newUUID, "new t1 desc", false, + LocalDateTime.of(2024, 03, 28, 14, 33, 48, 0)); + + c.addTaskModelToPosition(newTaskModel, 0); + + List sampleTaskModels2 = new ArrayList(); + sampleTaskModels2.add(new TaskModel("t1 name", u1, "t1 desc", false, + LocalDateTime.of(2024, 03, 28, 14, 33, 48, 0))); + sampleTaskModels2.add(new TaskModel("t2 name", u2, "t2 desc", true, + LocalDateTime.of(2023, 02, 18, 11, 10, 5, 2))); + sampleTaskModels2.add(new TaskModel("t3 name", u3, "t3 desc", false, + LocalDateTime.of(1985, 10, 1, 19, 13, 9, 6))); + sampleTaskModels2.add(0, newTaskModelCopy); + + Assertions.assertEquals(c.getTaskModels(), sampleTaskModels2); } @Test + /** + * Tests removeTaskModel + */ void removeTaskModel() { + List sampleTaskModels1 = new ArrayList(); + UUID u1 = UUID.randomUUID(); + UUID u2 = UUID.randomUUID(); + UUID u3 = UUID.randomUUID(); + TaskModel TaskModelToRemove = new TaskModel("t2 name", u2, "t2 desc", true, + LocalDateTime.of(2023, 02, 18, 11, 10, 5, 2)); + sampleTaskModels1.add(new TaskModel("t1 name", u1, "t1 desc", false, + LocalDateTime.of(2024, 03, 28, 14, 33, 48, 0))); + sampleTaskModels1.add(TaskModelToRemove); + sampleTaskModels1.add(new TaskModel("t3 name", u3, "t3 desc", false, + LocalDateTime.of(1985, 10, 1, 19, 13, 9, 6))); + ColumnModel c = new ColumnModel("testing ColumnModel name", sampleTaskModels1, UUID.randomUUID()); + + c.removeTaskModel(TaskModelToRemove); + + List sampleTaskModels2 = new ArrayList(); + sampleTaskModels2.add(new TaskModel("t1 name", u1, "t1 desc", false, + LocalDateTime.of(2024, 03, 28, 14, 33, 48, 0))); + sampleTaskModels2.add(new TaskModel("t3 name", u3, "t3 desc", false, + LocalDateTime.of(1985, 10, 1, 19, 13, 9, 6))); + + Assertions.assertEquals(c.getTaskModels(), sampleTaskModels2); } @Test + /** + * Tests swapTaskModelOrder + */ void swapTaskModelOrder() { + List sampleTaskModels1 = new ArrayList(); + UUID u1 = UUID.randomUUID(); + UUID u2 = UUID.randomUUID(); + UUID u3 = UUID.randomUUID(); + TaskModel TaskModel1 = new TaskModel("t1 name", u1, "t1 desc", false, + LocalDateTime.of(2024, 03, 28, 14, 33, 48, 0)); + TaskModel TaskModel2 = new TaskModel("t2 name", u2, "t2 desc", true, + LocalDateTime.of(2023, 02, 18, 11, 10, 5, 2)); + sampleTaskModels1.add(TaskModel1); + sampleTaskModels1.add(TaskModel2); + sampleTaskModels1.add(new TaskModel("t3 name", u3, "t3 desc", false, + LocalDateTime.of(1985, 10, 1, 19, 13, 9, 6))); + ColumnModel c = new ColumnModel("testing ColumnModel name", sampleTaskModels1, UUID.randomUUID()); + + c.swapTaskModelOrder(TaskModel1, TaskModel2); + + List sampleTaskModels2 = new ArrayList(); + sampleTaskModels2.add(TaskModel2); + sampleTaskModels2.add(TaskModel1); + sampleTaskModels2.add(new TaskModel("t3 name", u3, "t3 desc", false, + LocalDateTime.of(1985, 10, 1, 19, 13, 9, 6))); + + Assertions.assertEquals(c.getTaskModels(), sampleTaskModels2); } @Test + /** + * Tests moveTaskModelToPosition + */ void moveTaskModelToPosition() { + List sampleTaskModels1 = new ArrayList(); + UUID u1 = UUID.randomUUID(); + UUID u2 = UUID.randomUUID(); + UUID u3 = UUID.randomUUID(); + TaskModel t1 = new TaskModel("t1 name", u1, "t1 desc", false, + LocalDateTime.of(2024, 03, 28, 14, 33, 48, 0)); + sampleTaskModels1.add(t1); + sampleTaskModels1.add(new TaskModel("t2 name", u2, "t2 desc", true, + LocalDateTime.of(2023, 02, 18, 11, 10, 5, 2))); + sampleTaskModels1.add(new TaskModel("t3 name", u3, "t3 desc", false, + LocalDateTime.of(1985, 10, 1, 19, 13, 9, 6))); + ColumnModel c = new ColumnModel("testing ColumnModel name", sampleTaskModels1, UUID.randomUUID()); + + c.moveTaskModelToPosition(t1, 2); + + TaskModel t1Dupe = new TaskModel("t1 name", u1, "t1 desc", false, + LocalDateTime.of(2024, 03, 28, 14, 33, 48, 0)); + + List sampleTaskModels2 = new ArrayList(); + sampleTaskModels2.add(new TaskModel("t2 name", u2, "t2 desc", true, + LocalDateTime.of(2023, 02, 18, 11, 10, 5, 2))); + sampleTaskModels2.add(new TaskModel("t3 name", u3, "t3 desc", false, + LocalDateTime.of(1985, 10, 1, 19, 13, 9, 6))); + sampleTaskModels2.add(t1Dupe); + + Assertions.assertEquals(c.getTaskModels(), sampleTaskModels2); } @Test + /** + * Test toString + */ void testToString() { + List sampleTaskModels1 = new ArrayList(); + sampleTaskModels1.add(new TaskModel("t1 name", UUID.randomUUID(), "t1 desc", false, + LocalDateTime.of(2024, 03, 28, 14, 33, 48, 0))); + sampleTaskModels1.add(new TaskModel("t2 name", UUID.randomUUID(), "t2 desc", true, + LocalDateTime.of(2023, 02, 18, 11, 10, 5, 2))); + sampleTaskModels1.add(new TaskModel("t3 name", UUID.randomUUID(), "t3 desc", false, + LocalDateTime.of(1985, 10, 1, 19, 13, 9, 6))); + ColumnModel c = new ColumnModel("testing ColumnModel name", sampleTaskModels1, UUID.randomUUID()); + + String ColumnModelStringRepresentation = "[ColumnModel Name: testing ColumnModel name, " + + "TaskModels: {[TaskModel Name: t1 name, TaskModel Completed: false, Due Date: 2024-03-28T14:33:48], " + + "[TaskModel Name: t2 name, TaskModel Completed: true, Due Date: 2023-02-18T11:10:05.000000002], " + + "[TaskModel Name: t3 name, TaskModel Completed: false, Due Date: 1985-10-01T19:13:09.000000006]}]"; + + Assertions.assertEquals(c.toString(), ColumnModelStringRepresentation); + } + + @Test + /** + * Tests equals + */ + void testEquals() { + UUID u1 = UUID.randomUUID(); + UUID u2 = UUID.randomUUID(); + UUID u3 = UUID.randomUUID(); + + UUID cu = UUID.randomUUID(); + TaskModel t1 = new TaskModel("test TaskModel name", u1, "test TaskModel description", false, + LocalDateTime.of(2024, 03, 28, 14, 33, 48, 0)); + TaskModel t2 = new TaskModel("test TaskModel name", u2, "test TaskModel description", false, + LocalDateTime.of(2024, 03, 28, 14, 33, 48, 0)); + TaskModel t3 = new TaskModel("test TaskModel name", u3, "test TaskModel description", false, + LocalDateTime.of(2024, 03, 28, 14, 33, 48, 0)); + ArrayList TaskModels1 = new ArrayList(); + TaskModels1.add(t1); + TaskModels1.add(t2); + TaskModels1.add(t3); + + TaskModel tt1 = new TaskModel("test TaskModel name", u1, "test TaskModel description", false, + LocalDateTime.of(2024, 03, 28, 14, 33, 48, 0)); + TaskModel tt2 = new TaskModel("test TaskModel name", u2, "test TaskModel description", false, + LocalDateTime.of(2024, 03, 28, 14, 33, 48, 0)); + TaskModel tt3 = new TaskModel("test TaskModel name", u3, "test TaskModel description", false, + LocalDateTime.of(2024, 03, 28, 14, 33, 48, 0)); + + ArrayList TaskModels2 = new ArrayList(); + TaskModels2.add(tt1); + TaskModels2.add(tt2); + TaskModels2.add(tt3); + + TaskModel ttt1 = new TaskModel("test TaskModel name", u1, "test TaskModel description", false, + LocalDateTime.of(2024, 03, 28, 14, 33, 48, 0)); + TaskModel ttt2 = new TaskModel("test TaskModel name", u2, "test TaskModel description", false, + LocalDateTime.of(2024, 03, 28, 14, 33, 48, 0)); + TaskModel ttt3 = new TaskModel("test TaskModel name", u3, "test TaskModel description", false, + LocalDateTime.of(2024, 03, 28, 14, 33, 48, 0)); + + ArrayList TaskModels3 = new ArrayList(); + TaskModels3.add(ttt1); + TaskModels3.add(ttt2); + TaskModels3.add(ttt3); + + ColumnModel c1 = new ColumnModel("test ColumnModel", TaskModels1, cu); + ColumnModel c2 = new ColumnModel("test ColumnModel", TaskModels2, cu); + ColumnModel c3 = new ColumnModel("test ColumnModel", TaskModels3, cu); + + // Reflexive Property + Assertions.assertEquals(c1, c1); + + // Symmetric Property + Assertions.assertEquals(c1, c2); + Assertions.assertEquals(c2, c1); + + // Transitive Property + if (c1.equals(c2) && c2.equals(c3)) { + Assertions.assertEquals(c1, c3); + } } + + + + /** + * Tests IDToColumnModel NOT USED + */ +// void TestIDToColumnModel() { +// UUID u1 = UUID.randomUUID(); +// UUID u2 = UUID.randomUUID(); +// UUID u3 = UUID.randomUUID(); +// +// UUID cu1 = UUID.randomUUID(); +// UUID cu2 = UUID.randomUUID(); +// UUID cu3 = UUID.randomUUID(); +// +// +// TaskModel t1 = new TaskModel("test TaskModel name", u1, "test TaskModel description", false, +// LocalDateTime.of(2024, 03, 28, 14, 33, 48, 0)); +// TaskModel t2 = new TaskModel("test TaskModel name", u2, "test TaskModel description", false, +// LocalDateTime.of(2024, 03, 28, 14, 33, 48, 0)); +// TaskModel t3 = new TaskModel("test TaskModel name", u3, "test TaskModel description", false, +// LocalDateTime.of(2024, 03, 28, 14, 33, 48, 0)); +// ArrayList TaskModels1 = new ArrayList(); +// TaskModels1.add(t1); +// TaskModels1.add(t2); +// TaskModels1.add(t3); +// +// TaskModel tt1 = new TaskModel("test TaskModel name", u1, "test TaskModel description", false, +// LocalDateTime.of(2024, 03, 28, 14, 33, 48, 0)); +// TaskModel tt2 = new TaskModel("test TaskModel name", u2, "test TaskModel description", false, +// LocalDateTime.of(2024, 03, 28, 14, 33, 48, 0)); +// TaskModel tt3 = new TaskModel("test TaskModel name", u3, "test TaskModel description", false, +// LocalDateTime.of(2024, 03, 28, 14, 33, 48, 0)); +// +// ArrayList TaskModels2 = new ArrayList(); +// TaskModels2.add(tt1); +// TaskModels2.add(tt2); +// TaskModels2.add(tt3); +// +// TaskModel ttt1 = new TaskModel("test TaskModel name", u1, "test TaskModel description", false, +// LocalDateTime.of(2024, 03, 28, 14, 33, 48, 0)); +// TaskModel ttt2 = new TaskModel("test TaskModel name", u2, "test TaskModel description", false, +// LocalDateTime.of(2024, 03, 28, 14, 33, 48, 0)); +// TaskModel ttt3 = new TaskModel("test TaskModel name", u3, "test TaskModel description", false, +// LocalDateTime.of(2024, 03, 28, 14, 33, 48, 0)); +// +// ArrayList TaskModels3 = new ArrayList(); +// TaskModels3.add(ttt1); +// TaskModels3.add(ttt2); +// TaskModels3.add(ttt3); +// +// ColumnModel c1 = new ColumnModel("test ColumnModel", TaskModels1, cu1); +// ColumnModel c2 = new ColumnModel("test ColumnModel", TaskModels2, cu2); +// ColumnModel c3 = new ColumnModel("test ColumnModel", TaskModels3, cu3); +// +// ArrayList col = new ArrayList<>(); +// col.add(c1); +// col.add(c2); +// col.add(c3); +// +// ColumnModel output = ColumnModel.IDToColumnModel(cu2, col); +// Assertions.assertEquals(c2, output); +// +// } + + /** + * Tests getColumnEntity NOT USED + */ +// void getColumnEntity(){ +// +// } } \ No newline at end of file diff --git a/src/test/java/b_application_business_rules/entity_models/ProjectModelTest.java b/src/test/java/b_application_business_rules/entity_models/ProjectModelTest.java index c3bb450..2f0ee7a 100644 --- a/src/test/java/b_application_business_rules/entity_models/ProjectModelTest.java +++ b/src/test/java/b_application_business_rules/entity_models/ProjectModelTest.java @@ -1,70 +1,548 @@ package b_application_business_rules.entity_models; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.UUID; -import static org.junit.jupiter.api.Assertions.*; +import b_application_business_rules.entity_models.ColumnModel; +import b_application_business_rules.entity_models.ProjectModel; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +/** + * A class to test the ProjectModel entity. + */ class ProjectModelTest { - @BeforeEach - void setUp() { - } - - @AfterEach - void tearDown() { - } @Test + /** + * Tests the getName method + */ void getName() { + ProjectModel p = new ProjectModel("test proj", null, null, null); + Assertions.assertEquals(p.getName(), "test proj"); } @Test + /** + * Tests the setName method + */ void setName() { + ProjectModel p = new ProjectModel("test proj", null, null, null); + p.setName("new test proj"); + Assertions.assertEquals(p.getName(), "new test proj"); } @Test + /** + * Tests the getID method + */ void getID() { + UUID u = UUID.randomUUID(); + ProjectModel p = new ProjectModel(null, u, null, null); + Assertions.assertEquals(p.getID(), u); } @Test + /** + * Tests the setID method + */ void setID() { + UUID u = UUID.randomUUID(); + ProjectModel p = new ProjectModel(null, UUID.randomUUID(), null, null); + p.setID(u); + Assertions.assertEquals(p.getID(), u); } @Test + /** + * Tests the getDescription method + */ void getDescription() { + ProjectModel p = new ProjectModel(null, null, "skippidybopboombadabada", null); + Assertions.assertEquals(p.getDescription(), "skippidybopboombadabada"); } @Test + /** + * Tests the setDescription method + */ void setDescription() { + ProjectModel p = new ProjectModel(null, null, "skippidybopboombadabada", null); + p.setDescription("LALALALALAskippidybopboombadabada"); + Assertions.assertEquals(p.getDescription(), "LALALALALAskippidybopboombadabada"); } @Test + /** + * Tests getColumnModels + */ void getColumnModels() { + UUID u1 = UUID.randomUUID(); + UUID u2 = UUID.randomUUID(); + UUID u3 = UUID.randomUUID(); + + UUID cu1 = UUID.randomUUID(); + UUID cu2 = UUID.randomUUID(); + UUID cu3 = UUID.randomUUID(); + + + TaskModel t1 = new TaskModel("test TaskModel name", u1, "test TaskModel description", false, + LocalDateTime.of(2024, 03, 28, 14, 33, 48, 0)); + TaskModel t2 = new TaskModel("test TaskModel name", u2, "test TaskModel description", false, + LocalDateTime.of(2024, 03, 28, 14, 33, 48, 0)); + TaskModel t3 = new TaskModel("test TaskModel name", u3, "test TaskModel description", false, + LocalDateTime.of(2024, 03, 28, 14, 33, 48, 0)); + ArrayList TaskModels1 = new ArrayList(); + TaskModels1.add(t1); + TaskModels1.add(t2); + TaskModels1.add(t3); + + TaskModel tt1 = new TaskModel("test TaskModel name", u1, "test TaskModel description", false, + LocalDateTime.of(2024, 03, 28, 14, 33, 48, 0)); + TaskModel tt2 = new TaskModel("test TaskModel name", u2, "test TaskModel description", false, + LocalDateTime.of(2024, 03, 28, 14, 33, 48, 0)); + TaskModel tt3 = new TaskModel("test TaskModel name", u3, "test TaskModel description", false, + LocalDateTime.of(2024, 03, 28, 14, 33, 48, 0)); + + ArrayList TaskModels2 = new ArrayList(); + TaskModels2.add(tt1); + TaskModels2.add(tt2); + TaskModels2.add(tt3); + + TaskModel ttt1 = new TaskModel("test TaskModel name", u1, "test TaskModel description", false, + LocalDateTime.of(2024, 03, 28, 14, 33, 48, 0)); + TaskModel ttt2 = new TaskModel("test TaskModel name", u2, "test TaskModel description", false, + LocalDateTime.of(2024, 03, 28, 14, 33, 48, 0)); + TaskModel ttt3 = new TaskModel("test TaskModel name", u3, "test TaskModel description", false, + LocalDateTime.of(2024, 03, 28, 14, 33, 48, 0)); + + ArrayList TaskModels3 = new ArrayList(); + TaskModels3.add(ttt1); + TaskModels3.add(ttt2); + TaskModels3.add(ttt3); + + ColumnModel c1 = new ColumnModel("test ColumnModel", TaskModels1, cu1); + ColumnModel c2 = new ColumnModel("test ColumnModel", TaskModels2, cu2); + ColumnModel c3 = new ColumnModel("test ColumnModel", TaskModels3, cu3); + + ArrayList colResult = new ArrayList<>(); + colResult.add(c1); + colResult.add(c2); + colResult.add(c3); + + ArrayList col = new ArrayList<>(); + colResult.add(c1); + colResult.add(c2); + colResult.add(c3); + + ProjectModel p = new ProjectModel(null, null, null, col); + + + Assertions.assertEquals(p.getColumnModels(), colResult); } @Test + /** + * Tests setColumnModels + */ void setColumnModels() { + UUID u1 = UUID.randomUUID(); + UUID u2 = UUID.randomUUID(); + UUID u3 = UUID.randomUUID(); + + UUID cu1 = UUID.randomUUID(); + UUID cu2 = UUID.randomUUID(); + UUID cu3 = UUID.randomUUID(); + + + TaskModel t1 = new TaskModel("test TaskModel name", u1, "test TaskModel description", false, + LocalDateTime.of(2024, 03, 28, 14, 33, 48, 0)); + TaskModel t2 = new TaskModel("test TaskModel name", u2, "test TaskModel description", false, + LocalDateTime.of(2024, 03, 28, 14, 33, 48, 0)); + TaskModel t3 = new TaskModel("test TaskModel name", u3, "test TaskModel description", false, + LocalDateTime.of(2024, 03, 28, 14, 33, 48, 0)); + ArrayList TaskModels1 = new ArrayList(); + TaskModels1.add(t1); + TaskModels1.add(t2); + TaskModels1.add(t3); + + TaskModel tt1 = new TaskModel("test TaskModel name", u1, "test TaskModel description", false, + LocalDateTime.of(2024, 03, 28, 14, 33, 48, 0)); + TaskModel tt2 = new TaskModel("test TaskModel name", u2, "test TaskModel description", false, + LocalDateTime.of(2024, 03, 28, 14, 33, 48, 0)); + TaskModel tt3 = new TaskModel("test TaskModel name", u3, "test TaskModel description", false, + LocalDateTime.of(2024, 03, 28, 14, 33, 48, 0)); + + ArrayList TaskModels2 = new ArrayList(); + TaskModels2.add(tt1); + TaskModels2.add(tt2); + TaskModels2.add(tt3); + + TaskModel ttt1 = new TaskModel("test TaskModel name", u1, "test TaskModel description", false, + LocalDateTime.of(2024, 03, 28, 14, 33, 48, 0)); + TaskModel ttt2 = new TaskModel("test TaskModel name", u2, "test TaskModel description", false, + LocalDateTime.of(2024, 03, 28, 14, 33, 48, 0)); + TaskModel ttt3 = new TaskModel("test TaskModel name", u3, "test TaskModel description", false, + LocalDateTime.of(2024, 03, 28, 14, 33, 48, 0)); + + ArrayList TaskModels3 = new ArrayList(); + TaskModels3.add(ttt1); + TaskModels3.add(ttt2); + TaskModels3.add(ttt3); + + ColumnModel c1 = new ColumnModel("test ColumnModel", TaskModels1, cu1); + ColumnModel c2 = new ColumnModel("test ColumnModel", TaskModels2, cu2); + ColumnModel c3 = new ColumnModel("test ColumnModel", TaskModels3, cu3); + + ArrayList colResult = new ArrayList<>(); + colResult.add(c1); + colResult.add(c2); + colResult.add(c3); + + ArrayList input = new ArrayList<>(); + colResult.add(c1); + colResult.add(c2); + colResult.add(c3); + + ArrayList col = new ArrayList<>(); + colResult.add(c2); + + ProjectModel p = new ProjectModel(null, null, null, col); + p.setColumnModels(input); + + Assertions.assertEquals(p.getColumnModels(), colResult); } @Test + /** + * Tests addColumnModel + */ void addColumnModel() { + UUID u1 = UUID.randomUUID(); + UUID u2 = UUID.randomUUID(); + UUID u3 = UUID.randomUUID(); + + UUID cu1 = UUID.randomUUID(); + UUID cu2 = UUID.randomUUID(); + UUID cu3 = UUID.randomUUID(); + + + TaskModel t1 = new TaskModel("test TaskModel name", u1, "test TaskModel description", false, + LocalDateTime.of(2024, 03, 28, 14, 33, 48, 0)); + TaskModel t2 = new TaskModel("test TaskModel name", u2, "test TaskModel description", false, + LocalDateTime.of(2024, 03, 28, 14, 33, 48, 0)); + TaskModel t3 = new TaskModel("test TaskModel name", u3, "test TaskModel description", false, + LocalDateTime.of(2024, 03, 28, 14, 33, 48, 0)); + ArrayList TaskModels1 = new ArrayList(); + TaskModels1.add(t1); + TaskModels1.add(t2); + TaskModels1.add(t3); + + TaskModel tt1 = new TaskModel("test TaskModel name", u1, "test TaskModel description", false, + LocalDateTime.of(2024, 03, 28, 14, 33, 48, 0)); + TaskModel tt2 = new TaskModel("test TaskModel name", u2, "test TaskModel description", false, + LocalDateTime.of(2024, 03, 28, 14, 33, 48, 0)); + TaskModel tt3 = new TaskModel("test TaskModel name", u3, "test TaskModel description", false, + LocalDateTime.of(2024, 03, 28, 14, 33, 48, 0)); + + ArrayList TaskModels2 = new ArrayList(); + TaskModels2.add(tt1); + TaskModels2.add(tt2); + TaskModels2.add(tt3); + + TaskModel ttt1 = new TaskModel("test TaskModel name", u1, "test TaskModel description", false, + LocalDateTime.of(2024, 03, 28, 14, 33, 48, 0)); + TaskModel ttt2 = new TaskModel("test TaskModel name", u2, "test TaskModel description", false, + LocalDateTime.of(2024, 03, 28, 14, 33, 48, 0)); + TaskModel ttt3 = new TaskModel("test TaskModel name", u3, "test TaskModel description", false, + LocalDateTime.of(2024, 03, 28, 14, 33, 48, 0)); + + ArrayList TaskModels3 = new ArrayList(); + TaskModels3.add(ttt1); + TaskModels3.add(ttt2); + TaskModels3.add(ttt3); + + ColumnModel c1 = new ColumnModel("test ColumnModel", TaskModels1, cu1); + ColumnModel c2 = new ColumnModel("test ColumnModel", TaskModels2, cu2); + ColumnModel c3 = new ColumnModel("test ColumnModel", TaskModels3, cu3); + + ArrayList colResult = new ArrayList<>(); + colResult.add(c1); + colResult.add(c2); + colResult.add(c3); + + ArrayList col = new ArrayList<>(); + colResult.add(c1); + colResult.add(c2); + + + + ProjectModel p = new ProjectModel(null, null, null, col); + p.addColumnModel(c3); + + Assertions.assertEquals(p.getColumnModels(), colResult); } @Test + /** + * Tests addColumnModelToPosition + */ void addColumnModelToPosition() { - } + UUID u1 = UUID.randomUUID(); + UUID u2 = UUID.randomUUID(); + UUID u3 = UUID.randomUUID(); - @Test - void moveColumnModelToPosition() { + UUID cu1 = UUID.randomUUID(); + UUID cu2 = UUID.randomUUID(); + UUID cu3 = UUID.randomUUID(); + + + TaskModel t1 = new TaskModel("test TaskModel name", u1, "test TaskModel description", false, + LocalDateTime.of(2024, 03, 28, 14, 33, 48, 0)); + TaskModel t2 = new TaskModel("test TaskModel name", u2, "test TaskModel description", false, + LocalDateTime.of(2024, 03, 28, 14, 33, 48, 0)); + TaskModel t3 = new TaskModel("test TaskModel name", u3, "test TaskModel description", false, + LocalDateTime.of(2024, 03, 28, 14, 33, 48, 0)); + ArrayList TaskModels1 = new ArrayList(); + TaskModels1.add(t1); + TaskModels1.add(t2); + TaskModels1.add(t3); + + TaskModel tt1 = new TaskModel("test TaskModel name", u1, "test TaskModel description", false, + LocalDateTime.of(2024, 03, 28, 14, 33, 48, 0)); + TaskModel tt2 = new TaskModel("test TaskModel name", u2, "test TaskModel description", false, + LocalDateTime.of(2024, 03, 28, 14, 33, 48, 0)); + TaskModel tt3 = new TaskModel("test TaskModel name", u3, "test TaskModel description", false, + LocalDateTime.of(2024, 03, 28, 14, 33, 48, 0)); + + ArrayList TaskModels2 = new ArrayList(); + TaskModels2.add(tt1); + TaskModels2.add(tt2); + TaskModels2.add(tt3); + + TaskModel ttt1 = new TaskModel("test TaskModel name", u1, "test TaskModel description", false, + LocalDateTime.of(2024, 03, 28, 14, 33, 48, 0)); + TaskModel ttt2 = new TaskModel("test TaskModel name", u2, "test TaskModel description", false, + LocalDateTime.of(2024, 03, 28, 14, 33, 48, 0)); + TaskModel ttt3 = new TaskModel("test TaskModel name", u3, "test TaskModel description", false, + LocalDateTime.of(2024, 03, 28, 14, 33, 48, 0)); + + ArrayList TaskModels3 = new ArrayList(); + TaskModels3.add(ttt1); + TaskModels3.add(ttt2); + TaskModels3.add(ttt3); + + ColumnModel c1 = new ColumnModel("test ColumnModel", TaskModels1, cu1); + ColumnModel c2 = new ColumnModel("test ColumnModel", TaskModels2, cu2); + ColumnModel c3 = new ColumnModel("test ColumnModel", TaskModels3, cu3); + + ArrayList colResult = new ArrayList<>(); + colResult.add(c1); + colResult.add(c2); + colResult.add(c3); + + ArrayList col = new ArrayList<>(); + colResult.add(c2); + + + + ProjectModel p = new ProjectModel(null, null, null, col); + p.addColumnModelToPosition(c1, 0); + p.addColumnModelToPosition(c3, 2); + + + Assertions.assertEquals(p.getColumnModels(), colResult); } + /** + * Tests testMoveColumnModelToPosition NOT USED + */ +// void testMoveColumnModelToPosition() { +// ColumnModelModel c1 = new ColumnModelModel(null, null, null); +// ColumnModelModel c2 = new ColumnModelModel(null, null, null); +// ColumnModelModel c3 = new ColumnModelModel(null, null, null); +// ArrayList ColumnModels = new ArrayList(); +// ColumnModels.add(c1); +// ColumnModels.add(c2); +// ColumnModels.add(c3); +// +// ProjectModel p = new ProjectModel(null, null, null, ColumnModels); +// +// p.moveColumnModelToPosition(c3, 0); +// +// ArrayList ColumnModels2 = new ArrayList(); +// ColumnModels2.add(c3); +// ColumnModels2.add(c1); +// ColumnModels2.add(c2); +// +// Assertions.assertEquals(p.getColumnModels(), ColumnModels2); +// } + @Test + /** + * Tests removeColumnModel + */ void removeColumnModel() { + UUID u1 = UUID.randomUUID(); + UUID u2 = UUID.randomUUID(); + UUID u3 = UUID.randomUUID(); + + UUID cu1 = UUID.randomUUID(); + UUID cu2 = UUID.randomUUID(); + UUID cu3 = UUID.randomUUID(); + + + TaskModel t1 = new TaskModel("test TaskModel name", u1, "test TaskModel description", false, + LocalDateTime.of(2024, 03, 28, 14, 33, 48, 0)); + TaskModel t2 = new TaskModel("test TaskModel name", u2, "test TaskModel description", false, + LocalDateTime.of(2024, 03, 28, 14, 33, 48, 0)); + TaskModel t3 = new TaskModel("test TaskModel name", u3, "test TaskModel description", false, + LocalDateTime.of(2024, 03, 28, 14, 33, 48, 0)); + ArrayList TaskModels1 = new ArrayList(); + TaskModels1.add(t1); + TaskModels1.add(t2); + TaskModels1.add(t3); + + TaskModel tt1 = new TaskModel("test TaskModel name", u1, "test TaskModel description", false, + LocalDateTime.of(2024, 03, 28, 14, 33, 48, 0)); + TaskModel tt2 = new TaskModel("test TaskModel name", u2, "test TaskModel description", false, + LocalDateTime.of(2024, 03, 28, 14, 33, 48, 0)); + TaskModel tt3 = new TaskModel("test TaskModel name", u3, "test TaskModel description", false, + LocalDateTime.of(2024, 03, 28, 14, 33, 48, 0)); + + ArrayList TaskModels2 = new ArrayList(); + TaskModels2.add(tt1); + TaskModels2.add(tt2); + TaskModels2.add(tt3); + + TaskModel ttt1 = new TaskModel("test TaskModel name", u1, "test TaskModel description", false, + LocalDateTime.of(2024, 03, 28, 14, 33, 48, 0)); + TaskModel ttt2 = new TaskModel("test TaskModel name", u2, "test TaskModel description", false, + LocalDateTime.of(2024, 03, 28, 14, 33, 48, 0)); + TaskModel ttt3 = new TaskModel("test TaskModel name", u3, "test TaskModel description", false, + LocalDateTime.of(2024, 03, 28, 14, 33, 48, 0)); + + ArrayList TaskModels3 = new ArrayList(); + TaskModels3.add(ttt1); + TaskModels3.add(ttt2); + TaskModels3.add(ttt3); + + ColumnModel c1 = new ColumnModel("test ColumnModel", TaskModels1, cu1); + ColumnModel c2 = new ColumnModel("test ColumnModel", TaskModels2, cu2); + ColumnModel c3 = new ColumnModel("test ColumnModel", TaskModels3, cu3); + + ArrayList col = new ArrayList<>(); + col.add(c1); + col.add(c2); + col.add(c3); + + ArrayList colResult = new ArrayList(); + colResult.add(c1); + colResult.add(c3); + + ProjectModel p = new ProjectModel(null, null, null, col); + p.removeColumnModel(c2); + + Assertions.assertEquals(p.getColumnModels(), colResult); } + /** + * Tests swapColumnModelOrder. NOT USED. + */ +// void swapColumnModelOrder() { +// ColumnModelModel c1 = new ColumnModelModel(null, null, null); +// ColumnModelModel c2 = new ColumnModelModel(null, null, null); +// ArrayList ColumnModels = new ArrayList(); +// ColumnModels.add(c1); +// ColumnModels.add(c2); +// +// ArrayList ColumnModels2 = new ArrayList(); +// ColumnModels.add(c2); +// ColumnModels.add(c1); +// +// ProjectModel p = new ProjectModel(null, null, null, ColumnModels); +// p.swapColumnModelOrder(c2.getColumnModelEntity(), c1.getColumnModelEntity()); +// +// Assertions.assertEquals(p.getColumnModels(), ColumnModels2); +// } + @Test - void swapColumnModelOrder() { + /** + * Tests equals + */ + void testEquals() { + UUID u1 = UUID.randomUUID(); + UUID u2 = UUID.randomUUID(); + UUID u3 = UUID.randomUUID(); + + UUID cu1 = UUID.randomUUID(); + UUID cu2 = UUID.randomUUID(); + UUID cu3 = UUID.randomUUID(); + + UUID pu = UUID.randomUUID(); + String name = "Test ProjectModel"; + String description = "Description"; + + TaskModel t1 = new TaskModel("test TaskModel name", u1, "test TaskModel description", false, + LocalDateTime.of(2024, 03, 28, 14, 33, 48, 0)); + TaskModel t2 = new TaskModel("test TaskModel name", u2, "test TaskModel description", false, + LocalDateTime.of(2024, 03, 28, 14, 33, 48, 0)); + TaskModel t3 = new TaskModel("test TaskModel name", u3, "test TaskModel description", false, + LocalDateTime.of(2024, 03, 28, 14, 33, 48, 0)); + ArrayList TaskModels1 = new ArrayList(); + TaskModels1.add(t1); + TaskModels1.add(t2); + TaskModels1.add(t3); + + TaskModel tt1 = new TaskModel("test TaskModel name", u1, "test TaskModel description", false, + LocalDateTime.of(2024, 03, 28, 14, 33, 48, 0)); + TaskModel tt2 = new TaskModel("test TaskModel name", u2, "test TaskModel description", false, + LocalDateTime.of(2024, 03, 28, 14, 33, 48, 0)); + TaskModel tt3 = new TaskModel("test TaskModel name", u3, "test TaskModel description", false, + LocalDateTime.of(2024, 03, 28, 14, 33, 48, 0)); + + ArrayList TaskModels2 = new ArrayList(); + TaskModels2.add(tt1); + TaskModels2.add(tt2); + TaskModels2.add(tt3); + + TaskModel ttt1 = new TaskModel("test TaskModel name", u1, "test TaskModel description", false, + LocalDateTime.of(2024, 03, 28, 14, 33, 48, 0)); + TaskModel ttt2 = new TaskModel("test TaskModel name", u2, "test TaskModel description", false, + LocalDateTime.of(2024, 03, 28, 14, 33, 48, 0)); + TaskModel ttt3 = new TaskModel("test TaskModel name", u3, "test TaskModel description", false, + LocalDateTime.of(2024, 03, 28, 14, 33, 48, 0)); + + ArrayList TaskModels3 = new ArrayList(); + TaskModels3.add(ttt1); + TaskModels3.add(ttt2); + TaskModels3.add(ttt3); + + ColumnModel c1 = new ColumnModel("test ColumnModel", TaskModels1, cu1); + ColumnModel c2 = new ColumnModel("test ColumnModel", TaskModels2, cu2); + ColumnModel c3 = new ColumnModel("test ColumnModel", TaskModels3, cu3); + + ArrayList col = new ArrayList<>(); + col.add(c1); + col.add(c2); + col.add(c3); + + ProjectModel p1 = new ProjectModel(name, pu, description, col); + ProjectModel p2 = new ProjectModel(name, pu, description, col); + ProjectModel p3 = new ProjectModel(name, pu, description, col); + + // Reflexive Property + Assertions.assertEquals(p1, p1); + + // Symmetric Property + Assertions.assertEquals(p1, p2); + Assertions.assertEquals(p2, p1); + + // Transitive Property + if (p1.equals(p2) && p2.equals(p3)) { + Assertions.assertEquals(p1, p3); + } } } \ No newline at end of file diff --git a/src/test/java/b_application_business_rules/entity_models/TaskModelTest.java b/src/test/java/b_application_business_rules/entity_models/TaskModelTest.java index 22caf2d..4bb4eb0 100644 --- a/src/test/java/b_application_business_rules/entity_models/TaskModelTest.java +++ b/src/test/java/b_application_business_rules/entity_models/TaskModelTest.java @@ -1,60 +1,224 @@ package b_application_business_rules.entity_models; -import org.junit.jupiter.api.Test; -import static org.junit.jupiter.api.Assertions.*; +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.UUID; + + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +/** + * A class to test the TaskModels entity. + */ class TaskModelTest { @Test + /** + * Tests getName + */ void getName() { + TaskModel t = new TaskModel("test TaskModel name", UUID.randomUUID(), "test TaskModel description", false, + LocalDateTime.of(2024, 03, 28, 14, 33, 48, 0)); + Assertions.assertEquals(t.getName(), "test TaskModel name"); } @Test + /** + * Tests setName + */ void setName() { + TaskModel t = new TaskModel("test TaskModel name", UUID.randomUUID(), "test TaskModel description", false, + LocalDateTime.of(2024, 03, 28, 14, 33, 48, 0)); + t.setName("New testing name!"); + Assertions.assertEquals(t.getName(), "New testing name!"); } @Test + /** + * Tests getID + */ void getID() { + UUID TaskModelUUID = UUID.randomUUID(); + TaskModel t = new TaskModel("test TaskModel name", TaskModelUUID, "test TaskModel description", false, + LocalDateTime.of(2024, 03, 28, 14, 33, 48, 0)); + Assertions.assertEquals(t.getID(), TaskModelUUID); } @Test + /** + * Tests setID + */ void setID() { + TaskModel t = new TaskModel("test TaskModel name", UUID.randomUUID(), "test TaskModel description", false, + LocalDateTime.of(2024, 03, 28, 14, 33, 48, 0)); + UUID newTaskModelUUID = UUID.randomUUID(); + Assertions.assertEquals(t.getID(), newTaskModelUUID); } @Test + /** + * Tests getDescription + */ void getDescription() { + TaskModel t = new TaskModel("test TaskModel name", UUID.randomUUID(), "test TaskModel description", false, + LocalDateTime.of(2024, 03, 28, 14, 33, 48, 0)); + Assertions.assertEquals(t.getDescription(), "test TaskModel description"); } @Test + /** + * Tests setDescription + */ void setDescription() { + TaskModel t = new TaskModel("test TaskModel name", UUID.randomUUID(), "test TaskModel description", false, + LocalDateTime.of(2024, 03, 28, 14, 33, 48, 0)); + t.setDescription("newerrr test TaskModel description"); + Assertions.assertEquals(t.getDescription(), "newerrr test TaskModel description"); } @Test + /** + * Tests getCompletionStatus + */ void getCompletionStatus() { + TaskModel t = new TaskModel("test TaskModel name", UUID.randomUUID(), "test TaskModel description", false, + LocalDateTime.of(2024, 03, 28, 14, 33, 48, 0)); + Assertions.assertFalse(t.getCompletionStatus()); } @Test + /** + * Tests completeTaskModel + */ void completeTaskModel() { + TaskModel t = new TaskModel("test TaskModel name", UUID.randomUUID(), "test TaskModel description", false, + LocalDateTime.of(2024, 03, 28, 14, 33, 48, 0)); + t.completeTaskModel(); + Assertions.assertTrue(t.getCompletionStatus()); + + TaskModel s = new TaskModel("test TaskModel name", UUID.randomUUID(), "test TaskModel description", true, + LocalDateTime.of(2024, 03, 28, 14, 33, 48, 0)); + s.completeTaskModel(); + Assertions.assertTrue(s.getCompletionStatus()); } @Test + /** + * Tests incompleteTaskModel + */ void incompleteTaskModel() { + TaskModel t = new TaskModel("test TaskModel name", UUID.randomUUID(), "test TaskModel description", false, + LocalDateTime.of(2024, 03, 28, 14, 33, 48, 0)); + t.incompleteTaskModel(); + Assertions.assertFalse(t.getCompletionStatus()); + + TaskModel s = new TaskModel("test TaskModel name", UUID.randomUUID(), "test TaskModel description", true, + LocalDateTime.of(2024, 03, 28, 14, 33, 48, 0)); + s.incompleteTaskModel(); + Assertions.assertFalse(s.getCompletionStatus()); } @Test + /** + * Test negateCompletionStatus + */ void negateCompletionStatus() { + TaskModel t = new TaskModel("test TaskModel name", UUID.randomUUID(), "test TaskModel description", false, + LocalDateTime.of(2024, 03, 28, 14, 33, 48, 0)); + t.incompleteTaskModel(); + Assertions.assertTrue(t.getCompletionStatus()); + + TaskModel s = new TaskModel("test TaskModel name", UUID.randomUUID(), "test TaskModel description", true, + LocalDateTime.of(2024, 03, 28, 14, 33, 48, 0)); + s.incompleteTaskModel(); + Assertions.assertFalse(s.getCompletionStatus()); } @Test + /** + * Tests getDueDateTime + */ void getDueDateTime() { + TaskModel t = new TaskModel("test TaskModel name", UUID.randomUUID(), "test TaskModel description", false, + LocalDateTime.of(2024, 03, 28, 14, 33, 48, 0)); + Assertions.assertEquals(t.getDueDateTime(), LocalDateTime.of(2024, 03, 28, 14, 33, 48, 0)); } @Test + /** + * Tests setDueDateTime + */ void setDueDateTime() { + TaskModel t = new TaskModel("test TaskModel name", UUID.randomUUID(), "test TaskModel description", false, + LocalDateTime.of(2024, 03, 28, 14, 33, 48, 0)); + t.setDueDateTime(LocalDateTime.of(4024, 03, 28, 14, 2, 11, 1110)); + Assertions.assertEquals(t.getDueDateTime(), LocalDateTime.of(4024, 03, 28, 14, 2, 11, 1110)); } @Test + /** + * Tests toString + */ void testToString() { + TaskModel t = new TaskModel("test TaskModel name", UUID.randomUUID(), "test TaskModel description", false, + LocalDateTime.of(2024, 03, 28, 14, 33, 48, 0)); + Assertions.assertEquals( + t.toString(), "[TaskModel Name: test TaskModel name, TaskModel Completed: false, Due Date: 2024-03-28T14:33:48]"); + + } + + @Test + /** + * Tests equals + */ + void testEquals() { + TaskModel t1 = new TaskModel("test TaskModel name", UUID.randomUUID(), "test TaskModel description", false, + LocalDateTime.of(2024, 03, 28, 14, 33, 48, 0)); + TaskModel t2 = new TaskModel("test TaskModel name", UUID.randomUUID(), "test TaskModel description", false, + LocalDateTime.of(2024, 03, 28, 14, 33, 48, 0)); + TaskModel t3 = new TaskModel("test TaskModel name", UUID.randomUUID(), "test TaskModel description", false, + LocalDateTime.of(2024, 03, 28, 14, 33, 48, 0)); + + // Reflexive Property + Assertions.assertEquals(t1, t1); + + // Symmetric Property + Assertions.assertEquals(t1, t2); + Assertions.assertEquals(t2, t1); + + // Transitive Property + if (t1.equals(t2) && t2.equals(t3)) { + Assertions.assertEquals(t1, t3); + } } + + + + /** + * Tests ITToTaskModel NOT USED + */ +// void TestIDToTaskModel() { +// UUID u1 = UUID.randomUUID(); +// UUID u2 = UUID.randomUUID(); +// UUID u3 = UUID.randomUUID(); +// +// +// TaskModel t1 = new TaskModel("test TaskModel name", u1, "test TaskModel description", false, +// LocalDateTime.of(2024, 03, 28, 14, 33, 48, 0)); +// TaskModel t2 = new TaskModel("test TaskModel name", u2, "test TaskModel description", false, +// LocalDateTime.of(2024, 03, 28, 14, 33, 48, 0)); +// TaskModel t3 = new TaskModel("test TaskModel name", u3, "test TaskModel description", false, +// LocalDateTime.of(2024, 03, 28, 14, 33, 48, 0)); +// ArrayList TaskModels1 = new ArrayList(); +// TaskModels1.add(t1); +// TaskModels1.add(t2); +// TaskModels1.add(t3); +// +// TaskModel output = TaskModel.IDToTaskModel(u2, TaskModels1); +// Assertions.assertEquals(output, t2); +// +// } + } \ No newline at end of file