25
25
import org .mockito .Mockito ;
26
26
27
27
import java .util .concurrent .ScheduledExecutorService ;
28
- import java .util .concurrent .TimeUnit ;
29
28
30
29
/**
31
30
* Tests for the <code>PeriodicStatisticsSink</code> class.
@@ -57,15 +56,15 @@ public void testFlushOnClose() {
57
56
}
58
57
59
58
@ Test
60
- public void testPeriodicFlush () throws InterruptedException {
59
+ public void testPeriodicFlush () {
61
60
final ScheduledExecutorService executor = Mockito .mock (ScheduledExecutorService .class );
62
61
final ArgumentCaptor <Runnable > runnableCaptor = ArgumentCaptor .forClass (Runnable .class );
63
62
final Sink statisticsSink = new PeriodicStatisticsSink (_statisticsSinkBuilder , executor );
64
63
Mockito .verify (executor ).scheduleAtFixedRate (
65
64
runnableCaptor .capture (),
66
65
Mockito .anyLong (),
67
66
Mockito .anyLong (),
68
- Mockito .< TimeUnit > any ());
67
+ Mockito .any ());
69
68
70
69
final Runnable periodicRunnable = runnableCaptor .getValue ();
71
70
@@ -91,7 +90,15 @@ public void testPeriodicFlush() throws InterruptedException {
91
90
92
91
@ Test
93
92
public void testRecordProcessedAggregateData () {
94
- final Sink statisticsSink = _statisticsSinkBuilder .build ();
93
+ final ScheduledExecutorService executor = Mockito .mock (ScheduledExecutorService .class );
94
+ final ArgumentCaptor <Runnable > runnableCaptor = ArgumentCaptor .forClass (Runnable .class );
95
+ final Sink statisticsSink = new PeriodicStatisticsSink (_statisticsSinkBuilder , executor );
96
+ Mockito .verify (executor ).scheduleAtFixedRate (
97
+ runnableCaptor .capture (),
98
+ Mockito .anyLong (),
99
+ Mockito .anyLong (),
100
+ Mockito .any ());
101
+
95
102
Mockito .verify (_mockMetricsFactory ).create ();
96
103
Mockito .verify (_mockMetrics ).resetCounter (COUNTER_NAME );
97
104
0 commit comments