4
4
import io .split .cache .SplitCache ;
5
5
import io .split .engine .experiments .SplitFetcherImp ;
6
6
import io .split .engine .experiments .SplitSynchronizationTask ;
7
+ import io .split .engine .segments .SegmentFetcher ;
7
8
import io .split .engine .segments .SegmentSynchronizationTask ;
8
9
import org .junit .Before ;
9
10
import org .junit .Test ;
@@ -15,14 +16,15 @@ public class SynchronizerTest {
15
16
private SplitFetcherImp _splitFetcher ;
16
17
private SplitCache _splitCache ;
17
18
private Synchronizer _synchronizer ;
19
+ private SegmentCache _segmentCache ;
18
20
19
21
@ Before
20
22
public void beforeMethod () {
21
23
_refreshableSplitFetcherTask = Mockito .mock (SplitSynchronizationTask .class );
22
24
_segmentFetcher = Mockito .mock (SegmentSynchronizationTask .class );
23
25
_splitFetcher = Mockito .mock (SplitFetcherImp .class );
24
26
_splitCache = Mockito .mock (SplitCache .class );
25
- SegmentCache _segmentCache = Mockito .mock (SegmentCache .class );
27
+ _segmentCache = Mockito .mock (SegmentCache .class );
26
28
27
29
_synchronizer = new SynchronizerImp (_refreshableSplitFetcherTask , _splitFetcher , _segmentFetcher , _splitCache , _segmentCache );
28
30
}
@@ -51,4 +53,23 @@ public void stopPeriodicFetching() {
51
53
Mockito .verify (_refreshableSplitFetcherTask , Mockito .times (1 )).stop ();
52
54
Mockito .verify (_segmentFetcher , Mockito .times (1 )).stop ();
53
55
}
56
+
57
+ @ Test
58
+ public void streamingRetryOnSplit () {
59
+ Mockito .when (_splitCache .getChangeNumber ()).thenReturn (0l ).thenReturn (0l ).thenReturn (1l );
60
+ _synchronizer .refreshSplits (1l );
61
+
62
+ Mockito .verify (_splitCache , Mockito .times (3 )).getChangeNumber ();
63
+ }
64
+
65
+ @ Test
66
+ public void streamingRetryOnSegment () {
67
+ SegmentFetcher fetcher = Mockito .mock (SegmentFetcher .class );
68
+ Mockito .when (_segmentFetcher .getFetcher (Mockito .anyString ())).thenReturn (fetcher );
69
+ Mockito .when (_segmentCache .getChangeNumber (Mockito .anyString ())).thenReturn (0l ).thenReturn (0l ).thenReturn (1l );
70
+ _synchronizer .refreshSegment ("Segment" ,1l );
71
+
72
+ Mockito .verify (_segmentCache , Mockito .times (3 )).getChangeNumber (Mockito .anyString ());
73
+ }
74
+
54
75
}
0 commit comments