use of zipkin2.Callback in project mapbox-events-android by mapbox.
the class MapboxTelemetryTest method checksOnFullQueueSendEventsCalledWhenIsConnectedAndTelemetryEnabled.
@Test
public void checksOnFullQueueSendEventsCalledWhenIsConnectedAndTelemetryEnabled() throws Exception {
Context mockedContext = obtainNetworkConnectedMockedContext();
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, times(1)).sendEvents(eq(mockedList), eq(mockedHttpCallback));
}
use of zipkin2.Callback in project mapbox-events-android by mapbox.
the class TelemetryClientAppUserTurnstileEventTest method sendsTheCorrectBodyPostingAppUserTurnstileEvent.
@Test
public void sendsTheCorrectBodyPostingAppUserTurnstileEvent() throws Exception {
Context mockedContext = mock(Context.class, RETURNS_DEEP_STUBS);
MapboxTelemetry.applicationContext = mockedContext;
TelemetryClient telemetryClient = obtainATelemetryClient("anyAccessToken", "anyUserAgent");
Event anAppUserTurnstile = new AppUserTurnstile("anySdkIdentifier", "anySdkVersion", false);
List<Event> theAppUserTurnstile = obtainEvents(anAppUserTurnstile);
Callback mockedCallback = mock(Callback.class);
enqueueMockResponse();
telemetryClient.sendEvents(theAppUserTurnstile, mockedCallback);
String expectedRequestBody = obtainExpectedRequestBody(new GsonBuilder(), theAppUserTurnstile.get(0));
assertRequestBodyEquals(expectedRequestBody);
}
use of zipkin2.Callback in project mapbox-events-android by mapbox.
the class TelemetryClientNavigationEventsTest method sendsTheCorrectBodyPostingNavigationFeedbackEvent.
@Test
public void sendsTheCorrectBodyPostingNavigationFeedbackEvent() throws Exception {
TelemetryClient telemetryClient = obtainATelemetryClient("anyAccessToken", "anyUserAgent");
Event.Type feedback = Event.Type.NAV_FEEDBACK;
Event aFeedbackEvent = obtainNavigationEvent(feedback);
List<Event> theFeedbackEvent = obtainEvents(aFeedbackEvent);
Callback mockedCallback = mock(Callback.class);
enqueueMockResponse();
telemetryClient.sendEvents(theFeedbackEvent, mockedCallback);
GsonBuilder gsonBuilder = configureTypeAdapter(feedback, new GsonBuilder());
String expectedRequestBody = obtainExpectedRequestBody(gsonBuilder, theFeedbackEvent.get(0));
assertRequestBodyEquals(expectedRequestBody);
}
use of zipkin2.Callback in project mapbox-events-android by mapbox.
the class TelemetryClientNavigationEventsTest method sendsTheCorrectBodyPostingNavigationRerouteEvent.
@Test
public void sendsTheCorrectBodyPostingNavigationRerouteEvent() throws Exception {
TelemetryClient telemetryClient = obtainATelemetryClient("anyAccessToken", "anyUserAgent");
Event.Type reroute = Event.Type.NAV_REROUTE;
Event aRerouteEvent = obtainNavigationEvent(reroute);
List<Event> theRerouteEvent = obtainEvents(aRerouteEvent);
Callback mockedCallback = mock(Callback.class);
enqueueMockResponse();
telemetryClient.sendEvents(theRerouteEvent, mockedCallback);
GsonBuilder gsonBuilder = configureTypeAdapter(reroute, new GsonBuilder());
String expectedRequestBody = obtainExpectedRequestBody(gsonBuilder, theRerouteEvent.get(0));
assertRequestBodyEquals(expectedRequestBody);
}
use of zipkin2.Callback in project mapbox-events-android by mapbox.
the class TelemetryClientNavigationEventsTest method sendsTheCorrectBodyPostingNavigationCancelEvent.
@Test
public void sendsTheCorrectBodyPostingNavigationCancelEvent() throws Exception {
TelemetryClient telemetryClient = obtainATelemetryClient("anyAccessToken", "anyUserAgent");
Event.Type cancel = Event.Type.NAV_CANCEL;
Event aCancelEvent = obtainNavigationEvent(cancel);
List<Event> theCancelEvent = obtainEvents(aCancelEvent);
Callback mockedCallback = mock(Callback.class);
enqueueMockResponse();
telemetryClient.sendEvents(theCancelEvent, mockedCallback);
GsonBuilder gsonBuilder = configureTypeAdapter(cancel, new GsonBuilder());
String expectedRequestBody = obtainExpectedRequestBody(gsonBuilder, theCancelEvent.get(0));
assertRequestBodyEquals(expectedRequestBody);
}
Aggregations