/*
 * Copyright (c) 2017 Reto Inderbitzin (mail@indr.ch)
 *
 * For the full copyright and license information, please view
 * the LICENSE file that was distributed with this source code.
 */

package ch.indr.threethreefive;

import android.app.Application;
import android.content.Context;
import android.support.annotation.NonNull;

import ch.indr.threethreefive.data.db.favorites.FavoritesStore;
import ch.indr.threethreefive.data.db.music.MusicStore;
import ch.indr.threethreefive.data.network.ApiClient;
import ch.indr.threethreefive.libs.net.RobospiceManager;
import ch.indr.threethreefive.libs.qualifiers.ApplicationContext;

import static org.mockito.Mockito.mock;

public class TestAppModule extends AppModule {

  private ApiClient apiClient;
  private FavoritesStore favoritesStore;
  private MusicStore musicStore;
  private RobospiceManager robospiceManager;

  public TestAppModule(@NonNull Application application) {
    super(application);
  }

  @NonNull @Override public ApiClient apiClient(@ApplicationContext @NonNull Context context) {
    if (apiClient == null) apiClient = mock(ApiClient.class);
    return apiClient;
  }

  @NonNull @Override public FavoritesStore provideFavoritesStore(@ApplicationContext @NonNull Context context) {
    if (favoritesStore == null) favoritesStore = mock(FavoritesStore.class);
    return favoritesStore;
  }

  @NonNull @Override public MusicStore provideMusicStore(@ApplicationContext @NonNull Context context) {
    if (musicStore == null) musicStore = mock(MusicStore.class);
    return musicStore;
  }

  @NonNull @Override public RobospiceManager provideRobospiceManager() {
    if (robospiceManager == null) robospiceManager = mock(RobospiceManager.class);
    return robospiceManager;
  }
}

@@ -627,47 +627,250 @@
 xt;%0A
-%0Aimport static org.mockito.Mockito.mock
+import ch.indr.threethreefive.services.CommandSpeaker;%0Aimport ch.indr.threethreefive.services.InstructionsSpeaker;%0Aimport ch.indr.threethreefive.services.Speaker;%0A%0Aimport static org.mockito.Mockito.mock;%0Aimport static org.mockito.Mockito.when
 ;%0A%0Ap
@@ -1017,24 +1017,24 @@
 musicStore;%0A
-
   private Ro
@@ -1065,16 +1065,43 @@
 Manager;
+%0A  private Speaker speaker;
 %0A%0A  publ
@@ -1975,11 +1975,348 @@
 ger;%0A  %7D
+%0A%0A  @NonNull @Override Speaker provideSpeaker(@ApplicationContext @NonNull Context context) %7B%0A    if (speaker == null) %7B%0A      speaker = mock(Speaker.class);%0A      when(speaker.instructions()).thenReturn(mock(InstructionsSpeaker.class));%0A      when(speaker.command()).thenReturn(mock(CommandSpeaker.class));%0A    %7D%0A    return speaker;%0A  %7D
 %0A%7D%0A

Provide mock speaker