@Test
public void test29ParsePolicyList() throws Exception {

    PolicyManagerServlet servlet = new PolicyManagerServlet();
    List<JSONObject> resultList = new ArrayList<JSONObject>();
    PolicyController mockPolicyController = Mockito.mock(PolicyController.class);
    UserInfo mockUserInfo = Mockito.mock(UserInfo.class);
    String policyName = "sampleName\\";
    String policyVersion = "sampleVersion";
    List<Object> activeDataList = new ArrayList<Object>();
    PolicyVersion mockPolicyVersion = Mockito.mock(PolicyVersion.class);
    activeDataList.add(mockPolicyVersion);
    Date mockDate = Mockito.mock(Date.class);
    when(mockPolicyController.getDataByQuery(any(String.class), any(SimpleBindings.class)))
            .thenReturn(activeDataList);
    when(mockPolicyVersion.getPolicyName()).thenReturn("testPolicyName");
    when(mockPolicyVersion.getModifiedDate()).thenReturn(mockDate);
    when(mockPolicyVersion.getActiveVersion()).thenReturn(1);
    when(mockPolicyVersion.getCreatedBy()).thenReturn("sampleUserName");
    when(mockPolicyVersion.getModifiedBy()).thenReturn("sampleUserName");
    //
    // This intermittently throws an NPE, even when fixing the method order
    //
    when(mockPolicyController.getEntityItem(UserInfo.class, "userLoginId", "sampleUserName"))
        .thenReturn(mockUserInfo);
    when(mockUserInfo.getUserName()).thenReturn("testUserName");
    Whitebox.invokeMethod(servlet, "parsePolicyList", resultList, mockPolicyController, policyName, policyVersion);
    verify(mockPolicyController, atLeast(1)).getDataByQuery(any(String.class), any(SimpleBindings.class));
    verify(mockPolicyVersion, atLeast(1)).getPolicyName();
    verify(mockPolicyVersion, atLeast(1)).getModifiedDate();
    verify(mockPolicyVersion, atLeast(1)).getActiveVersion();
    verify(mockPolicyVersion, atLeast(1)).getCreatedBy();
    verify(mockPolicyVersion, atLeast(1)).getModifiedBy();
}