title: Unit testing, custom Call class for retrofit2 request: Reponse has private access
body: <p>When I create custom Call class I can't return Response, because Response class is final. Is there any workaround for this?</p>
  
  <pre><code>public class TestCall implements Call&lt;PlacesResults&gt; {
  
      String fileType;
      String getPlacesJson = "getplaces.json";
      String getPlacesUpdatedJson = "getplaces_updated.json";
  
      public TestCall(String fileType) {
          this.fileType = fileType;
      }
  
      @Override
      public Response execute() throws IOException {
          String responseString;
          InputStream is;
          if (fileType.equals(getPlacesJson)) {
              is = InstrumentationRegistry.getContext().getAssets().open(getPlacesJson);
          } else {
              is = InstrumentationRegistry.getContext().getAssets().open(getPlacesUpdatedJson);
          }
  
          PlacesResults placesResults= new Gson().fromJson(new InputStreamReader(is), PlacesResults.class);
          //CAN"T DO IT
          return new Response&lt;PlacesResults&gt;(null, placesResults, null);
      }
  
      @Override
      public void enqueue(Callback callback) {
  
      }
  
  //default methods here
  //....
  }
  </code></pre>
  
  <p>In my unit test class I want to use it like this:</p>
  
  <pre><code>Mockito.when(mockApi.getNearbyPlaces(eq("testkey"), Matchers.anyString(), Matchers.anyInt())).thenReturn(new TestCall("getplaces.json"));
  GetPlacesAction action = new GetPlacesAction(getContext().getContentResolver(), mockEventBus, mockApi, "testkey");
  action.downloadPlaces();
  </code></pre>
  
  <p>My downloadPlaces() method look like:</p>
  
  <pre><code>public void downloadPlaces() {
      Call&lt;PlacesResults&gt; call = api.getNearbyPlaces(webApiKey, LocationLocator.getInstance().getLastLocation(), 500);
  
      PlacesResults jsonResponse = null;
      try {
          Response&lt;PlacesResults&gt; response = call.execute();
          Timber.d("response " + response);
          jsonResponse = response.body();
          if (jsonResponse == null) {
              throw new IllegalStateException("Response is null");
          }
      } catch (UnknownHostException e) {
          events.sendError(EventBus.ERROR_NO_CONNECTION);
      } catch (Exception e) {
          events.sendError(EventBus.ERROR_NO_PLACES);
          return;
      }
  
      //TODO: some database operations
  }
  </code></pre>