title: How to mock the ResponseEntity<?> with generic type?
body: <p>I need to mock a service. i m getting null in <code>ResponseEntity&lt;?&gt;</code> resp while mocking the class. </p>
  
  <p>Method which need to mock: </p>
  
  <pre><code>public List&lt;Expression&gt; getExpression(String expressView, Localdate date) {
  
      List&lt;Expression&gt; =new ArrayList&lt;&gt;();
      Map&lt;String, Object&gt; uri = new HashMap&lt;&gt;();
      UriComponenetsBuilder build = 
          UriComponentsBuilder.fromHttpUrl("someUrl" + "/" + expressView);
      build.queryParam(someParameter, someParameter);
      build.queryParam(someParameter, someParameter);
      build.queryParam(someParameter, someParameter);
  
      HttpHeaders header = new HttpHeaders();
      header.setContentType(MediaType.APPLICATION_JSON);
      RestClient client = new RestClient(
          build.build().encode.toUriString, HttpMethod.GET.Uri, header
      );
  
      ResponseEntity&lt;?&gt; resp = restC.SomeMethod(client);
  
      if (resp = !null) {
          //it goes to these line
      }
  
    }
  </code></pre>
  
  <p>In my mock method:</p>
  
  <pre><code>when(restC.SomeMethod(client)).thenReturn(resp);
  </code></pre>
  
  <p>So above method call a service get some data get the value of expressView and save as list. when i mocked the method <code>when(restC.SomeMethod(client)).thenReturn(resp);</code> it hit the URL but the value i m getting as response <code>resp</code> is null . 
  So here i m getting the <code>resp</code> value as <code>null</code>. I checked the URL(someUrl) in postman its returning the value.</p>
  
  <p>How to mock the <code>ResponseEntity&lt;?&gt;</code>?</p>
  
  <p>Thanks.</p>