use of com.optimizely.ab.android.shared.DatafileConfig in project android-sdk by optimizely.
the class OptimizelyManagerBuilderTest method testBuilderWithDatafileConfig.
@Test
public void testBuilderWithDatafileConfig() {
ErrorHandler errorHandler = new ErrorHandler() {
@Override
public <T extends OptimizelyRuntimeException> void handleError(T exception) throws T {
logger.error("Inside error handler", exception);
}
};
OptimizelyManager manager = OptimizelyManager.builder().withUserProfileService(DefaultUserProfileService.newInstance(testProjectId, InstrumentationRegistry.getInstrumentation().getTargetContext())).withDatafileDownloadInterval(30L, TimeUnit.MINUTES).withEventDispatchInterval(30L, TimeUnit.MINUTES).withDatafileHandler(new DefaultDatafileHandler()).withErrorHandler(errorHandler).withDatafileConfig(new DatafileConfig(null, "sdkKey7")).withEventHandler(DefaultEventHandler.getInstance(InstrumentationRegistry.getInstrumentation().getTargetContext())).withLogger(logger).build(InstrumentationRegistry.getInstrumentation().getTargetContext());
assertNotNull(manager);
assertNotNull(manager.getDatafileHandler());
assertNotNull(manager.getUserProfileService());
assertNotNull(manager.getEventHandler(InstrumentationRegistry.getInstrumentation().getTargetContext()));
manager.stop(InstrumentationRegistry.getInstrumentation().getTargetContext());
}
use of com.optimizely.ab.android.shared.DatafileConfig in project android-sdk by optimizely.
the class OptimizelyManagerTest method injectOptimizely.
@Test
public void injectOptimizely() {
Context context = mock(Context.class);
UserProfileService userProfileService = mock(UserProfileService.class);
OptimizelyStartListener startListener = mock(OptimizelyStartListener.class);
optimizelyManager.setOptimizelyStartListener(startListener);
optimizelyManager.injectOptimizely(context, userProfileService, minDatafile);
try {
executor.awaitTermination(5, TimeUnit.SECONDS);
} catch (InterruptedException e) {
fail("Timed out");
}
verify(logger).info("Sending Optimizely instance to listener");
verify(startListener).onStart(any(OptimizelyClient.class));
verify(optimizelyManager.getDatafileHandler()).startBackgroundUpdates(eq(context), eq(new DatafileConfig(testProjectId, null)), eq(3600L), any(DatafileLoadedListener.class));
}
use of com.optimizely.ab.android.shared.DatafileConfig in project android-sdk by optimizely.
the class OptimizelyManagerTest method injectOptimizelyWithDatafileListener.
@Test
public void injectOptimizelyWithDatafileListener() {
Context context = mock(Context.class);
UserProfileService userProfileService = mock(UserProfileService.class);
OptimizelyStartListener startListener = mock(OptimizelyStartListener.class);
optimizelyManager.setOptimizelyStartListener(startListener);
optimizelyManager.injectOptimizely(context, userProfileService, minDatafile);
try {
executor.awaitTermination(5, TimeUnit.SECONDS);
} catch (InterruptedException e) {
fail("Timed out");
}
verify(optimizelyManager.getDatafileHandler()).startBackgroundUpdates(eq(context), eq(new DatafileConfig(testProjectId, null)), eq(3600L), any(DatafileLoadedListener.class));
verify(logger).info("Sending Optimizely instance to listener");
verify(startListener).onStart(any(OptimizelyClient.class));
}
Aggregations