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

  Request request = createNiceMock(Request.class);
  DependencyInfo dependencyInfo = new DependencyInfo();
  dependencyInfo.setName("service_name/comp_name");
  dependencyInfo.setScope("cluster");
  Predicate namePredicate = new EqualsPredicate<String>(
      StackDependencyResourceProvider.COMPONENT_NAME_ID, "comp_name");
  Predicate name2Predicate = new EqualsPredicate<String>(
      StackDependencyResourceProvider.COMPONENT_NAME_ID, "comp_name2");
  Predicate depServicePredicate = new EqualsPredicate<String>(
      StackDependencyResourceProvider.DEPENDENT_SERVICE_NAME_ID, "dep_service_name");
  Predicate depCompPredicate = new EqualsPredicate<String>(
      StackDependencyResourceProvider.DEPENDENT_COMPONENT_NAME_ID, "dep_comp_name");
  Predicate stackNamePredicate = new EqualsPredicate<String>
      (StackDependencyResourceProvider.STACK_NAME_ID, "stack_name");
  Predicate stackVersionPredicate = new EqualsPredicate<String>(
      StackDependencyResourceProvider.STACK_VERSION_ID, "stack_version");
  Predicate andPredicate1 = new AndPredicate(namePredicate, depServicePredicate,
      depCompPredicate, stackNamePredicate, stackVersionPredicate);
  Predicate andPredicate2 = new AndPredicate(name2Predicate, depServicePredicate,
      depCompPredicate, stackNamePredicate, stackVersionPredicate);
  Predicate orPredicate = new OrPredicate(andPredicate1, andPredicate2);
  //mock expectations
  expect(metaInfo.getComponentDependency("stack_name", "stack_version", "dep_service_name",
      "dep_comp_name", "comp_name")).andReturn(dependencyInfo);
  expect(metaInfo.getComponentDependency("stack_name", "stack_version", "dep_service_name",
      "dep_comp_name", "comp_name2")).andThrow(new StackAccessException("test"));
  replay(metaInfo, request);
  ResourceProvider provider = createProvider();
  Set<Resource> resources = provider.getResources(request, orPredicate);
  verify(metaInfo);
  assertEquals(1, resources.size());
  Resource resource = resources.iterator().next();
  assertEquals("cluster", resource.getPropertyValue(StackDependencyResourceProvider.SCOPE_ID));
  assertEquals("comp_name", resource.getPropertyValue(StackDependencyResourceProvider.COMPONENT_NAME_ID));
  assertEquals("service_name", resource.getPropertyValue(StackDependencyResourceProvider.SERVICE_NAME_ID));
  assertEquals("dep_service_name", resource.getPropertyValue(StackDependencyResourceProvider.DEPENDENT_SERVICE_NAME_ID));
  assertEquals("dep_comp_name", resource.getPropertyValue(StackDependencyResourceProvider.DEPENDENT_COMPONENT_NAME_ID));
  assertEquals("stack_name", resource.getPropertyValue(StackDependencyResourceProvider.STACK_NAME_ID));
  assertEquals("stack_version", resource.getPropertyValue(StackDependencyResourceProvider.STACK_VERSION_ID));
}