title: How do I create a PagedList of an object for tests?
body: <p>I have been working with the arch libraries from Google, but one thing that has made testing difficult is working with <code>PagedList</code>.</p>
  
  <p>For this example, I am using the repository pattern and returning details from either an API or network.  </p>
  
  <p>So within the ViewModel I make a call to this interface method:</p>
  
  <pre><code>override fun getFoos(): Observable&lt;PagedList&lt;Foo&gt;&gt;
  </code></pre>
  
  <p>The Repository will then use <code>RxPagedListBuilder</code> to create the <code>Observable</code> that is of type PagedList:</p>
  
  <pre><code> override fun getFoos(): Observable&lt;PagedList&lt;Foo&gt;&gt; =
              RxPagedListBuilder(database.fooDao().selectAll(), PAGED_LIST_CONFIG).buildObservable()
  </code></pre>
  
  <p>I want to be able for tests to setup the return from these methods that return a <code>PagedList&lt;Foo&gt;</code>.  Something similar to</p>
  
  <pre><code>when(repository.getFoos()).thenReturn(Observable.just(TEST_PAGED_LIST_OF_FOOS)
  </code></pre>
  
  <p>Two questions:</p>
  
  <ol>
  <li>Is this possible?</li>
  <li>How do I create a <code>PagedList&lt;Foo&gt;</code>?</li>
  </ol>
  
  <p>My goal is to verify in a more end-to-end fashion (such as ensuring that the correct list of Foos is displayed on the screen).  The fragment/activity/view is the one observing the <code>PagedList&lt;Foo&gt;</code> from a ViewModel.</p>