11package models ;
22
3- import org .junit .After ;
4- import org .junit .Before ;
5- import org .junit .Test ;
3+
4+ import org .junit .jupiter .api .AfterEach ;
5+ import org .junit .jupiter .api .Assertions ;
6+ import org .junit .jupiter .api .BeforeEach ;
7+ import org .junit .jupiter .api .Test ;
68
79import java .time .LocalDateTime ;
810
9- import static org .junit .Assert .*;
1011
1112public class TaskTest {
12- @ Before
13+ @ BeforeEach
1314 public void setUp () throws Exception {
1415 }
1516
16- @ After
17+ @ AfterEach
1718 public void tearDown () throws Exception {
1819 Task .clearAllTasks (); // clear out all the tasks before each test
1920 }
2021
2122 @ Test
2223 public void NewTaskObjectGetsCorrectlyCreated_true () throws Exception {
2324 Task task = setupNewTask ();
24- assertEquals (true , task instanceof Task );
25+ Assertions . assertEquals (true , task instanceof Task );
2526 }
2627
2728 @ Test
2829 public void TaskInstantiatesWithDescription_true () throws Exception {
2930 Task task = setupNewTask ();
30- assertEquals ("Mow the lawn" , task .getDescription ());
31+ Assertions . assertEquals ("Mow the lawn" , task .getDescription ());
3132 }
3233
3334 @ Test
3435 public void AllTasksAreCorrectlyReturned_true () throws Exception {
3536 Task task = setupNewTask ();
3637 Task otherTask = new Task ("Brush the cat" );
37- assertEquals (2 , Task .getAll ().size ());
38+ Assertions . assertEquals (2 , Task .getAll ().size ());
3839 }
3940
4041 @ Test
4142 public void AllTasksContainsAllTasks_true () throws Exception {
4243 Task task = setupNewTask ();
4344 Task otherTask = new Task ("Brush the cat" );
44- assertTrue (Task .getAll ().contains (task ));
45- assertTrue (Task .getAll ().contains (otherTask ));
45+ Assertions . assertTrue (Task .getAll ().contains (task ));
46+ Assertions . assertTrue (Task .getAll ().contains (otherTask ));
4647 }
4748
4849 @ Test
4950 public void isCompletedPropertyIsFalseAfterInstantiation () throws Exception {
5051 Task task = setupNewTask ();
51- assertEquals (false , task .getCompleted ()); //should never start as completed
52+ Assertions . assertEquals (false , task .getCompleted ()); //should never start as completed
5253 }
5354
5455 @ Test
5556 public void getCreatedAtInstantiatesWithCurrentTimeToday () throws Exception {
5657 Task task = setupNewTask ();
57- assertEquals (LocalDateTime .now ().getDayOfWeek (), task .getCreatedAt ().getDayOfWeek ());
58+ Assertions . assertEquals (LocalDateTime .now ().getDayOfWeek (), task .getCreatedAt ().getDayOfWeek ());
5859 }
5960
6061 @ Test
6162 public void tasksInstantiateWithId () throws Exception {
6263 Task task = setupNewTask ();
63- assertEquals (1 , task .getId ());
64+ Assertions . assertEquals (1 , task .getId ());
6465 }
6566
6667 @ Test
6768 public void findReturnsCorrectTask () throws Exception {
6869 Task task = setupNewTask ();
69- assertEquals (1 , Task .findById (task .getId ()).getId ());
70+ Assertions . assertEquals (1 , Task .findById (task .getId ()).getId ());
7071 }
7172
7273
7374 @ Test
7475 public void findReturnsCorrectTaskWhenMoreThanOneTaskExists () throws Exception {
7576 Task task = setupNewTask ();
7677 Task otherTask = new Task ("Brush the cat" );
77- assertEquals (2 , Task .findById (otherTask .getId ()).getId ());
78+ Assertions . assertEquals (2 , Task .findById (otherTask .getId ()).getId ());
7879 }
7980
8081 @ Test
@@ -86,27 +87,27 @@ public void updateChangesTaskContent() throws Exception {
8687
8788 task .update ("Floss the cat" );
8889
89- assertEquals (formerId , task .getId ());
90- assertEquals (formerDate , task .getCreatedAt ());
91- assertNotEquals (formerContent , task .getDescription ());
90+ Assertions . assertEquals (formerId , task .getId ());
91+ Assertions . assertEquals (formerDate , task .getCreatedAt ());
92+ Assertions . assertNotEquals (formerContent , task .getDescription ());
9293 }
9394
9495 @ Test
9596 public void deleteDeletesASpecificTask () throws Exception {
9697 Task task = setupNewTask ();
9798 Task otherTask = new Task ("Brush the cat" );
9899 task .deleteTask ();
99- assertEquals (1 , Task .getAll ().size ()); //one is left
100- assertEquals (Task .getAll ().get (0 ).getId (), 2 ); //the one that was deleted has the id of 2
100+ Assertions . assertEquals (1 , Task .getAll ().size ()); //one is left
101+ Assertions . assertEquals (Task .getAll ().get (0 ).getId (), 2 ); //the one that was deleted has the id of 2
101102 }
102103
103- @ Test
104- public void deleteAllTasksDeletesAllTasks () throws Exception {
105- Task task = setupNewTask ();
106- Task otherTask = setupNewTask ();
107- Task .clearAllTasks ();
108- assertEquals (0 , Task .getAll ().size ());
109- }
104+ // @Test
105+ // public void deleteAllTasksDeletesAllTasks() throws Exception {
106+ // Task task = setupNewTask();
107+ // Task otherTask = setupNewTask();
108+ // Task.clearAllTasks();
109+ // assertEquals(0, Task.getAll().size());
110+ // }
110111
111112
112113 //helper methods
0 commit comments