@@ -21,6 +21,10 @@ public void testAddAndExecuteTask() {
21
21
scheduler .addTask ("Group1" , "Task1" );
22
22
23
23
String result = scheduler .executeTasks ("Group1" );
24
+
25
+ // Check for null before splitting
26
+ assertTrue (result != null , "The result should not be null after executing the task." );
27
+
24
28
String [] parts = result .split (" started at " );
25
29
26
30
// Validate task name and ensure start time is a valid timestamp
@@ -35,12 +39,20 @@ public void testMultipleTasksInGroup() {
35
39
36
40
// Execute the first task
37
41
String result1 = scheduler .executeTasks ("Group1" );
42
+
43
+ // Check for null before splitting
44
+ assertTrue (result1 != null , "The result for Task1 should not be null." );
45
+
38
46
String [] parts1 = result1 .split (" started at " );
39
47
assertEquals ("Task1" , parts1 [0 ]);
40
48
assertTrue (Long .parseLong (parts1 [1 ]) > 0 , "Start time should be greater than 0" );
41
49
42
50
// Execute the second task
43
51
String result2 = scheduler .executeTasks ("Group1" );
52
+
53
+ // Check for null before splitting
54
+ assertTrue (result2 != null , "The result for Task2 should not be null." );
55
+
44
56
String [] parts2 = result2 .split (" started at " );
45
57
assertEquals ("Task2" , parts2 [0 ]);
46
58
assertTrue (Long .parseLong (parts2 [1 ]) > 0 , "Start time should be greater than 0" );
@@ -54,6 +66,7 @@ public void testExecuteAllTasks() {
54
66
scheduler .executeTasks ("Group1" );
55
67
scheduler .executeTasks ("Group1" );
56
68
69
+ // Confirm executing tasks again returns null
57
70
assertNull (scheduler .executeTasks ("Group1" ));
58
71
}
59
72
0 commit comments