### Question:
StageResourceProvider extends AbstractControllerResourceProvider implements ExtendedResourceProvider { @Override public QueryResponse queryForResources(Request request, Predicate predicate) throws SystemException, UnsupportedPropertyException, NoSuchResourceException, NoSuchParentResourceException { Set<Resource> results = getResources(request, predicate); return new QueryResponseImpl(results, request.getSortRequest() != null, false, results.size()); } StageResourceProvider(AmbariManagementController managementController); @Override RequestStatus createResources(Request request); @Override RequestStatus updateResources(Request request, Predicate predicate); @Override RequestStatus deleteResources(Request request, Predicate predicate); @Override Set<Resource> getResources(Request request, Predicate predicate); @Override QueryResponse queryForResources(Request request, Predicate predicate); static final String STAGE_STAGE_ID; static final String STAGE_CLUSTER_NAME; static final String STAGE_REQUEST_ID; static final String STAGE_LOG_INFO; static final String STAGE_CONTEXT; static final String STAGE_COMMAND_PARAMS; static final String STAGE_HOST_PARAMS; static final String STAGE_SKIPPABLE; static final String STAGE_PROGRESS_PERCENT; static final String STAGE_STATUS; static final String STAGE_DISPLAY_STATUS; static final String STAGE_START_TIME; static final String STAGE_END_TIME; }### Answer:
@Test @Ignore public void testQueryForResources() throws Exception { StageResourceProvider provider = new StageResourceProvider(managementController); Request request = createNiceMock(Request.class); Predicate predicate = createNiceMock(Predicate.class); List<StageEntity> entities = getStageEntities(HostRoleStatus.COMPLETED); expect(dao.findAll(request, predicate)).andReturn(entities); expect(clusters.getClusterById(anyLong())).andReturn(cluster).anyTimes(); expect(cluster.getClusterName()).andReturn("c1").anyTimes(); replay(dao, clusters, cluster, request, predicate); QueryResponse response = provider.queryForResources(request, predicate); Set<Resource> resources = response.getResources(); Assert.assertEquals(1, resources.size()); Assert.assertFalse(response.isSortedResponse()); Assert.assertFalse(response.isPagedResponse()); Assert.assertEquals(1, response.getTotalResourceCount()); verify(dao, clusters, cluster); }