@Test
public void testGetResources() throws Exception {

  Properties properties = new Properties();
  properties.put("p1", "v1");
  Configuration ambariConfig = new Configuration(properties);
  ViewConfig config = ViewConfigTest.getConfig(xml);
  ViewEntity viewEntity = ViewRegistryTest.getViewEntity(config, ambariConfig, getClass().getClassLoader(), "");
  ViewRegistryTest.getViewInstanceEntity(viewEntity, config.getInstances().get(0));
  Map<Resource.Type, ViewSubResourceDefinition> resourceDefinitions = viewEntity.getResourceDefinitions();
  Assert.assertEquals(1, resourceDefinitions.size());
  Resource.Type type = resourceDefinitions.keySet().iterator().next();
  ViewSubResourceProvider viewSubResourceProvider = new ViewSubResourceProvider(type, MyResource.class, "id", viewEntity);
  Request request = PropertyHelper.getReadRequest("id", "properties", "metrics/myMetric");
  Predicate predicate = new AlwaysPredicate();
  Set<Resource> resources = viewSubResourceProvider.getResources(request, predicate);
  Assert.assertEquals(2, resources.size());
  predicate = new PredicateBuilder().property("metrics/myMetric").greaterThan(1).toPredicate();
  resources = viewSubResourceProvider.getResources(request, predicate);
  Assert.assertEquals(1, resources.size());
  Assert.assertTrue(((Integer) resources.iterator().next().getPropertyValue("metrics/myMetric")) > 1);
}