title: How to use Gson TypeAdapter with an object mocked by Mockito?
body: <p>I would like to mock an object passed into Gson via TypeAdapter like this:</p>
  
  <pre><code>@RunWith(MockitoJUnitRunner.class)
  public class SceneExporterTest {
  
  @Test
  public void testWriter() {
      List&lt;SceneObject&gt; sceneObjects = mockSceneObjects();
      Gson gson = new GsonBuilder().registerTypeAdapter(SceneObject.class, new SceneExporter()).create();
  
      String s = gson.toJson(sceneObjects); //This method ends up with an exception.
  }
  
  private List&lt;SceneObject&gt; mockSceneObjects() {
      List&lt;SceneObject&gt; sceneObjects = new LinkedList&lt;&gt;();
      for (int i = 0; i &lt; 50; i++) {
          sceneObjects.add(mockSceneObject(i));
      }
      return sceneObjects;
  }
  
  private SceneObject mockSceneObject(int i) {
      SceneObject sceneObject = mock(SceneObject.class);
      //...
      return sceneObject;
  }
  
  }
  </code></pre>
  
  <p>My type adapter:</p>
  
  <pre><code>public class SceneExporter extends TypeAdapter&lt;SceneObject&gt; {
  
      @Override
      public void write(JsonWriter out, SceneObject value) throws IOException {
          out.name("position");
          out.value(toValue(value.getPosition()));
          out.name("scale");
          out.value(toValue(value.getScale()));
          out.name("rotation");
          out.value(toValue(value.getRotation()));
      }
  
      @Override
      public SceneObject read(JsonReader in) throws IOException {
          return null;
      }
  }
  </code></pre>
  
  <p>But I end up which such exception:</p>
  
  <pre><code>java.lang.UnsupportedOperationException: Attempted to serialize java.lang.Class: com.editor.api.scene.objects.SceneObject. Forgot to register a type adapter?
  </code></pre>
  
  <p>Scene object is pretty heavy object and I don't want to instantinate it normally within test. So is there a possibility to just mock it? I also would like not to use Spies.</p>