use of com.google.firebase.crashlytics.internal.network.HttpResponse in project firebase-android-sdk by firebase.
the class DefaultSettingsSpiCallTest method testHandleResponse_requestSuccessfulValidJson.
public void testHandleResponse_requestSuccessfulValidJson() throws IOException {
final HttpResponse mockHttpResponse = mock(HttpResponse.class);
when(mockHttpResponse.code()).thenReturn(HttpURLConnection.HTTP_OK);
when(mockHttpResponse.body()).thenReturn(getJsonContentFrom("default_settings.json"));
assertNotNull(defaultSettingsSpiCall.handleResponse(mockHttpResponse));
}
use of com.google.firebase.crashlytics.internal.network.HttpResponse in project GreenHouse by utsanjan.
the class NativeCreateReportSpiCall method invoke.
// com.google.firebase.crashlytics.internal.report.network.CreateReportSpiCall
@Override
public boolean invoke(CreateReportRequest requestData, boolean dataCollectionToken) {
if (dataCollectionToken) {
HttpRequest httpRequest = getHttpRequest();
HttpRequest httpRequest2 = applyMultipartDataTo(applyHeadersTo(httpRequest, requestData.googleAppId), requestData.organizationId, requestData.report);
Logger logger = Logger.getLogger();
logger.d("Sending report to: " + getUrl());
try {
HttpResponse httpResponse = httpRequest2.execute();
int statusCode = httpResponse.code();
Logger logger2 = Logger.getLogger();
logger2.d("Result was: " + statusCode);
return ResponseParser.parse(statusCode) == 0;
} catch (IOException ioe) {
throw new RuntimeException(ioe);
}
} else {
throw new RuntimeException("An invalid data collection token was used.");
}
}
use of com.google.firebase.crashlytics.internal.network.HttpResponse in project GreenHouse by utsanjan.
the class AbstractAppSpiCall method invoke.
// com.google.firebase.crashlytics.internal.settings.network.AppSpiCall
@Override
public boolean invoke(AppRequestData requestData, boolean dataCollectionToken) {
if (dataCollectionToken) {
HttpRequest httpRequest = applyMultipartDataTo(applyHeadersTo(getHttpRequest(), requestData), requestData);
Logger logger = Logger.getLogger();
logger.d("Sending app info to " + getUrl());
try {
HttpResponse httpResponse = httpRequest.execute();
int statusCode = httpResponse.code();
String kind = "POST".equalsIgnoreCase(httpRequest.method()) ? "Create" : "Update";
Logger logger2 = Logger.getLogger();
logger2.d(kind + " app request ID: " + httpResponse.header(AbstractSpiCall.HEADER_REQUEST_ID));
Logger logger3 = Logger.getLogger();
logger3.d("Result was " + statusCode);
return ResponseParser.parse(statusCode) == 0;
} catch (IOException ioe) {
Logger.getLogger().e("HTTP request failed.", ioe);
throw new RuntimeException(ioe);
}
} else {
throw new RuntimeException("An invalid data collection token was used.");
}
}
use of com.google.firebase.crashlytics.internal.network.HttpResponse in project firebase-android-sdk by firebase.
the class DefaultSettingsSpiCallTest method testHandleResponse_requestSuccessfulNoJson.
public void testHandleResponse_requestSuccessfulNoJson() {
final HttpResponse mockHttpResponse = mock(HttpResponse.class);
when(mockHttpResponse.code()).thenReturn(HttpURLConnection.HTTP_OK);
when(mockHttpResponse.body()).thenReturn("No Json here!");
assertNull(defaultSettingsSpiCall.handleResponse(mockHttpResponse));
// Verify failing to parse a JSON object does not result in an error log.
verify(mockLogger, never()).e(anyString());
}
use of com.google.firebase.crashlytics.internal.network.HttpResponse in project firebase-android-sdk by firebase.
the class DefaultSettingsSpiCallTest method testHandleResponse_requestSuccessfulValidJson.
public void testHandleResponse_requestSuccessfulValidJson() throws IOException {
final HttpResponse mockHttpResponse = mock(HttpResponse.class);
when(mockHttpResponse.code()).thenReturn(HttpURLConnection.HTTP_OK);
when(mockHttpResponse.body()).thenReturn(getJsonContentFrom("default_settings.json"));
assertNotNull(defaultSettingsSpiCall.handleResponse(mockHttpResponse));
}
Aggregations