@@ -81,42 +81,47 @@ public void testDrainOnClose() throws Exception {
81
81
}
82
82
83
83
@ Test
84
- public void testFlushOnMaxTimeout () throws Exception {
84
+ public void testFlushMaxBatchSize () throws Exception {
85
85
CountDownLatch countDownLatch = new CountDownLatch (1 );
86
86
setEventProcessor (logEvent -> {
87
+ assertEquals (MAX_BATCH_SIZE , logEvent .getEventBatch ().getVisitors ().size ());
87
88
eventHandlerRule .dispatchEvent (logEvent );
88
89
countDownLatch .countDown ();
89
90
});
90
91
91
- UserEvent userEvent = buildConversionEvent (EVENT_NAME );
92
- eventProcessor .process (userEvent );
93
- eventHandlerRule .expectConversion (EVENT_NAME , USER_ID );
92
+ for (int i = 0 ; i < MAX_BATCH_SIZE ; i ++) {
93
+ String eventName = EVENT_NAME + i ;
94
+ UserEvent userEvent = buildConversionEvent (eventName );
95
+ eventProcessor .process (userEvent );
96
+ eventHandlerRule .expectConversion (eventName , USER_ID );
97
+ }
94
98
95
99
if (!countDownLatch .await (MAX_DURATION_MS * 3 , TimeUnit .MILLISECONDS )) {
96
100
fail ("Exceeded timeout waiting for notification." );
97
101
}
98
102
99
- eventProcessor .close ();
100
103
assertEquals (0 , eventQueue .size ());
101
104
}
102
105
103
106
@ Test
104
- public void testFlushMaxBatchSize () throws Exception {
107
+ public void testFlushOnMaxTimeout () throws Exception {
108
+ UserEvent userEvent = buildConversionEvent (EVENT_NAME );
109
+
105
110
CountDownLatch countDownLatch = new CountDownLatch (1 );
106
111
setEventProcessor (logEvent -> {
107
- assertEquals (MAX_BATCH_SIZE , logEvent .getEventBatch ().getVisitors ().size ());
108
112
eventHandlerRule .dispatchEvent (logEvent );
109
113
countDownLatch .countDown ();
110
114
});
111
115
112
- for (int i = 0 ; i < MAX_BATCH_SIZE ; i ++) {
113
- String eventName = EVENT_NAME + i ;
114
- UserEvent userEvent = buildConversionEvent (eventName );
115
- eventProcessor .process (userEvent );
116
- eventHandlerRule .expectConversion (eventName , USER_ID );
116
+ eventProcessor .process (userEvent );
117
+ eventHandlerRule .expectConversion (EVENT_NAME , USER_ID );
118
+
119
+ eventProcessor .close ();
120
+
121
+ if (!countDownLatch .await ( TIMEOUT_MS * 3 , TimeUnit .MILLISECONDS )) {
122
+ fail ("Exceeded timeout waiting for events to flush." );
117
123
}
118
124
119
- countDownLatch .await ();
120
125
assertEquals (0 , eventQueue .size ());
121
126
}
122
127
@@ -285,4 +290,4 @@ private static ConversionEvent buildConversionEvent(String eventName, ProjectCon
285
290
return UserEventFactory .createConversionEvent (projectConfig , USER_ID , EVENT_ID , eventName ,
286
291
Collections .emptyMap (), Collections .emptyMap ());
287
292
}
288
- }
293
+ }
0 commit comments