use of com.google.firebase.crashlytics.internal.settings.model.SettingsRequest in project firebase-android-sdk by firebase.
the class DefaultSettingsSpiCallTest method testWebCall.
public void testWebCall() throws Exception {
final String instanceId = CommonUtils.createInstanceIdFrom("fake_build_id");
final SettingsRequest requestData = buildSettingsRequest(instanceId);
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));
assertEquals(instanceId, queryParams.get(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));
}
use of com.google.firebase.crashlytics.internal.settings.model.SettingsRequest in project GreenHouse by utsanjan.
the class SettingsController method create.
public static SettingsController create(Context context, String googleAppId, IdManager idManager, HttpRequestFactory httpRequestFactory, String versionCode, String versionName, String urlEndpoint, DataCollectionArbiter dataCollectionArbiter) {
String installerPackageName = idManager.getInstallerPackageName();
CurrentTimeProvider currentTimeProvider = new SystemCurrentTimeProvider();
SettingsJsonParser settingsJsonParser = new SettingsJsonParser(currentTimeProvider);
CachedSettingsIo cachedSettingsIo = new CachedSettingsIo(context);
String settingsUrl = String.format(Locale.US, SETTINGS_URL_FORMAT, googleAppId);
SettingsSpiCall settingsSpiCall = new DefaultSettingsSpiCall(urlEndpoint, settingsUrl, httpRequestFactory);
String deviceModel = idManager.getModelName();
String osBuildVersion = idManager.getOsBuildVersionString();
String osDisplayVersion = idManager.getOsDisplayVersionString();
String instanceId = CommonUtils.createInstanceIdFrom(CommonUtils.getMappingFileId(context), googleAppId, versionName, versionCode);
int deliveryMechanismId = DeliveryMechanism.determineFrom(installerPackageName).getId();
SettingsRequest settingsRequest = new SettingsRequest(googleAppId, deviceModel, osBuildVersion, osDisplayVersion, idManager, instanceId, versionName, versionCode, deliveryMechanismId);
return new SettingsController(context, settingsRequest, currentTimeProvider, settingsJsonParser, cachedSettingsIo, settingsSpiCall, dataCollectionArbiter);
}
use of com.google.firebase.crashlytics.internal.settings.model.SettingsRequest in project firebase-android-sdk by firebase.
the class DefaultSettingsControllerTest method testNoAvailableSettingsLoad.
public void testNoAvailableSettingsLoad() throws Exception {
when(mockSettingsSpiCall.invoke(any(SettingsRequest.class), eq(true))).thenReturn(null);
when(mockCachedSettingsIo.readCachedSettings()).thenReturn(null);
TaskCompletionSource<Void> dataCollectionPermission = new TaskCompletionSource<>();
when(mockDataCollectionArbiter.waitForDataCollectionPermission(any(Executor.class))).thenReturn(dataCollectionPermission.getTask());
final SettingsRequest requestData = buildSettingsRequest();
final SettingsController controller = newSettingsController(requestData, mockCurrentTimeProvider, mockSettingsJsonParser, mockCachedSettingsIo, mockSettingsSpiCall, mockDataCollectionArbiter, false);
Task<Void> loadFinished = controller.loadSettingsData(networkExecutor);
assertNotNull(controller.getSettings());
assertFalse(controller.getAppSettings().isComplete());
dataCollectionPermission.trySetResult(null);
await(loadFinished);
assertNotNull(controller.getSettings());
assertFalse(controller.getAppSettings().isComplete());
verify(mockSettingsSpiCall).invoke(any(SettingsRequest.class), eq(true));
verify(mockCachedSettingsIo, times(2)).readCachedSettings();
verifyZeroInteractions(mockSettingsJsonParser);
verify(mockCurrentTimeProvider).getCurrentTimeMillis();
}
use of com.google.firebase.crashlytics.internal.settings.model.SettingsRequest 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