@@ -81,42 +81,47 @@ public void testDrainOnClose() throws Exception {
8181 }
8282
8383 @ Test
84- public void testFlushOnMaxTimeout () throws Exception {
84+ public void testFlushMaxBatchSize () throws Exception {
8585 CountDownLatch countDownLatch = new CountDownLatch (1 );
8686 setEventProcessor (logEvent -> {
87+ assertEquals (MAX_BATCH_SIZE , logEvent .getEventBatch ().getVisitors ().size ());
8788 eventHandlerRule .dispatchEvent (logEvent );
8889 countDownLatch .countDown ();
8990 });
9091
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+ }
9498
9599 if (!countDownLatch .await (MAX_DURATION_MS * 3 , TimeUnit .MILLISECONDS )) {
96100 fail ("Exceeded timeout waiting for notification." );
97101 }
98102
99- eventProcessor .close ();
100103 assertEquals (0 , eventQueue .size ());
101104 }
102105
103106 @ Test
104- public void testFlushMaxBatchSize () throws Exception {
107+ public void testFlushOnMaxTimeout () throws Exception {
108+ UserEvent userEvent = buildConversionEvent (EVENT_NAME );
109+
105110 CountDownLatch countDownLatch = new CountDownLatch (1 );
106111 setEventProcessor (logEvent -> {
107- assertEquals (MAX_BATCH_SIZE , logEvent .getEventBatch ().getVisitors ().size ());
108112 eventHandlerRule .dispatchEvent (logEvent );
109113 countDownLatch .countDown ();
110114 });
111115
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." );
117123 }
118124
119- countDownLatch .await ();
120125 assertEquals (0 , eventQueue .size ());
121126 }
122127
@@ -285,4 +290,4 @@ private static ConversionEvent buildConversionEvent(String eventName, ProjectCon
285290 return UserEventFactory .createConversionEvent (projectConfig , USER_ID , EVENT_ID , eventName ,
286291 Collections .emptyMap (), Collections .emptyMap ());
287292 }
288- }
293+ }
0 commit comments