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

  Set<Resource> expected = new HashSet<Resource>();
  expected.add(createTaskAttemptResponse("Cluster100", "workflow1", "job1",
      "taskAttempt1"));
  expected.add(createTaskAttemptResponse("Cluster100", "workflow2", "job2",
      "taskAttempt2"));
  expected.add(createTaskAttemptResponse("Cluster100", "workflow2", "job2",
      "taskAttempt3"));
  Resource.Type type = Resource.Type.TaskAttempt;
  Set<String> propertyIds = PropertyHelper.getPropertyIds(type);
  TaskAttemptFetcher taskAttemptFetcher = createMock(TaskAttemptFetcher.class);
  expect(
      taskAttemptFetcher.fetchTaskAttemptDetails(propertyIds, null, null,
          "job2", null)).andReturn(expected).once();
  replay(taskAttemptFetcher);
  Map<Resource.Type,String> keyPropertyIds = PropertyHelper
      .getKeyPropertyIds(type);
  ResourceProvider provider = new TaskAttemptResourceProvider(propertyIds,
      keyPropertyIds, taskAttemptFetcher);
  Request request = PropertyHelper.getReadRequest(propertyIds);
  Predicate predicate = new PredicateBuilder()
      .property(TaskAttemptResourceProvider.TASK_ATTEMPT_JOB_ID_PROPERTY_ID)
      .equals("job2").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(TaskAttemptResourceProvider.TASK_ATTEMPT_CLUSTER_NAME_PROPERTY_ID);
    Assert.assertEquals("Cluster100", clusterName);
    names
        .add((String) resource
            .getPropertyValue(TaskAttemptResourceProvider.TASK_ATTEMPT_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(TaskAttemptResourceProvider.TASK_ATTEMPT_ID_PROPERTY_ID)));
  }
  verify(taskAttemptFetcher);
}