title: How to mock a static method in side a public class using Power mockito?
body: <p>Hi every one I am trying to mock a static method name <strong>mapCreditInfo(UCIPin, creditAssessmentResults)</strong> which has two parameters <strong>UCIPin</strong> and <strong>creditAssessmentResults</strong>. UCIPin is String type and creditAssessmentResults is List 
  This method is inside a public class ResponseMapper
  type as shown below:</p>
  
  <pre><code>private CreditInfo getAccountByUCI(String audiUser, String UCIPin) throws EnterpriseCustomerVerificationException {
      List&lt;CreditAssessmentResult&gt; creditAssessmentResults = creditInfoRepository.getUCISummary(UCIPin, audiUser);
      return ResponseMapper.mapCreditInfo(UCIPin, creditAssessmentResults);
  }
  </code></pre>
  
  <blockquote>
    <p>Note: getAccountbyUCI method is called inside another public method
    name <strong>executeCustomerVerification</strong> which is in the class
    <strong>EnterpriseCustomerVerificationService</strong></p>
  </blockquote>
  
  <p><strong>ResponseMapper class</strong> </p>
  
  <pre><code>public class ResponseMapper {
  
  public static CreditInfo mapCreditInfo(String UCIPin, List&lt;CreditAssessmentResult&gt; creditAssessmentResults) {
      CreditInfo creditInfo = new CreditInfo();
  
      creditInfo.setUCIPin(UCIPin);
  
      List&lt;AccountCreditInfo&gt; accountCreditInfos = new ArrayList&lt;AccountCreditInfo&gt;();
      for (CreditAssessmentResult creditAssessmentResult : creditAssessmentResults) {
          AccountCreditInfo accountCreditInfo = new AccountCreditInfo();
          accountCreditInfo.setDelinquenctBalance(creditAssessmentResult.getPastDueAmount());
          accountCreditInfo.setNonPayDisconnect(creditAssessmentResult.getNonpayDiscount());
          accountCreditInfo.setPreviousAccountNumber(creditAssessmentResult.getAccountNumber());
          accountCreditInfo.setUnreturnedEquipmentFlag(creditAssessmentResult.getUnreturnedEquipment());
  
          accountCreditInfos.add(accountCreditInfo);
      }
      creditInfo.setAccountCreditInfo(accountCreditInfos);
  
      return creditInfo;
  }
  </code></pre>
  
  <p>}</p>
  
  <p><strong>I have Tried like some portion of my test class as shown below</strong> :
  Test Class </p>
  
  <pre><code>@PrepareForTest( EnterpriseCustomerVerificationService.class)
  @RunWith(PowerMockRunner.class)
  public class EnterpriseCustomerVerificationServiceTest {
  
  @InjectMocks
      private EnterpriseCustomerVerificationService enterpriseCustormerVerificationServiceMock ;
  @Test
  public void executeCustomerVerificationTest() throws Exception {
      List&lt;ErrorResponse&gt; errorResponses = getErrorResponse();
      List&lt;String&gt; mso = new ArrayList&lt;String&gt;();
      mso.add("a");
      mso.add("b");
      mso.add("c");
      AddressResponse addressResponse = getAddressResponse();
      String experianAuthorization = "experianAuthorization";
      String UCIPin = "110019";
      String auditUser = "ABC";
  
      CreditInfo credit  =   getCreditInfo();
      CreditCheck creditCheck = getcreditCheck();
      EnterpriseCustomerVerificationService spy = PowerMockito.spy(new EnterpriseCustomerVerificationService());
  
      PowerMockito.when(spy,PowerMockito.method(EnterpriseCustomerVerificationService.class,"executeCreditCheck",CreditCheck.class)).withArguments(Mockito.any()).thenReturn("@1");
      Mockito.when(creditInfoRepository.getUCISummary("110019", "test")).thenReturn(getCreditAssessmentResultList());
  
      PowerMockito.mockStatic(ResponseMapper.class);
      Mockito.when(ResponseMapper.mapCreditInfo(UCIPin, getCreditAssessmentResultList())).thenReturn(credit);
  
      CustomerVerification cv = spy
              .executeCustomerVerification(getCustomerVerificationRequest1(),
                      "101");
  }
  </code></pre>
  
  <p>My question is how to mock <strong>static mapCreditInfo</strong> method using power Mockito ?</p>
  
  <p>Thanks</p>