InboxJobHandler { private void syncReadMessageState() { Set<String> idsToUpdate = resolver.getReadUpdatedMessageIds(); if (idsToUpdate.size() == 0) { return; } AirshipUrlConfig urlConfig = runtimeConfig.getUrlConfig(); URL url = getUserApiUrl(urlConfig, user.getId(), MARK_READ_MESSAGES_PATH); if (url == null) { Logger.debug("User URL null, unable to sync read messages."); return; } Logger.verbose("InboxJobHandler - Found %s messages to mark read.", idsToUpdate.size()); JsonMap payload = buildMessagesPayload(urlConfig, MARK_READ_MESSAGES_KEY, idsToUpdate); Logger.verbose("InboxJobHandler - Marking inbox messages read request with payload: %s", payload); Response response = requestFactory.createRequest("POST", url) .setCredentials(user.getId(), user.getPassword()) .setRequestBody(payload.toString(), "application/json") .setHeader(CHANNEL_ID_HEADER, channel.getId()) .setHeader("Accept", "application/vnd.urbanairship+json; version=3;") .safeExecute(); Logger.verbose("InboxJobHandler - Mark inbox messages read response: %s", response); if (response != null && response.getStatus() == HttpURLConnection.HTTP_OK) { resolver.markMessagesReadOrigin(idsToUpdate); } } InboxJobHandler(@NonNull Context context,
                    @NonNull Inbox inbox,
                    @NonNull User user,
                    @NonNull AirshipChannel channel,
                    @NonNull AirshipRuntimeConfig runtimeConfig,
                    @NonNull PreferenceDataStore dataStore); @VisibleForTesting  InboxJobHandler(@NonNull Inbox inbox,
                    @NonNull User user,
                    @NonNull AirshipChannel channel,
                    @NonNull AirshipRuntimeConfig runtimeConfig,
                    @NonNull PreferenceDataStore dataStore,
                    @NonNull RequestFactory requestFactory,
                    @NonNull MessageCenterResolver resolver);   }
@Test public void testSyncReadMessageState() { user.setUser("fakeUserId", "password"); dataStore.put(InboxJobHandler.LAST_MESSAGE_REFRESH_TIME, 300L); responses.put("https: new Response.Builder<Void>(HttpURLConnection.HTTP_INTERNAL_ERROR) .setResponseBody("{ failed }") .build()); JobInfo jobInfo = JobInfo.newBuilder() .setAction(InboxJobHandler.ACTION_RICH_PUSH_MESSAGES_UPDATE) .build(); assertEquals(JobInfo.JOB_FINISHED, jobHandler.performJob(jobInfo)); verify(inbox).onUpdateMessagesFinished(false); TestRequest testRequest = requests.get(0); assertEquals("GET", testRequest.getRequestMethod()); assertEquals("https: assertEquals(300l, testRequest.getIfModifiedSince()); assertEquals(300l, dataStore.getLong(InboxJobHandler.LAST_MESSAGE_REFRESH_TIME, 0)); }