GetMediaItemList extends DynamicUseCase { @Override protected Observable buildUseCaseObservable( Map parameters ) { if (!parameters.containsKey( MEDIA_KEY ) ) { throw new IllegalArgumentException( "Key [" + MEDIA_KEY + "] is required!" ); } Media media = (Media) parameters.get( MEDIA_KEY ); switch( media ) { case PROGRAM: return getRecordedPrograms( media, parameters ); case RECENT: return this.mediaItemRepository.mediaItems( media, null ); case UPCOMING: return this.mediaItemRepository.mediaItems( media, null ); case VIDEO: return this.mediaItemRepository.mediaItems( media, null ); case MOVIE: case HOMEVIDEO: case MUSICVIDEO: case ADULT: return this.mediaItemRepository.mediaItems( media, null ); case TELEVISION: if( parameters.containsKey( TV_KEY ) ) { return this.mediaItemRepository.mediaItems( media, null ); } else { return this.mediaItemRepository.series( media ); } default : throw new IllegalArgumentException( "Key [" + media.name() + "] not found" ); } } GetMediaItemList( final MediaItemRepository mediaItemRepository, ThreadExecutor threadExecutor, PostExecutionThread postExecutionThread );  static final String MEDIA_KEY; static final String TITLE_REGEX_KEY; static final String TV_KEY; }
@Test public void testGetMediaItemForRecordedProgramDetailsUseCaseObservableHappyCase() { Media fakeMedia = Media.PROGRAM; int FAKE_RECORDED_ID = 999; getMediaItemDetails = new GetMediaItemDetails( fakeMedia, FAKE_RECORDED_ID, mockMediaItemRepository, mockThreadExecutor, mockPostExecutionThread ); getMediaItemDetails.buildUseCaseObservable(); verify( mockMediaItemRepository ).mediaItem( fakeMedia, FAKE_RECORDED_ID ); verifyZeroInteractions( mockPostExecutionThread ); verifyZeroInteractions( mockThreadExecutor ); }
@Test public void testGetMediaItemForVideoDetailsUseCaseObservableHappyCase() { Media fakeMedia = Media.PROGRAM; int FAKE_ID = 999; getMediaItemDetails = new GetMediaItemDetails( fakeMedia, FAKE_ID, mockMediaItemRepository, mockThreadExecutor, mockPostExecutionThread ); getMediaItemDetails.buildUseCaseObservable(); verify( mockMediaItemRepository ).mediaItem( fakeMedia, FAKE_ID ); verifyZeroInteractions( mockPostExecutionThread ); verifyZeroInteractions( mockThreadExecutor ); }