### Question:
StackConfigurationDependencyResourceProvider extends
    ReadOnlyResourceProvider { @Override public Set<Resource> getResources(final Request request, Predicate predicate) throws SystemException, UnsupportedPropertyException, NoSuchResourceException, NoSuchParentResourceException { final Set<StackConfigurationDependencyRequest> 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<StackConfigurationDependencyResponse> responses = getResources(new Command<Set<StackConfigurationDependencyResponse>>() { @Override public Set<StackConfigurationDependencyResponse> invoke() throws AmbariException { return getManagementController().getStackConfigurationDependencies(requests); } }); Set<Resource> resources = new HashSet<>(); for (StackConfigurationDependencyResponse response : responses) { Resource resource = new ResourceImpl(Type.StackConfigurationDependency); setResourceProperty(resource, STACK_NAME_PROPERTY_ID, response.getStackName(), requestedIds); setResourceProperty(resource, STACK_VERSION_PROPERTY_ID, response.getStackVersion(), requestedIds); setResourceProperty(resource, SERVICE_NAME_PROPERTY_ID, response.getServiceName(), requestedIds); setResourceProperty(resource, PROPERTY_NAME_PROPERTY_ID, response.getPropertyName(), requestedIds); setResourceProperty(resource, DEPENDENCY_NAME_PROPERTY_ID, response.getDependencyName(), requestedIds); setResourceProperty(resource, DEPENDENCY_TYPE_PROPERTY_ID, response.getDependencyType(), requestedIds); resources.add(resource); } return resources; } protected  StackConfigurationDependencyResourceProvider(AmbariManagementController managementController); @Override Set<Resource> getResources(final Request request, Predicate predicate); static final String STACK_NAME_PROPERTY_ID; static final String STACK_VERSION_PROPERTY_ID; static final String SERVICE_NAME_PROPERTY_ID; static final String PROPERTY_NAME_PROPERTY_ID; static final String DEPENDENCY_NAME_PROPERTY_ID; static final String DEPENDENCY_TYPE_PROPERTY_ID; }### Answer:
@Test public void testGetResources() throws Exception{ Resource.Type type = Resource.Type.StackConfigurationDependency; AmbariManagementController managementController = createMock(AmbariManagementController.class); Set<StackConfigurationDependencyResponse> allResponse = new HashSet<>(); allResponse.add(new StackConfigurationDependencyResponse("depName", "depType")); expect(managementController.getStackConfigurationDependencies( AbstractResourceProviderTest.Matcher.getStackConfigurationDependencyRequestSet(null, null, null, null, null))). andReturn(allResponse).times(1); replay(managementController); ResourceProvider provider = AbstractControllerResourceProvider.getResourceProvider( type, managementController); Set<String> propertyIds = new HashSet<>(); propertyIds.add(StackConfigurationDependencyResourceProvider.STACK_NAME_PROPERTY_ID); propertyIds.add(StackConfigurationDependencyResourceProvider.STACK_VERSION_PROPERTY_ID); propertyIds.add(StackConfigurationDependencyResourceProvider.SERVICE_NAME_PROPERTY_ID); propertyIds.add(StackConfigurationDependencyResourceProvider.PROPERTY_NAME_PROPERTY_ID); propertyIds.add(StackConfigurationDependencyResourceProvider.DEPENDENCY_NAME_PROPERTY_ID); propertyIds.add(StackConfigurationDependencyResourceProvider.DEPENDENCY_TYPE_PROPERTY_ID); Request request = PropertyHelper.getReadRequest(propertyIds); Set<Resource> resources = provider.getResources(request, null); Assert.assertEquals(allResponse.size(), resources.size()); for (Resource resource : resources) { String dependencyName = (String) resource.getPropertyValue(StackConfigurationDependencyResourceProvider.DEPENDENCY_NAME_PROPERTY_ID); String dependencyType = (String) resource.getPropertyValue(StackConfigurationDependencyResourceProvider.DEPENDENCY_TYPE_PROPERTY_ID); Assert.assertEquals("depName", dependencyName); Assert.assertEquals("depType", dependencyType); } verify(managementController); }