use of zipkin2.Callback in project mapbox-events-android by mapbox.
the class TelemetryClientMapEventsTest method sendsTheCorrectBodyPostingMapLoadEvent.
@Test
public void sendsTheCorrectBodyPostingMapLoadEvent() throws Exception {
TelemetryClient telemetryClient = obtainATelemetryClient("anyAccessToken", "anyUserAgent");
Event.Type load = Event.Type.MAP_LOAD;
Event aLoadEvent = obtainMapEvent(load);
List<Event> theLoadEvent = obtainEvents(aLoadEvent);
Callback mockedCallback = mock(Callback.class);
enqueueMockResponse();
telemetryClient.sendEvents(theLoadEvent, mockedCallback);
String expectedRequestBody = obtainExpectedRequestBody(new GsonBuilder(), theLoadEvent.get(0));
assertRequestBodyEquals(expectedRequestBody);
}
use of zipkin2.Callback in project mapbox-events-android by mapbox.
the class TelemetryClientTest method sendsPostEventRequestWithTheCorrectAccessTokenParameter.
@Test
public void sendsPostEventRequestWithTheCorrectAccessTokenParameter() throws Exception {
Context mockedContext = mock(Context.class, RETURNS_DEEP_STUBS);
MapboxTelemetry.applicationContext = mockedContext;
TelemetryClient telemetryClient = obtainATelemetryClient("theAccessToken", "anyUserAgent");
List<Event> mockedEvent = obtainAnEvent();
Callback mockedCallback = mock(Callback.class);
enqueueMockResponse();
telemetryClient.sendEvents(mockedEvent, mockedCallback);
assertRequestContainsParameter("access_token", "theAccessToken");
}
use of zipkin2.Callback in project mapbox-events-android by mapbox.
the class TelemetryClientTest method provideACallback.
private Callback provideACallback(final CountDownLatch latch, final AtomicReference<String> bodyRef, final AtomicBoolean failureRef) {
Callback aCallback = new Callback() {
@Override
public void onFailure(Call call, IOException exception) {
failureRef.set(true);
latch.countDown();
}
@Override
public void onResponse(Call call, Response response) throws IOException {
try {
bodyRef.set(response.body().string());
} catch (IOException exception) {
throw exception;
} finally {
latch.countDown();
}
}
};
return aCallback;
}
use of zipkin2.Callback in project mapbox-events-android by mapbox.
the class TelemetryClientTest method sendsContentEncodingHeader.
@Test
public void sendsContentEncodingHeader() throws Exception {
Context mockedContext = mock(Context.class, RETURNS_DEEP_STUBS);
MapboxTelemetry.applicationContext = mockedContext;
TelemetryClient telemetryClient = obtainATelemetryClient("anyAccessToken", "anyUserAgent");
List<Event> mockedEvent = obtainAnEvent();
Callback mockedCallback = mock(Callback.class);
enqueueMockResponse();
telemetryClient.sendEvents(mockedEvent, mockedCallback);
assertRequestContainsHeader("Content-Encoding", "gzip");
}
use of zipkin2.Callback in project mapbox-events-android by mapbox.
the class TelemetryClientTest method sendsContentTypeHeader.
@Test
public void sendsContentTypeHeader() throws Exception {
Context mockedContext = mock(Context.class, RETURNS_DEEP_STUBS);
MapboxTelemetry.applicationContext = mockedContext;
TelemetryClient telemetryClient = obtainATelemetryClient("anyAccessToken", "anyUserAgent");
List<Event> mockedEvent = obtainAnEvent();
Callback mockedCallback = mock(Callback.class);
enqueueMockResponse();
telemetryClient.sendEvents(mockedEvent, mockedCallback);
assertRequestContainsHeader("Content-Type", "application/json; charset=utf-8");
}
Aggregations