use of com.google.firebase.crashlytics.internal.network.HttpRequestFactory in project firebase-android-sdk by firebase.
the class DefaultSettingsSpiCallTest method testWebCallNoInstanceId.
public void testWebCallNoInstanceId() throws Exception {
final SettingsRequest requestData = buildSettingsRequest(null);
final String url = "http://localhost:3000/spi/v1/platforms/android/apps/com.crashlytics.test/settings";
final InspectableHttpGetRequest request = new InspectableHttpGetRequest();
final DefaultSettingsSpiCall call = new DefaultSettingsSpiCall(url, new HttpRequestFactory() {
@Override
public HttpGetRequest buildHttpGetRequest(String url, Map<String, String> queryParams) {
request.setUrl(url);
request.setQueryParams(queryParams);
return request;
}
});
assertNotNull(call.invoke(requestData, true));
assertEquals(url, request.getUrl());
final Map<?, ?> queryParams = request.getQueryParams();
assertEquals(BUILD_VERSION, queryParams.get(DefaultSettingsSpiCall.BUILD_VERSION_PARAM));
assertEquals(DISPLAY_VERSION, queryParams.get(DefaultSettingsSpiCall.DISPLAY_VERSION_PARAM));
assertFalse(queryParams.containsKey(DefaultSettingsSpiCall.INSTANCE_PARAM));
assertEquals(Integer.toString(SOURCE), queryParams.get(DefaultSettingsSpiCall.SOURCE_PARAM));
final Map<String, String> headers = request.getHeaders();
assertEquals(GOOGLE_APP_ID, headers.get(DefaultSettingsSpiCall.HEADER_GOOGLE_APP_ID));
assertEquals(DefaultSettingsSpiCall.ANDROID_CLIENT_TYPE, headers.get(DefaultSettingsSpiCall.HEADER_CLIENT_TYPE));
assertEquals(DEVICE_MODEL, headers.get(DefaultSettingsSpiCall.HEADER_DEVICE_MODEL));
assertEquals(OS_BUILD_VERSION, headers.get(DefaultSettingsSpiCall.HEADER_OS_BUILD_VERSION));
assertEquals(OS_DISPLAY_VERSION, headers.get(DefaultSettingsSpiCall.HEADER_OS_DISPLAY_VERSION));
assertEquals(INSTALLATION_ID, headers.get(DefaultSettingsSpiCall.HEADER_INSTALLATION_ID));
assertEquals(DefaultSettingsSpiCall.ACCEPT_JSON_VALUE, headers.get(DefaultSettingsSpiCall.HEADER_ACCEPT));
}
Aggregations