@Test
  public void testResourceProviderResponse() throws Exception {
    ProviderModule providerModule = createNiceMock(ProviderModule.class);
    ResourceProvider resourceProvider = createNiceMock(ResourceProvider.class);

    expect(providerModule.getResourceProvider(Resource.Type.AlertHistory)).andReturn(
        resourceProvider).anyTimes();

    expect(
        resourceProvider.checkPropertyIds(Collections.singleton(AlertHistoryResourceProvider.ALERT_HISTORY_HOSTNAME))).andReturn(
        Collections.emptySet()).anyTimes();

    expect(
        resourceProvider.getResources(anyObject(Request.class),
            anyObject(Predicate.class))).andReturn(
        Collections.emptySet()).anyTimes();

    expect(resourceProvider.checkPropertyIds(EasyMock.anyObject())).andReturn(
      new HashSet<>()).anyTimes();

    // strict pageRequest mock to ensure that paging is not performed on
    // the result set
    PageRequest pageRequest = EasyMock.createStrictMock(PageRequest.class);

    SortRequest sortRequest = EasyMock.createStrictMock(SortRequest.class);
    expect(sortRequest.getPropertyIds()).andReturn(new ArrayList<>()).atLeastOnce();

    replay(providerModule, resourceProvider, pageRequest, sortRequest);

    ClusterControllerImpl controller = new ClusterControllerImpl(providerModule);

    Set<String> propertyIds = new HashSet<>();
    propertyIds.add(AlertHistoryResourceProvider.ALERT_HISTORY_HOSTNAME);

    // create a result set that we will use to ensure that the contents
    // were unmodified
    Set<Resource> providerResources = new LinkedHashSet<>();
    providerResources.add(new ResourceImpl(Resource.Type.AlertHistory));

    Request request = PropertyHelper.getReadRequest(propertyIds, null, null,
        pageRequest, sortRequest);

    Predicate predicate = new PredicateBuilder().property(
        AlertHistoryResourceProvider.ALERT_HISTORY_HOSTNAME).equals(
        "c6401.ambari.apache.org").toPredicate();

    PageResponse pageResponse = controller.getPage(Resource.Type.AlertHistory,
        new QueryResponseImpl(providerResources, true, true, 0), request, predicate, pageRequest, sortRequest);

    verify(providerModule, resourceProvider, pageRequest, sortRequest);
  }
Tests that when a {@link PageResponse} is present on the
{@link Request}, in-memory paging is not performed.

@throws Exception
ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ClusterControllerImplTest.java