title: Spring boot test - PowerMockito to mock and stub constructor
body: <p>Using Spring boot starter test for testing my application but I am using third party library. Lets suppose we have a class TRequest and it has some constructor and I want to mock and stub that constructor to return the result. </p>
  
  <pre><code>@SpringBootTest
  @RunWith(SpringRunner.class)
  @PrepareForEverythingForTest
  public class TestClass {
  
  @MockBean
  TRequest trequest ; 
  
  @Before
  public void setUp() throws Exception {
      PowerMockito.whenNew(TRequest.class).withAnyArguments().thenReturn(trequest);
  
  }
  }
  </code></pre>
  
  <p>Now when I am trying to create the constructor using new, it is not returning the correct stubbed result.</p>
  
  <pre><code>  TRequest trequest1 = new TRequest("apiKey","secretKey") ; 
    trequest.equals(trequest1) ; // false but I want it to be true
  </code></pre>