use of com.google.firebase.crashlytics.internal.network.HttpResponse in project firebase-android-sdk by firebase.
the class DefaultSettingsSpiCallTest method testHandleResponse_requestNotSuccessful.
public void testHandleResponse_requestNotSuccessful() throws IOException {
final HttpResponse mockHttpResponse = mock(HttpResponse.class);
when(mockHttpResponse.code()).thenReturn(HttpURLConnection.HTTP_INTERNAL_ERROR);
assertNull(defaultSettingsSpiCall.handleResponse(mockHttpResponse));
verify(mockHttpResponse, never()).body();
verify(mockLogger, times(1)).e(eq("Settings request failed; (status: " + HttpURLConnection.HTTP_INTERNAL_ERROR + ") from " + TEST_URL));
}
use of com.google.firebase.crashlytics.internal.network.HttpResponse in project firebase-android-sdk by firebase.
the class DefaultSettingsSpiCall method invoke.
@Override
public JSONObject invoke(SettingsRequest requestData, boolean dataCollectionToken) {
if (!dataCollectionToken) {
throw new RuntimeException("An invalid data collection token was used.");
}
JSONObject toReturn = null;
try {
final Map<String, String> queryParams = getQueryParamsFor(requestData);
HttpGetRequest httpRequest = createHttpGetRequest(queryParams);
httpRequest = applyHeadersTo(httpRequest, requestData);
logger.d("Requesting settings from " + url);
logger.v("Settings query params were: " + queryParams);
final HttpResponse httpResponse = httpRequest.execute();
toReturn = handleResponse(httpResponse);
} catch (IOException e) {
logger.e("Settings request failed.", e);
toReturn = null;
}
return toReturn;
}
Aggregations