MediaItemDataRepository implements MediaItemRepository { @Override public Observable<MediaItem> addLiveStream( final Media media, final int id ) { MediaItemDataStore mediaItemDataStore = mediaItemDataStoreFactory.createMasterBackendDataStore(); return mediaItemDataStore.addLiveStream( media, id ) .map( MediaItemDataMapper::transform ); } @Inject  MediaItemDataRepository(
            final MediaItemDataStoreFactory mediaItemDataStoreFactory
    ); @SuppressWarnings( CONVERT2METHODREF ) @Override Observable<List<Series>> series( Media media ); @SuppressWarnings( CONVERT2METHODREF ) @Override Observable<List<MediaItem>> mediaItems( final Media media, @Nullable final String title ); @SuppressWarnings( CONVERT2METHODREF ) @Override Observable<MediaItem> mediaItem( final Media media, final int id ); @Override Observable<MediaItem> addLiveStream( final Media media, final int id ); @Override Observable<MediaItem> removeLiveStream( final Media media, final int id ); @Override Observable<MediaItem> updateWatchedStatus( Media media, int id, boolean watched ); @SuppressWarnings( CONVERT2METHODREF ) @Override Observable<List<MediaItem>> search( String searchString );  }
@Test public void testAddLiveStreamHappyCase() { TestSubscriber<Object> subscriber = new TestSubscriber<>(); given( mockMediaItemDataStore.addLiveStream( any( Media.class ), anyInt() ) ).willReturn( Observable.just( mediaItemEntity() ) ); mediaItemDataRepository.addLiveStream( FAKE_MEDIA, FAKE_ID ) .subscribe( subscriber ); assertThat( subscriber.getOnNextEvents() ) .isNotNull() .hasSize( 1 ); verify( mockMediaItemDataStoreFactory, times( 1 ) ).createMasterBackendDataStore(); verify( mockMediaItemDataStoreFactory, times( 0 ) ).create( anyInt() ); verify( mockMediaItemDataStore ).addLiveStream( any( Media.class ), anyInt() ); }