MasterBackendVideoDataStore implements VideoDataStore { @Override public Observable<List<VideoMetadataInfoEntity>> getCategory( final String category ) { Log.d( TAG, "getCategory : enter" ); Log.d( TAG, "getCategory : category=" + category ); return this.api.getVideoList( null, null, false, -1, -1 ) .flatMap( Observable::from ) .filter( entity -> entity.contentType().equals( category ) ) .toSortedList( ( entity1, entity2 ) -> entity1.title().compareTo( entity2.title() ) ) .doOnNext( entity -> Log.d( TAG, "getCategory : entity=" + entity ) ); } MasterBackendVideoDataStore( VideoApi api ); @Override Observable<List<VideoMetadataInfoEntity>> getVideos( String folder, String sort, boolean descending, int startIndex, int count ); @Override Observable<List<VideoMetadataInfoEntity>> getCategory( final String category ); @Override Observable<List<VideoMetadataInfoEntity>> getSeriesInCategory( String category, String series ); @Override Observable<VideoMetadataInfoEntity> getVideoById( int id ); @Override Observable<VideoMetadataInfoEntity> getVideoByFilename( String filename ); @Override Observable<Boolean> updateWatchedStatus( final int videoId, final boolean watched );  }
@Test public void testGetCategory() { List<VideoMetadataInfoEntity> fakeVideoMetadataInfoEntities = new ArrayList<>(); VideoMetadataInfoEntity fakeVideoMetadataInfoEntity = createVideoMetadataInfoEntity(); fakeVideoMetadataInfoEntities.add( fakeVideoMetadataInfoEntity ); Observable<List<VideoMetadataInfoEntity>> fakeObservable = Observable.just( fakeVideoMetadataInfoEntities ); given( mockVideoApi.getVideoList( null, null, false, -1, -1 ) ).willReturn( fakeObservable ); masterBackendVideoDataStore.getCategory( null ); verify( mockVideoApi ).getVideoList( null, null, false, -1, -1); }