title: Unit testing RxJava using Single.just(true) as the expected result
body: <pre><code>Android Studio 3.0
  RxJava-1
  </code></pre>
  
  <p>Unit testing the following code that will return a single with the result that could be either true or false depending if <code>findLastMessage</code> returns null or not.</p>
  
  <pre><code> public Single&lt;Boolean&gt; hasLocalStorage() {
          return Single.fromCallable(() -&gt;
                  chatStorageHelper.findLatestMessage() != null);
      }
  </code></pre>
  
  <p>In my test case I have the following:
  <code>storageHelper</code> is a mock that will return a non-null value for this case</p>
  
  <pre><code>@Test
      public void testHasLocalStorage_hasLocalStorage_returnTrue() {
          when(storageHelper.findLatestMessage()).thenReturn(new DBMessage());
  
          final Single&lt;Boolean&gt; result = Single.just(true);
          assertThat(localRepository.hasLocalStorage(), is(result));
      }
  </code></pre>
  
  <p>However, the test always fails because of this:</p>
  
  <pre><code>Expected :is &lt;rx.internal.util.ScalarSynchronousSingle@712cfb63&gt; 
  Actual   :&lt;rx.Single@32e54a9d&gt;
  </code></pre>
  
  <p>When I check what <code>Single.just(true)</code> returns is the following:</p>
  
  <pre><code>public static &lt;T&gt; Single&lt;T&gt; just(final T value) {
          return ScalarSynchronousSingle.create(value);
      }
  </code></pre>
  
  <p>Calls the ScalarSynchronousSingle. I am wondering how can I change my test case so that a <code>rx.Single</code> is return from <code>Single.just(true)</code>?</p>
  
  <p>Many thanks for any suggestions,</p>