title: Simulate Bad Network with Retrofit 2 (on Actual, i.e. Non-mocked, API)
body: <p>In Retrofit 1.x I used the following pattern to create api service classes that simulated a bad network connection for certain build variants.</p>
  
  <pre class="lang-java prettyprint-override"><code>// Retrofit 1
  private &lt;T&gt; T create(Class&lt;T&gt; apiServiceClass) {
      T apiService = restAdapter.create(apiServiceClass);
      if (!BuildConfig.IS_PRODUCTION_BUILD) {
          endpoints = mockRestAdapter.create(apiServiceClass, apiService);
      }
      return apiService;
  }
  </code></pre>
  
  <p>The cool thing about this is that my actual API endpoints are used. This way I can see how the app behaves on a flaky connection and I don't need to provide mocked/artificial responses.</p>
  
  <p>Now, in Retrofit 2 the API for <code>MockRestAdapter</code> or rather <code>MockRetrofit</code> changed completely. <code>MockRetrofit#create</code> now returns a <code>BehaviorDelegate</code>. If I try to use the same pattern as before</p>
  
  <pre class="lang-java prettyprint-override"><code>// Retrofit 2
  private &lt;T&gt; T create(Class&lt;T&gt; apiServiceClass) {
      T apiService = retrofit.create(apiServiceClass);
      if (!BuildConfig.IS_PRODUCTION_BUILD) {
          endpoints = mockRetrofit.create(apiServiceClass).returning(???);
      }
      return apiService;
  }
  </code></pre>
  
  <p>I get stuck on the <code>returning(???)</code>. <code>returning</code> expects a <code>Call&lt;?&gt;</code> implementation. But I can't seem to figure out how to implement it to make it work like my Retrofit 1 example (maybe it's not intended to).</p>
  
  <p><strong>So my question is: In general, how can I achieve the above Retrofit 1 pattern for simulating a bad network on an actual API with Retrofit 2?</strong></p>