Search in sources :

Example 1 with DatafileService

use of com.optimizely.ab.android.datafile_handler.DatafileService in project android-sdk by optimizely.

the class OptimizelyManagerDatafileServiceConnectionTest method onServiceConnected.

@Test
public void onServiceConnected() {
    DatafileService.LocalBinder binder = mock(DatafileService.LocalBinder.class);
    DatafileService service = mock(DatafileService.class);
    Context context = mock(Context.class);
    when(service.getApplicationContext()).thenReturn(context);
    when(binder.getService()).thenReturn(service);
    when(optimizelyManager.getDatafileConfig()).thenReturn(new DatafileConfig("1", (String) null));
    when(optimizelyManager.getDatafileLoadedListener(context, null)).thenReturn(mock(DatafileLoadedListener.class));
    ArgumentCaptor<DatafileLoadedListener> captor = ArgumentCaptor.forClass(DatafileLoadedListener.class);
    datafileServiceConnection = new DatafileServiceConnection(optimizelyManager.getDatafileConfig(), context, optimizelyManager.getDatafileLoadedListener(context, null));
    datafileServiceConnection.onServiceConnected(null, binder);
    String sameString = optimizelyManager.getDatafileConfig().getUrl();
    verify(service).getDatafile(eq(sameString), any(DatafileLoader.class), any(DatafileLoadedListener.class));
}
Also used : Context(android.content.Context) DatafileLoadedListener(com.optimizely.ab.android.datafile_handler.DatafileLoadedListener) DatafileLoader(com.optimizely.ab.android.datafile_handler.DatafileLoader) DatafileServiceConnection(com.optimizely.ab.android.datafile_handler.DatafileServiceConnection) DatafileConfig(com.optimizely.ab.android.shared.DatafileConfig) DatafileService(com.optimizely.ab.android.datafile_handler.DatafileService) Test(org.junit.Test)

Aggregations

Context (android.content.Context)1 DatafileLoadedListener (com.optimizely.ab.android.datafile_handler.DatafileLoadedListener)1 DatafileLoader (com.optimizely.ab.android.datafile_handler.DatafileLoader)1 DatafileService (com.optimizely.ab.android.datafile_handler.DatafileService)1 DatafileServiceConnection (com.optimizely.ab.android.datafile_handler.DatafileServiceConnection)1 DatafileConfig (com.optimizely.ab.android.shared.DatafileConfig)1 Test (org.junit.Test)1