@Test
public void testGetResourcesWithRequestInfo() throws Exception {

  Resource.Type type = Resource.Type.Request;
  expect(requestDAO.findByPks(Collections.<Long> emptyList(), true)).andReturn(Collections.<RequestEntity>emptyList()).anyTimes();
  ActionManager actionManager = createNiceMock(ActionManager.class);
  Cluster cluster = createNiceMock(Cluster.class);
  expect(cluster.getClusterId()).andReturn(1L).anyTimes();
  expect(cluster.getResourceId()).andReturn(4L).anyTimes();
  Clusters clusters = createNiceMock(Clusters.class);
  expect(clusters.getCluster("foo_cluster")).andReturn(cluster).anyTimes();
  AmbariManagementController managementController = createMock(AmbariManagementController.class);
  expect(managementController.getActionManager()).andReturn(actionManager).anyTimes();
  expect(managementController.getClusters()).andReturn(clusters).anyTimes();
  replay(managementController, clusters, cluster);
  ResourceProvider provider = AbstractControllerResourceProvider.getResourceProvider(type,
    PropertyHelper.getPropertyIds(type), PropertyHelper.getKeyPropertyIds(type),
    managementController);
  Map<String, String> requestInfoProperties = new HashMap<String, String>();
  Request request;
  Predicate predicate = new PredicateBuilder()
    .property(RequestResourceProvider.REQUEST_CLUSTER_NAME_PROPERTY_ID)
    .equals("foo_cluster")
    .and().property(RequestResourceProvider.REQUEST_ID_PROPERTY_ID)
    .equals(null)
    .and().property(RequestResourceProvider.REQUEST_STATUS_PROPERTY_ID)
    .equals(null)
    .toPredicate();
  request = PropertyHelper.getReadRequest(new HashSet<String>(),
    requestInfoProperties, null, null, null);
  expect(requestDAO.findAllRequestIds(BaseRequest.DEFAULT_PAGE_SIZE, false, 1L)).andReturn(Collections.<Long> emptyList()).anyTimes();
  replay(requestDAO);
  provider.getResources(request, predicate);
  verify(requestDAO);
  requestInfoProperties.put(BaseRequest.PAGE_SIZE_PROPERTY_KEY, "20");
  request = PropertyHelper.getReadRequest(new HashSet<String>(),
    requestInfoProperties, null, null, null);
  provider.getResources(request, predicate);
  verify(requestDAO);
  reset(requestDAO);
  requestInfoProperties.put(BaseRequest.ASC_ORDER_PROPERTY_KEY, "true");
  request = PropertyHelper.getReadRequest(new HashSet<String>(),
    requestInfoProperties, null, null, null);
  expect(requestDAO.findByPks(Collections.<Long> emptyList(), true)).andReturn(Collections.<RequestEntity>emptyList()).anyTimes();
  expect(requestDAO.findAllRequestIds(BaseRequest.DEFAULT_PAGE_SIZE, true, 1L)).andReturn(Collections.<Long> emptyList()).anyTimes();
  replay(requestDAO);
  provider.getResources(request, predicate);
  verify(requestDAO);
}