File tree Expand file tree Collapse file tree 3 files changed +20
-3
lines changed
main/java/com/optimizely/ab/event
test/java/com/optimizely/ab/event Expand file tree Collapse file tree 3 files changed +20
-3
lines changed Original file line number Diff line number Diff line change @@ -313,6 +313,10 @@ public BatchEventProcessor build(boolean shouldStart) {
313313 timeoutMillis = DEFAULT_TIMEOUT_INTERVAL ;
314314 }
315315
316+ if (eventHandler == null ) {
317+ throw new IllegalArgumentException ("EventHandler was not configured" );
318+ }
319+
316320 if (executor == null ) {
317321 final ThreadFactory threadFactory = Executors .defaultThreadFactory ();
318322 executor = Executors .newSingleThreadExecutor (runnable -> {
Original file line number Diff line number Diff line change @@ -67,7 +67,9 @@ public void setUp() throws Exception {
6767
6868 @ After
6969 public void tearDown () throws Exception {
70- eventProcessor .close ();
70+ if (eventProcessor != null ) {
71+ eventProcessor .close ();
72+ }
7173 }
7274
7375 @ Test
@@ -288,6 +290,11 @@ public void testInvalidTimeoutUsesDefault() {
288290 assertEquals (eventProcessor .timeoutMillis , BatchEventProcessor .DEFAULT_TIMEOUT_INTERVAL );
289291 }
290292
293+ @ Test (expected = IllegalArgumentException .class )
294+ public void testDefaultEventHandler () {
295+ eventProcessor = BatchEventProcessor .builder ().build ();
296+ }
297+
291298 private void setEventProcessor (EventHandler eventHandler ) {
292299 eventProcessor = BatchEventProcessor .builder ()
293300 .withEventQueue (eventQueue )
Original file line number Diff line number Diff line change @@ -24,6 +24,8 @@ compile 'com.optimizely.ab:core-httpclient-impl:{VERSION}'
2424
2525## Basic usage
2626``` java
27+ package com.optimizely ;
28+
2729import com.optimizely.ab.Optimizely ;
2830import com.optimizely.ab.OptimizelyFactory ;
2931
@@ -38,9 +40,13 @@ public class App {
3840
3941## Advanced usage
4042``` java
43+ package com.optimizely ;
44+
4145import com.optimizely.ab.Optimizely ;
46+ import com.optimizely.ab.config.ProjectConfigManager ;
4247import com.optimizely.ab.config.HttpProjectConfigManager ;
4348import com.optimizely.ab.event.AsyncEventHandler ;
49+ import com.optimizely.ab.event.EventHandler ;
4450import java.util.concurrent.TimeUnit ;
4551
4652public class App {
@@ -54,12 +60,12 @@ public class App {
5460
5561 ProjectConfigManager projectConfigManager = HttpProjectConfigManager . builder()
5662 .withSdkKey(sdkKey)
57- .withPollingInterval(1 , TimeUnit . MINUTES )
63+ .withPollingInterval(1L , TimeUnit . MINUTES )
5864 .build();
5965
6066 Optimizely optimizely = Optimizely . builder()
61- .withConfig(projectConfigManager)
6267 .withEventHandler(eventHandler)
68+ .withConfigManager(projectConfigManager)
6369 .build();
6470 }
6571}
You can’t perform that action at this time.
0 commit comments