Search in sources :

Example 1 with InspectableHttpGetRequest

use of com.google.firebase.crashlytics.internal.network.InspectableHttpGetRequest 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));
}
Also used : HttpRequestFactory(com.google.firebase.crashlytics.internal.network.HttpRequestFactory) SettingsRequest(com.google.firebase.crashlytics.internal.settings.model.SettingsRequest) InspectableHttpGetRequest(com.google.firebase.crashlytics.internal.network.InspectableHttpGetRequest) HttpGetRequest(com.google.firebase.crashlytics.internal.network.HttpGetRequest) InspectableHttpGetRequest(com.google.firebase.crashlytics.internal.network.InspectableHttpGetRequest)

Example 2 with InspectableHttpGetRequest

use of com.google.firebase.crashlytics.internal.network.InspectableHttpGetRequest 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));
}
Also used : HttpRequestFactory(com.google.firebase.crashlytics.internal.network.HttpRequestFactory) InspectableHttpGetRequest(com.google.firebase.crashlytics.internal.network.InspectableHttpGetRequest) HttpGetRequest(com.google.firebase.crashlytics.internal.network.HttpGetRequest) InspectableHttpGetRequest(com.google.firebase.crashlytics.internal.network.InspectableHttpGetRequest)

Example 3 with InspectableHttpGetRequest

use of com.google.firebase.crashlytics.internal.network.InspectableHttpGetRequest 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));
}
Also used : HttpRequestFactory(com.google.firebase.crashlytics.internal.network.HttpRequestFactory) InspectableHttpGetRequest(com.google.firebase.crashlytics.internal.network.InspectableHttpGetRequest) HttpGetRequest(com.google.firebase.crashlytics.internal.network.HttpGetRequest) InspectableHttpGetRequest(com.google.firebase.crashlytics.internal.network.InspectableHttpGetRequest)

Example 4 with InspectableHttpGetRequest

use of com.google.firebase.crashlytics.internal.network.InspectableHttpGetRequest 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));
}
Also used : HttpRequestFactory(com.google.firebase.crashlytics.internal.network.HttpRequestFactory) SettingsRequest(com.google.firebase.crashlytics.internal.settings.model.SettingsRequest) InspectableHttpGetRequest(com.google.firebase.crashlytics.internal.network.InspectableHttpGetRequest) HttpGetRequest(com.google.firebase.crashlytics.internal.network.HttpGetRequest) InspectableHttpGetRequest(com.google.firebase.crashlytics.internal.network.InspectableHttpGetRequest)

Aggregations

HttpGetRequest (com.google.firebase.crashlytics.internal.network.HttpGetRequest)4 HttpRequestFactory (com.google.firebase.crashlytics.internal.network.HttpRequestFactory)4 InspectableHttpGetRequest (com.google.firebase.crashlytics.internal.network.InspectableHttpGetRequest)4 SettingsRequest (com.google.firebase.crashlytics.internal.settings.model.SettingsRequest)2