package com.marverenic.music.player;

import android.graphics.Bitmap;

import com.marverenic.music.data.store.ReadOnlyPreferenceStore;
import com.marverenic.music.model.Song;

import java.util.List;

import rx.Observable;
import rx.Single;

public class MockPlayerController implements PlayerController {

    // TODO implement stubbed methods when a test requires interactions with a PlayerController

    @Override
    public Observable<String> getError() {
        throw new UnsupportedOperationException("Stub!");
    }

    @Override
    public Observable<String> getInfo() {
        throw new UnsupportedOperationException("Stub!");
    }

    @Override
    public Single<PlayerState> getPlayerState() {
        throw new UnsupportedOperationException("Stub!");
    }

    @Override
    public void restorePlayerState(PlayerState restoreState) {
        throw new UnsupportedOperationException("Stub!");
    }

    @Override
    public void stop() {
        throw new UnsupportedOperationException("Stub!");
    }

    @Override
    public void skip() {
        throw new UnsupportedOperationException("Stub!");
    }

    @Override
    public void previous() {
        throw new UnsupportedOperationException("Stub!");
    }

    @Override
    public void togglePlay() {
        throw new UnsupportedOperationException("Stub!");
    }

    @Override
    public void play() {
        throw new UnsupportedOperationException("Stub!");
    }

    @Override
    public void pause() {
        throw new UnsupportedOperationException("Stub!");
    }

    @Override
    public void updatePlayerPreferences(ReadOnlyPreferenceStore preferenceStore) {
        throw new UnsupportedOperationException("Stub!");
    }

    @Override
    public void setQueue(List<Song> newQueue, int newPosition) {
        throw new UnsupportedOperationException("Stub!");
    }

    @Override
    public void clearQueue() {
        throw new UnsupportedOperationException("Stub!");
    }

    @Override
    public void changeSong(int newPosition) {
        throw new UnsupportedOperationException("Stub!");
    }

    @Override
    public void editQueue(List<Song> queue, int newPosition) {
        throw new UnsupportedOperationException("Stub!");
    }

    @Override
    public void queueNext(Song song) {
        throw new UnsupportedOperationException("Stub!");
    }

    @Override
    public void queueNext(List<Song> songs) {
        throw new UnsupportedOperationException("Stub!");
    }

    @Override
    public void queueLast(Song song) {
        throw new UnsupportedOperationException("Stub!");
    }

    @Override
    public void queueLast(List<Song> songs) {
        throw new UnsupportedOperationException("Stub!");
    }

    @Override
    public void seek(int position) {
        throw new UnsupportedOperationException("Stub!");
    }

    @Override
    public Observable<Boolean> isPlaying() {
        throw new UnsupportedOperationException("Stub!");
    }

    @Override
    public Observable<Song> getNowPlaying() {
        throw new UnsupportedOperationException("Stub!");
    }

    @Override
    public Observable<List<Song>> getQueue() {
        throw new UnsupportedOperationException("Stub!");
    }

    @Override
    public Observable<Integer> getQueuePosition() {
        throw new UnsupportedOperationException("Stub!");
    }

    @Override
    public Observable<Integer> getCurrentPosition() {
        throw new UnsupportedOperationException("Stub!");
    }

    @Override
    public Observable<Integer> getDuration() {
        throw new UnsupportedOperationException("Stub!");
    }

    @Override
    public Observable<Boolean> isShuffleEnabled() {
        throw new UnsupportedOperationException("Stub!");
    }

    @Override
    public Observable<Integer> getMultiRepeatCount() {
        throw new UnsupportedOperationException("Stub!");
    }

    @Override
    public void setMultiRepeatCount(int count) {
        throw new UnsupportedOperationException("Stub!");
    }

    @Override
    public Observable<Long> getSleepTimerEndTime() {
        throw new UnsupportedOperationException("Stub!");
    }

    @Override
    public void setSleepTimerEndTime(long timestampInMillis) {
        throw new UnsupportedOperationException("Stub!");
    }

    @Override
    public void disableSleepTimer() {
        throw new UnsupportedOperationException("Stub!");
    }

    @Override
    public Observable<Bitmap> getArtwork() {
        throw new UnsupportedOperationException("Stub!");
    }
}

@@ -169,16 +169,46 @@
 .Song;%0A%0A
+import java.util.Collections;%0A
 import j
@@ -262,16 +262,52 @@
 .Single;
+%0Aimport rx.subjects.BehaviorSubject;
 %0A%0Apublic
@@ -460,16 +460,272 @@
 ntroller
+%0A    private BehaviorSubject%3CList%3CSong%3E%3E mQueue;%0A    private BehaviorSubject%3CInteger%3E mQueueIndex;%0A%0A    public MockPlayerController() %7B%0A        mQueue = BehaviorSubject.create(Collections.emptyList());%0A        mQueueIndex = BehaviorSubject.create(0);%0A    %7D
 %0A%0A    @O
@@ -787,55 +787,32 @@
     
-throw new UnsupportedOperationException(%22Stub!%22
+return Observable.never(
 );%0A 
@@ -885,55 +885,32 @@
     
-throw new UnsupportedOperationException(%22Stub!%22
+return Observable.never(
 );%0A 
@@ -1341,55 +1341,53 @@
     
-throw new UnsupportedOperationException(%22Stub!%22
+mQueueIndex.onNext(mQueueIndex.getValue() + 1
 );%0A 
@@ -1447,55 +1447,53 @@
     
-throw new UnsupportedOperationException(%22Stub!%22
+mQueueIndex.onNext(mQueueIndex.getValue() - 1
 );%0A 
@@ -2070,55 +2070,71 @@
     
-throw new UnsupportedOperationException(%22Stub!%22
+mQueue.onNext(newQueue);%0A        mQueueIndex.onNext(newPosition
 );%0A 
@@ -2196,55 +2196,43 @@
     
-throw new UnsupportedOperationException(%22Stub!%22
+setQueue(Collections.emptyList(), 0
 );%0A 
@@ -2309,55 +2309,38 @@
     
-throw new UnsupportedOperationException(%22Stub!%22
+mQueueIndex.onNext(newPosition
 );%0A 
@@ -3285,55 +3285,236 @@
     
-throw new UnsupportedOperationException(%22Stub!%22
+return Observable.combineLatest(mQueue, mQueueIndex, (queue, index) -%3E %7B%0A            if (index %3E= queue.size()) %7B%0A                return null;%0A            %7D else %7B%0A                return queue.get(index);%0A            %7D%0A        %7D
 );%0A 
@@ -3592,56 +3592,21 @@
     
-throw new UnsupportedOperationException(%22Stub!%22)
+return mQueue
 ;%0A  
@@ -3688,56 +3688,26 @@
     
-throw new UnsupportedOperationException(%22Stub!%22)
+return mQueueIndex
 ;%0A  
@@ -3917,55 +3917,76 @@
     
-throw new UnsupportedOperationException(%22Stub!%22
+return getNowPlaying().map(Song::getSongDuration).cast(Integer.class
 );%0A 

Implement basic MockPlayerController queue logic