Search in sources :

Example 16 with Callback

use of zipkin2.Callback in project mapbox-events-android by mapbox.

the class MapboxTelemetryTest method obtainMapboxTelemetryWith.

private MapboxTelemetry obtainMapboxTelemetryWith(Context context, SchedulerFlusher schedulerFlusher) {
    MapboxTelemetry.applicationContext = context;
    String aValidAccessToken = "validAccessToken";
    String aValidUserAgent = "MapboxTelemetryAndroid/";
    EventsQueue mockedEventsQueue = mock(EventsQueue.class);
    TelemetryClient mockedTelemetryClient = mock(TelemetryClient.class);
    Callback mockedHttpCallback = mock(Callback.class);
    Clock mockedClock = mock(Clock.class);
    boolean indifferentServiceBound = true;
    TelemetryEnabler telemetryEnabler = new TelemetryEnabler(false);
    TelemetryLocationEnabler telemetryLocationEnabler = new TelemetryLocationEnabler(false);
    MapboxTelemetry mapboxTelemetry = new MapboxTelemetry(context, aValidAccessToken, aValidUserAgent, mockedEventsQueue, mockedTelemetryClient, mockedHttpCallback, schedulerFlusher, mockedClock, indifferentServiceBound, telemetryEnabler, telemetryLocationEnabler);
    return mapboxTelemetry;
}
Also used : Callback(okhttp3.Callback)

Example 17 with Callback

use of zipkin2.Callback in project mapbox-events-android by mapbox.

the class MapboxTelemetryTest method checksOnFullQueueSendEventsNotCalledWhenConnectivityNotAvailable.

@Test
public void checksOnFullQueueSendEventsNotCalledWhenConnectivityNotAvailable() throws Exception {
    Context mockedContext = obtainNetworkNotAvailableMockedContext();
    TelemetryClient mockedTelemetryClient = mock(TelemetryClient.class);
    Callback mockedHttpCallback = mock(Callback.class);
    MapboxTelemetry theMapboxTelemetry = obtainMapboxTelemetryWith(mockedContext, mockedTelemetryClient, mockedHttpCallback);
    List<Event> mockedList = mock(List.class);
    theMapboxTelemetry.enable();
    theMapboxTelemetry.onFullQueue(mockedList);
    verify(mockedTelemetryClient, never()).sendEvents(eq(mockedList), eq(mockedHttpCallback));
}
Also used : Context(android.content.Context) Callback(okhttp3.Callback) Test(org.junit.Test)

Example 18 with Callback

use of zipkin2.Callback in project mapbox-events-android by mapbox.

the class MapboxTelemetryTest method checksOnFullQueueSendEventsNotCalledWhenNullTelemetryClient.

@Test
public void checksOnFullQueueSendEventsNotCalledWhenNullTelemetryClient() throws Exception {
    Context mockedContext = obtainNetworkConnectedMockedContext();
    MapboxTelemetry.applicationContext = mockedContext;
    String nullAccessToken = null;
    String nullUserAgent = null;
    TelemetryClient mockedTelemetryClient = mock(TelemetryClient.class);
    Callback mockedHttpCallback = mock(Callback.class);
    TelemetryLocationEnabler telemetryLocationEnabler = new TelemetryLocationEnabler(false);
    telemetryLocationEnabler.injectTelemetryLocationState(TelemetryLocationEnabler.LocationState.ENABLED);
    MapboxTelemetry theMapboxTelemetry = obtainMapboxTelemetryWith(mockedContext, nullAccessToken, nullUserAgent, mockedTelemetryClient, mockedHttpCallback);
    List<Event> mockedList = mock(List.class);
    theMapboxTelemetry.onFullQueue(mockedList);
    verify(mockedTelemetryClient, never()).sendEvents(eq(mockedList), eq(mockedHttpCallback));
}
Also used : Context(android.content.Context) Callback(okhttp3.Callback) Test(org.junit.Test)

