@Test
public void testGetResources() throws SystemException,
    UnsupportedPropertyException, NoSuchResourceException,
    NoSuchParentResourceException {

  Set<Resource> expected = new HashSet<Resource>();
  expected.add(createJobResponse("Cluster100", "workflow1", "job1"));
  expected.add(createJobResponse("Cluster100", "workflow2", "job2"));
  expected.add(createJobResponse("Cluster100", "workflow2", "job3"));
  Resource.Type type = Resource.Type.Job;
  Set<String> propertyIds = PropertyHelper.getPropertyIds(type);
  JobFetcher jobFetcher = createMock(JobFetcher.class);
  expect(jobFetcher.fetchJobDetails(propertyIds, null, "workflow2", null))
      .andReturn(expected).once();
  replay(jobFetcher);
  Map<Resource.Type,String> keyPropertyIds = PropertyHelper
      .getKeyPropertyIds(type);
  ResourceProvider provider = new JobResourceProvider(propertyIds,
      keyPropertyIds, jobFetcher);
  Request request = PropertyHelper.getReadRequest(propertyIds);
  Predicate predicate = new PredicateBuilder()
      .property(JobResourceProvider.JOB_WORKFLOW_ID_PROPERTY_ID)
      .equals("workflow2").toPredicate();
  Set<Resource> resources = provider.getResources(request, predicate);
  Assert.assertEquals(3, resources.size());
  Set<String> names = new HashSet<String>();
  for (Resource resource : resources) {
    String clusterName = (String) resource
        .getPropertyValue(JobResourceProvider.JOB_CLUSTER_NAME_PROPERTY_ID);
    Assert.assertEquals("Cluster100", clusterName);
    names.add((String) resource
        .getPropertyValue(JobResourceProvider.JOB_ID_PROPERTY_ID));
  }
  // Make sure that all of the response objects got moved into resources
  for (Resource resource : expected) {
    Assert.assertTrue(names.contains(resource
        .getPropertyValue(JobResourceProvider.JOB_ID_PROPERTY_ID)));
  }
  verify(jobFetcher);
}