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) {
313
313
timeoutMillis = DEFAULT_TIMEOUT_INTERVAL ;
314
314
}
315
315
316
+ if (eventHandler == null ) {
317
+ throw new IllegalArgumentException ("EventHandler was not configured" );
318
+ }
319
+
316
320
if (executor == null ) {
317
321
final ThreadFactory threadFactory = Executors .defaultThreadFactory ();
318
322
executor = Executors .newSingleThreadExecutor (runnable -> {
Original file line number Diff line number Diff line change @@ -67,7 +67,9 @@ public void setUp() throws Exception {
67
67
68
68
@ After
69
69
public void tearDown () throws Exception {
70
- eventProcessor .close ();
70
+ if (eventProcessor != null ) {
71
+ eventProcessor .close ();
72
+ }
71
73
}
72
74
73
75
@ Test
@@ -288,6 +290,11 @@ public void testInvalidTimeoutUsesDefault() {
288
290
assertEquals (eventProcessor .timeoutMillis , BatchEventProcessor .DEFAULT_TIMEOUT_INTERVAL );
289
291
}
290
292
293
+ @ Test (expected = IllegalArgumentException .class )
294
+ public void testDefaultEventHandler () {
295
+ eventProcessor = BatchEventProcessor .builder ().build ();
296
+ }
297
+
291
298
private void setEventProcessor (EventHandler eventHandler ) {
292
299
eventProcessor = BatchEventProcessor .builder ()
293
300
.withEventQueue (eventQueue )
Original file line number Diff line number Diff line change @@ -24,6 +24,8 @@ compile 'com.optimizely.ab:core-httpclient-impl:{VERSION}'
24
24
25
25
## Basic usage
26
26
``` java
27
+ package com.optimizely ;
28
+
27
29
import com.optimizely.ab.Optimizely ;
28
30
import com.optimizely.ab.OptimizelyFactory ;
29
31
@@ -38,9 +40,13 @@ public class App {
38
40
39
41
## Advanced usage
40
42
``` java
43
+ package com.optimizely ;
44
+
41
45
import com.optimizely.ab.Optimizely ;
46
+ import com.optimizely.ab.config.ProjectConfigManager ;
42
47
import com.optimizely.ab.config.HttpProjectConfigManager ;
43
48
import com.optimizely.ab.event.AsyncEventHandler ;
49
+ import com.optimizely.ab.event.EventHandler ;
44
50
import java.util.concurrent.TimeUnit ;
45
51
46
52
public class App {
@@ -54,12 +60,12 @@ public class App {
54
60
55
61
ProjectConfigManager projectConfigManager = HttpProjectConfigManager . builder()
56
62
.withSdkKey(sdkKey)
57
- .withPollingInterval(1 , TimeUnit . MINUTES )
63
+ .withPollingInterval(1L , TimeUnit . MINUTES )
58
64
.build();
59
65
60
66
Optimizely optimizely = Optimizely . builder()
61
- .withConfig(projectConfigManager)
62
67
.withEventHandler(eventHandler)
68
+ .withConfigManager(projectConfigManager)
63
69
.build();
64
70
}
65
71
}
You can’t perform that action at this time.
0 commit comments