Example 19 with Callback

use of zipkin2.Callback in project mapbox-events-android by mapbox.

the class MapboxTelemetryTest method obtainMapboxTelemetryWith.

private MapboxTelemetry obtainMapboxTelemetryWith(boolean isServiceBound, TelemetryService telemetryService) {
    Context mockedContext = mock(Context.class);
    MapboxTelemetry.applicationContext = mockedContext;
    String aValidAccessToken = "validAccessToken";
    String aValidUserAgent = "MapboxTelemetryAndroid/";
    EventsQueue mockedEventsQueue = mock(EventsQueue.class);
    TelemetryClient mockedTelemetryClient = mock(TelemetryClient.class);
    Callback mockedHttpCallback = mock(Callback.class);
    SchedulerFlusher mockedSchedulerFlusher = mock(SchedulerFlusher.class);
    Clock mockedClock = mock(Clock.class);
    TelemetryEnabler telemetryEnabler = new TelemetryEnabler(false);
    TelemetryLocationEnabler telemetryLocationEnabler = new TelemetryLocationEnabler(false);
    MapboxTelemetry theMapboxTelemetry = new MapboxTelemetry(mockedContext, aValidAccessToken, aValidUserAgent, mockedEventsQueue, mockedTelemetryClient, mockedHttpCallback, mockedSchedulerFlusher, mockedClock, isServiceBound, telemetryEnabler, telemetryLocationEnabler);
    if (isServiceBound) {
        theMapboxTelemetry.injectTelemetryService(telemetryService);
    }
    return theMapboxTelemetry;
}
Also used : Context(android.content.Context) Callback(okhttp3.Callback)

Example 20 with Callback

use of zipkin2.Callback in project mapbox-events-android by mapbox.

the class MapboxTelemetryTest method obtainMapboxTelemetryWith.

private MapboxTelemetry obtainMapboxTelemetryWith(Context context, EventsQueue eventsQueue, TelemetryEnabler.State state) {
    MapboxTelemetry.applicationContext = context;
    String aValidAccessToken = "validAccessToken";
    String aValidUserAgent = "MapboxTelemetryAndroid/";
    TelemetryClient mockedTelemetryClient = mock(TelemetryClient.class);
    Callback mockedHttpCallback = mock(Callback.class);
    SchedulerFlusher mockedSchedulerFlusher = mock(SchedulerFlusher.class);
    Clock mockedClock = mock(Clock.class);
    boolean indifferentServiceBound = true;
    TelemetryEnabler telemetryEnabler = new TelemetryEnabler(false);
    telemetryEnabler.updatePreferences(state);
    TelemetryLocationEnabler telemetryLocationEnabler = new TelemetryLocationEnabler(false);
    MapboxTelemetry mapboxTelemetry = new MapboxTelemetry(context, aValidAccessToken, aValidUserAgent, eventsQueue, mockedTelemetryClient, mockedHttpCallback, mockedSchedulerFlusher, mockedClock, indifferentServiceBound, telemetryEnabler, telemetryLocationEnabler);
    return mapboxTelemetry;
}
Also used : Callback(okhttp3.Callback)

Aggregations

Callback (okhttp3.Callback)173 IOException (java.io.IOException)137 Call (okhttp3.Call)132 Response (okhttp3.Response)132 Request (okhttp3.Request)110 Callback (retrofit2.Callback)42 Call (retrofit2.Call)41 Test (org.junit.Test)39 Response (retrofit2.Response)39 RequestBody (okhttp3.RequestBody)37 OkHttpClient (okhttp3.OkHttpClient)34 File (java.io.File)27 Context (android.content.Context)24 JSONObject (org.json.JSONObject)20 FormBody (okhttp3.FormBody)19 ArrayList (java.util.ArrayList)18 View (android.view.View)16 Intent (android.content.Intent)14 TextView (android.widget.TextView)14 GsonBuilder (com.google.gson.GsonBuilder)14