Separate method pullImageUrlsFromNetwork to allow testing

This commit is contained in:
inorichi
2015-10-09 13:38:28 +02:00
parent ea8ded549b
commit e7ecfd1e84
3 changed files with 53 additions and 45 deletions

View File

@@ -62,21 +62,19 @@ public class ChapterManagerImpl extends BaseManager implements ChapterManager {
subscriber.onCompleted();
});
Observable<Integer> newChaptersObs =
chapterList
.flatMap(dbChapters -> Observable.from(chapters)
.filter(c -> !dbChapters.contains(c))
.toList()
.flatMap(this::insertChapters)
.map(PutResults::numberOfInserts));
Observable<Integer> newChaptersObs = chapterList
.flatMap(dbChapters -> Observable.from(chapters)
.filter(c -> !dbChapters.contains(c))
.toList()
.flatMap(this::insertChapters)
.map(PutResults::numberOfInserts));
Observable<Integer> deletedChaptersObs =
chapterList
.flatMap(dbChapters -> Observable.from(dbChapters)
.filter(c -> !chapters.contains(c))
.toList()
.flatMap(this::deleteChapters)
.map( d -> d.results().size() ));
Observable<Integer> deletedChaptersObs = chapterList
.flatMap(dbChapters -> Observable.from(dbChapters)
.filter(c -> !chapters.contains(c))
.toList()
.flatMap(this::deleteChapters)
.map( d -> d.results().size() ));
return Observable.zip(newChaptersObs, deletedChaptersObs,
(insertions, deletions) -> new PostResult(0, insertions, deletions)