SyncSettingsReader { @Nullable public SyncSettings readSyncSettings(@Nullable final String json) { if (TextUtils.isEmpty(json)) { return null; } try { return readSyncSettings(new StringReader(json)); } catch (IOException ioe) { Log.w(TAG, ioe.getMessage()); } return null; }  @Nullable SyncSettings readSyncSettings(@Nullable final String json); @NonNull SyncSettings readSyncSettings(@NonNull final Reader in); @NonNull SyncSettings readSyncSettings(@NonNull final JsonReader reader);  }
@Test public void testReadSyncSettingsFromJsonString() throws Exception { final String json = TestHelper.getFixture("sync_settings.json"); final SyncSettings syncSettings = syncSettingsReader.readSyncSettings(json); assertNotNull(syncSettings); assertEquals("http: syncSettings.getServerUrl()); assertEquals("my!token#", syncSettings.getToken()); assertEquals("status/", syncSettings.getStatusUrl()); assertEquals("import/", syncSettings.getImportUrl()); assertEquals(1, syncSettings.getExports() .size()); assertEquals("export/sqlite/", syncSettings.getExports() .get(0) .getUrl()); assertEquals("databases/data.db", syncSettings.getExports() .get(0) .getFile()); }
@Test public void testReadSyncSettingsFromInvalidJsonString() throws Exception { final SyncSettings syncSettings = syncSettingsReader.readSyncSettings(""); assertNull(syncSettings); }