@Test public void testFetchRemoteDataRequestFailure() { Map<String, List<String>> headers = new HashMap<>(); testRequest.response = new Response.Builder<Void>(HttpURLConnection.HTTP_NOT_IMPLEMENTED) .setResponseHeaders(headers) .build(); String requestTimestamp = DateUtils.createIso8601TimeStamp(0); Response response = client.fetchRemoteData(requestTimestamp, new Locale("en")); assertNotNull("Response should not be null", response); assertEquals("Response status should be 501", HttpURLConnection.HTTP_NOT_IMPLEMENTED, response.getStatus()); }
@Nullable Response fetchRemoteData(@Nullable String lastModified, @NonNull Locale locale) { URL url = getRemoteDataURL(locale); if (url == null) { Logger.debug("Remote Data URL null. Unable to update tagGroups."); return null; } Request request = requestFactory.createRequest("GET", url) .setCredentials(runtimeConfig.getConfigOptions().appKey, runtimeConfig.getConfigOptions().appSecret); if (lastModified != null) { request.setHeader("If-Modified-Since", lastModified); } return request.safeExecute(); }
RemoteDataApiClient { @Nullable Response fetchRemoteData(@Nullable String lastModified, @NonNull Locale locale) { URL url = getRemoteDataURL(locale); if (url == null) { Logger.debug("Remote Data URL null. Unable to update tagGroups."); return null; } Request request = requestFactory.createRequest("GET", url) .setCredentials(runtimeConfig.getConfigOptions().appKey, runtimeConfig.getConfigOptions().appSecret); if (lastModified != null) { request.setHeader("If-Modified-Since", lastModified); } return request.safeExecute(); } }
RemoteDataApiClient { @Nullable Response fetchRemoteData(@Nullable String lastModified, @NonNull Locale locale) { URL url = getRemoteDataURL(locale); if (url == null) { Logger.debug("Remote Data URL null. Unable to update tagGroups."); return null; } Request request = requestFactory.createRequest("GET", url) .setCredentials(runtimeConfig.getConfigOptions().appKey, runtimeConfig.getConfigOptions().appSecret); if (lastModified != null) { request.setHeader("If-Modified-Since", lastModified); } return request.safeExecute(); } RemoteDataApiClient(@NonNull AirshipRuntimeConfig runtimeConfig,
                        @NonNull PushProviders pushProviders); @VisibleForTesting  RemoteDataApiClient(@NonNull AirshipRuntimeConfig runtimeConfig,
                        @NonNull PushProviders pushProviders,
                        @NonNull RequestFactory requestFactory); }
RemoteDataApiClient { @Nullable Response fetchRemoteData(@Nullable String lastModified, @NonNull Locale locale) { URL url = getRemoteDataURL(locale); if (url == null) { Logger.debug("Remote Data URL null. Unable to update tagGroups."); return null; } Request request = requestFactory.createRequest("GET", url) .setCredentials(runtimeConfig.getConfigOptions().appKey, runtimeConfig.getConfigOptions().appSecret); if (lastModified != null) { request.setHeader("If-Modified-Since", lastModified); } return request.safeExecute(); } RemoteDataApiClient(@NonNull AirshipRuntimeConfig runtimeConfig,
                        @NonNull PushProviders pushProviders); @VisibleForTesting  RemoteDataApiClient(@NonNull AirshipRuntimeConfig runtimeConfig,
                        @NonNull PushProviders pushProviders,
                        @NonNull RequestFactory requestFactory);  }
RemoteDataApiClient { @Nullable Response fetchRemoteData(@Nullable String lastModified, @NonNull Locale locale) { URL url = getRemoteDataURL(locale); if (url == null) { Logger.debug("Remote Data URL null. Unable to update tagGroups."); return null; } Request request = requestFactory.createRequest("GET", url) .setCredentials(runtimeConfig.getConfigOptions().appKey, runtimeConfig.getConfigOptions().appSecret); if (lastModified != null) { request.setHeader("If-Modified-Since", lastModified); } return request.safeExecute(); } RemoteDataApiClient(@NonNull AirshipRuntimeConfig runtimeConfig,
                        @NonNull PushProviders pushProviders); @VisibleForTesting  RemoteDataApiClient(@NonNull AirshipRuntimeConfig runtimeConfig,
                        @NonNull PushProviders pushProviders,
                        @NonNull RequestFactory requestFactory);   }