title: How to Mock ObjectMapper readValue method?
body: <p>I am trying to mock MAPPER.readValue() but cant get the expected output.</p>
  
  <pre><code>private static final ObjectMapper MAPPER = new ObjectMapper();
  
  String res = EntityUtils.toString(response.getEntity());
  PartyDetailInfo partyInfo = MAPPER.readValue(res, PartyDetailInfo.class);
  
          if (partyInfo.getXpartyInfo() == null || partyInfo.getXpartyInfo().getXpartyInfoItem() == null
                  || partyInfo.getXpartyInfo().getXpartyInfoItem().get(0).getOrigSystemRefs() == null
                  || partyInfo.getXpartyInfo().getXpartyInfoItem().get(0).getOrigSystemRefs().getOrigSystemRefsItems()
                          .isEmpty()) {
              BusinessException exception = new BusinessException(Constants.ERROR_PARTY_ID_NOT_EXIST
                      .replace(Constants.TEMP_ZERO_REPLACE_STRING, partyDetailRequest.getPartyId()));
              exception.setErrorCode(Integer.toString(HttpStatus.SC_NOT_FOUND));
              throw exception;
          }
  </code></pre>
  
  <p>I tried mocking it but i ge partyInfo = null;</p>
  
  <pre><code>Mockito.when(Mapper.readValue(Mockito.anyString(),Mockito.eq(PartyDetailInfo.class))).thenReturn(getPartyInfoDummy());
  </code></pre>
  
  <p>Here's the getPartyInfoDummy():</p>
  
  <pre><code>private PartyDetailInfo getPartyInfoDummy(){
      List&lt;XpartyInfoItem&gt; xpartyInfoItems = new ArrayList&lt;XpartyInfoItem&gt;();
  
      XpartyInfoItem infoItem = new XpartyInfoItem();
      OrigSystemRefs origSystemRefs = new OrigSystemRefs();
      OrigSystemRefsItem origSystemRefsItem = new OrigSystemRefsItem();
      List&lt;OrigSystemRefsItem&gt; origSystemRefsItems = new ArrayList&lt;OrigSystemRefsItem&gt;();
      origSystemRefsItem.setOrigSystem("PSFT");
      origSystemRefsItem.setOrigSystemReference("PS-47439934");
      PrimaryMlsSet primaryMlsSet = new PrimaryMlsSet();
      primaryMlsSet.setNil("true");
      origSystemRefsItem.setPrimaryMlsSet(primaryMlsSet );
      origSystemRefsItems.add(origSystemRefsItem);
      origSystemRefs.setOrigSystemRefsItems(origSystemRefsItems );
      infoItem.setOrigSystemRefs(origSystemRefs);
  
      xpartyInfoItems.add(infoItem);
      PartyDetailInfo partyInfo = new PartyDetailInfo();
      XpartyInfo xpartyInfo = new XpartyInfo();
  
      xpartyInfo.setxReturnStatus(null);
      xpartyInfo.setxErrMsgs(null);
      xpartyInfo.setXpartyInfoItem(xpartyInfoItems);
  
      partyInfo.setXpartyInfo(xpartyInfo);
  
      return partyInfo;
  }
  </code></pre>
  
  <p>I dont understand whats going wrong here? Need help.</p>