Dictionary implements Parcelable { protected Map<String, Boolean> getAudioPaths() { HashMap<String, Boolean> pathMap = new HashMap<>(); for (Translation translation : translations) { if (translation.isAudioFilePresent()) { pathMap.put(translation.getFilePath(), translation.getIsAsset()); } } return pathMap; } Dictionary(String language, Translation[] translations, long dbId);  Dictionary(String language); protected  Dictionary(Parcel in); String getLanguage(); int getTranslationCount(); Translation getTranslation(int index); Translation getTranslationBySourcePhrase(String sourcePhrase); long getDbId(); @Override String toString(); @Override int describeContents(); @Override void writeToParcel(Parcel dest, int flags); static final Creator<Dictionary> CREATOR; }
@Test public void shouldReturnMapOfAudioPathsToAssetBoolean() { Translation firstTranslation = new Translation("", false, "/filename1", 1L, ""); Translation secondTranslation = new Translation("", true, "/filename2", 1L, ""); Dictionary dictionary = new Dictionary("", new Translation[]{firstTranslation, secondTranslation}, 1L); Map<String, Boolean> audioPaths = dictionary.getAudioPaths(); assertEquals(2, audioPaths.size()); assertTrue(audioPaths.containsKey("/filename1")); assertTrue(audioPaths.containsKey("/filename2")); assertFalse(audioPaths.get("/filename1")); assertTrue(audioPaths.get("/filename2")); }
@Test public void shouldNotReturnTranslationPathsWithNoAudio() { Translation firstTranslation = new Translation("", false, "/filename1", 1L, ""); Translation secondTranslation = new Translation("", false, "", 1L, ""); Dictionary dictionary = new Dictionary("", new Translation[]{firstTranslation, secondTranslation}, 1L); Map<String, Boolean> audioPaths = dictionary.getAudioPaths(); assertEquals(1, audioPaths.size()); assertTrue(audioPaths.containsKey("/filename1")); }