BaseImport { T convertToJsonData(String json) { T jsonData = null; if (!TextUtils.isEmpty(json)) { try { jsonData = mMapper.readValue(json, mClazz); } catch (IOException e) { Timber.e(e, "Error converting to a json object"); } } return jsonData; } BaseImport(Preferences prefs, OkHttpClient client, ObjectMapper mapper, JsonToDatabaseDao<T> dao, Class<T> clazz); Observable<Boolean> importData();  }
@Test public void should_convert_to_json_data() { String json = "{\"name\": \"Paris\", \"ville_img\": \"img/villes/BBL.jpg\",\"lat\": 48.856614, \"lng\": 2.352222}"; City city = importer.convertToJsonData(json); assertThat(city).isNotNull(); assertThat(city.name).isEqualTo("Paris"); }
@Test public void should_return_null_if_json_is_null() { String json = null; City city = importer.convertToJsonData(json); assertThat(city).isNull(); }