17
17
18
18
package org .apache .dolphinscheduler .server .master .runner ;
19
19
20
- import static org .junit .Assert .assertTrue ;
20
+ import static org .junit .jupiter . api . Assertions .assertTrue ;
21
21
import static org .mockito .Mockito .doNothing ;
22
22
import static org .mockito .Mockito .mock ;
23
23
import static org .mockito .Mockito .times ;
24
24
import static org .mockito .Mockito .verify ;
25
25
26
- import org .apache .dolphinscheduler .server .master .engine .task .client .ITaskExecutorClient ;
27
26
import org .apache .dolphinscheduler .server .master .engine .task .runnable .ITaskExecutionRunnable ;
28
27
29
28
import java .util .concurrent .ConcurrentHashMap ;
30
29
31
- import org .junit .jupiter .api .BeforeEach ;
32
30
import org .junit .jupiter .api .Test ;
33
- import org .junit .runner . RunWith ;
31
+ import org .junit .jupiter . api . extension . ExtendWith ;
34
32
import org .mockito .InjectMocks ;
35
33
import org .mockito .Mock ;
36
- import org .mockito .junit .MockitoJUnitRunner ;
34
+ import org .mockito .junit .jupiter . MockitoExtension ;
37
35
import org .springframework .test .util .ReflectionTestUtils ;
38
36
39
- @ RunWith ( MockitoJUnitRunner .class )
40
- public class WorkerGroupTaskDispatcherManagerTest {
37
+ @ ExtendWith ( MockitoExtension .class )
38
+ class WorkerGroupTaskDispatcherManagerTest {
41
39
42
40
@ InjectMocks
43
41
private WorkerGroupTaskDispatcherManager workerGroupTaskDispatcherManager ;
44
42
45
- @ Mock
46
- private ITaskExecutorClient taskExecutorClient ;
47
-
48
43
@ Mock
49
44
private ITaskExecutionRunnable taskExecutionRunnable ;
50
45
51
- @ BeforeEach
52
- public void setUp () {
53
- workerGroupTaskDispatcherManager = new WorkerGroupTaskDispatcherManager ();
54
- ReflectionTestUtils .setField (workerGroupTaskDispatcherManager , "taskExecutorClient" , taskExecutorClient );
55
- }
56
-
57
46
@ Test
58
- public void addTaskToWorkerGroup_NewWorkerGroup_ShouldAddTask () {
47
+ void addTaskToWorkerGroup_NewWorkerGroup_ShouldAddTask () {
59
48
String workerGroup = "newGroup" ;
60
49
long delayTimeMills = 1000 ;
61
50
62
51
workerGroupTaskDispatcherManager .addTaskToWorkerGroup (workerGroup , taskExecutionRunnable , delayTimeMills );
63
52
64
53
ConcurrentHashMap <String , WorkerGroupTaskDispatcher > dispatchWorkerMap =
65
- (ConcurrentHashMap <String , WorkerGroupTaskDispatcher >) ReflectionTestUtils
66
- .getField (workerGroupTaskDispatcherManager , "dispatchWorkerMap" );
54
+ workerGroupTaskDispatcherManager .getDispatchWorkerMap ();
67
55
68
- assert dispatchWorkerMap != null ;
69
56
assertTrue (dispatchWorkerMap .containsKey (workerGroup ));
70
57
}
71
58
72
59
@ Test
73
- public void addTaskToWorkerGroup_ExistingWorkerGroup_ShouldAddTask () {
60
+ void addTaskToWorkerGroup_ExistingWorkerGroup_ShouldAddTask () {
74
61
String workerGroup = "existingGroup" ;
75
62
long delayTimeMills = 1000 ;
76
63
@@ -87,7 +74,7 @@ public void addTaskToWorkerGroup_ExistingWorkerGroup_ShouldAddTask() {
87
74
}
88
75
89
76
@ Test
90
- public void close_ShouldCloseAllWorkerGroups () throws Exception {
77
+ void close_ShouldCloseAllWorkerGroups () throws Exception {
91
78
WorkerGroupTaskDispatcher mockDispatcher1 = mock (WorkerGroupTaskDispatcher .class );
92
79
WorkerGroupTaskDispatcher mockDispatcher2 = mock (WorkerGroupTaskDispatcher .class );
93
80
0 commit comments