### Question:
StackResourceProvider extends ReadOnlyResourceProvider { @Override public Set<Resource> getResources(Request request, Predicate predicate) throws SystemException, UnsupportedPropertyException, NoSuchResourceException, NoSuchParentResourceException { final Set<StackRequest> requests = new HashSet<>(); if (predicate == null) { requests.add(getRequest(Collections.emptyMap())); } else { for (Map<String, Object> propertyMap : getPropertyMaps(predicate)) { requests.add(getRequest(propertyMap)); } } Set<String> requestedIds = getRequestPropertyIds(request, predicate); Set<StackResponse> responses = getResources(new Command<Set<StackResponse>>() { @Override public Set<StackResponse> invoke() throws AmbariException { return getManagementController().getStacks(requests); } }); Set<Resource> resources = new HashSet<>(); for (StackResponse response : responses) { Resource resource = new ResourceImpl(Resource.Type.Stack); setResourceProperty(resource, STACK_NAME_PROPERTY_ID, response.getStackName(), requestedIds); resource.setProperty(STACK_NAME_PROPERTY_ID, response.getStackName()); resources.add(resource); } return resources; } protected  StackResourceProvider(AmbariManagementController managementController); @Override Set<Resource> getResources(Request request, Predicate predicate); @Override RequestStatus updateResources(Request request, Predicate predicate); static final String STACK_NAME_PROPERTY_ID; }### Answer:
@Test public void testGetResources() throws Exception { Resource.Type type = Resource.Type.Stack; AmbariManagementController managementController = createMock(AmbariManagementController.class); Set<StackResponse> allResponse = new HashSet<>(); allResponse.add(new StackResponse("Stack1")); allResponse.add(new StackResponse("Stack2")); expect(managementController.getStacks(EasyMock.anyObject())).andReturn(allResponse).once(); replay(managementController); ResourceProvider provider = AbstractControllerResourceProvider.getResourceProvider( type, managementController); Set<String> propertyIds = new HashSet<>(); propertyIds.add(StackResourceProvider.STACK_NAME_PROPERTY_ID); Request request = PropertyHelper.getReadRequest(propertyIds); Set<Resource> resources = provider.getResources(request, null); Assert.assertEquals(2, resources.size()); Set<String> stackNames = new HashSet<>(); stackNames.add("Stack1"); stackNames.add("Stack2"); for (Resource resource : resources) { String stackName = (String) resource.getPropertyValue(StackResourceProvider.STACK_NAME_PROPERTY_ID); Assert.assertTrue(stackNames.contains(stackName)); } verify(managementController); }