3232import org .junit .jupiter .api .extension .ExtendWith ;
3333import org .mockito .Mock ;
3434import org .mockito .Mockito ;
35- import org .mockito .MockitoAnnotations ;
35+ import org .mockito .junit . jupiter . MockitoExtension ;
3636import org .springframework .beans .factory .annotation .Autowired ;
3737import org .springframework .boot .test .autoconfigure .data .mongo .DataMongoTest ;
3838import org .springframework .boot .test .system .CapturedOutput ;
6767
6868@ DataMongoTest
6969@ Testcontainers
70+ @ ExtendWith (MockitoExtension .class )
7071@ ExtendWith (OutputCaptureExtension .class )
7172class TaskServiceTests {
7273 private final long maxExecutionTime = 60000 ;
@@ -101,7 +102,6 @@ static void initRegistry() {
101102
102103 @ BeforeEach
103104 void init () {
104- MockitoAnnotations .openMocks (this );
105105 taskRepository .deleteAll ();
106106 taskService = new TaskService (mongoTemplate , taskRepository , iexecHubService , applicationEventPublisher );
107107 }
@@ -259,6 +259,7 @@ void shouldNotFindByCurrentStatusList() {
259259 }
260260 // endregion
261261
262+ // region getPrioritizedInitializedOrRunningTask
262263 @ Test
263264 void shouldGetInitializedOrRunningTasks () {
264265 final Task task = getStubTask ();
@@ -269,6 +270,17 @@ void shouldGetInitializedOrRunningTasks() {
269270 .isEqualTo (Optional .of (task ));
270271 }
271272
273+ @ Test
274+ void shouldNotGetTaskPastContributionDeadline () {
275+ final Task task = getStubTask ();
276+ task .setContributionDeadline (Date .from (Instant .now ().minus (1 , ChronoUnit .MINUTES )));
277+ taskRepository .save (task );
278+ assertThat (taskService .getPrioritizedInitializedOrRunningTask (false , List .of ()))
279+ .usingRecursiveComparison ()
280+ .isEqualTo (Optional .empty ());
281+ }
282+ // endregion
283+
272284 @ Test
273285 void shouldGetChainTaskIdsOfTasksExpiredBefore () {
274286 Date date = new Date ();
0 commit comments