### Question:
PermissionResourceProvider extends AbstractResourceProvider { @Override public Set<Resource> getResources(Request request, Predicate predicate) throws SystemException, UnsupportedPropertyException, NoSuchResourceException, NoSuchParentResourceException { Set<Resource> resources = new HashSet<>(); Set<String> requestedIds = getRequestPropertyIds(request, predicate); for(PermissionEntity permissionEntity : permissionDAO.findAll()){ resources.add(toResource(permissionEntity, requestedIds)); } return resources; } PermissionResourceProvider(); static void init(PermissionDAO dao); @Override RequestStatus createResources(Request request); @Override Set<Resource> getResources(Request request, Predicate predicate); @Override RequestStatus updateResources(Request request, Predicate predicate); @Override RequestStatus deleteResources(Request request, Predicate predicate); @Override Map<Resource.Type, String> getKeyPropertyIds(); static final String PERMISSION_ID_PROPERTY_ID; static final String PERMISSION_NAME_PROPERTY_ID; static final String PERMISSION_LABEL_PROPERTY_ID; static final String RESOURCE_NAME_PROPERTY_ID; static final String SORT_ORDER_PROPERTY_ID; }### Answer:
@Test public void testGetResources() throws Exception { List<PermissionEntity> permissionEntities = new LinkedList<>(); PermissionEntity permissionEntity = createNiceMock(PermissionEntity.class); ResourceTypeEntity resourceTypeEntity = createNiceMock(ResourceTypeEntity.class); permissionEntities.add(permissionEntity); expect(dao.findAll()).andReturn(permissionEntities); expect(permissionEntity.getId()).andReturn(99); expect(permissionEntity.getPermissionName()).andReturn("AMBARI.ADMINISTRATOR"); expect(permissionEntity.getPermissionLabel()).andReturn("Ambari Administrator"); expect(permissionEntity.getSortOrder()).andReturn(1); expect(permissionEntity.getResourceType()).andReturn(resourceTypeEntity); expect(resourceTypeEntity.getName()).andReturn("AMBARI"); replay(dao, permissionEntity, resourceTypeEntity); PermissionResourceProvider provider = new PermissionResourceProvider(); Set<Resource> resources = provider.getResources(PropertyHelper.getReadRequest(), null); Assert.assertEquals(1, resources.size()); Resource resource = resources.iterator().next(); Assert.assertEquals(99, resource.getPropertyValue(PermissionResourceProvider.PERMISSION_ID_PROPERTY_ID)); Assert.assertEquals("AMBARI.ADMINISTRATOR", resource.getPropertyValue(PermissionResourceProvider.PERMISSION_NAME_PROPERTY_ID)); Assert.assertEquals("Ambari Administrator", resource.getPropertyValue(PermissionResourceProvider.PERMISSION_LABEL_PROPERTY_ID)); Assert.assertEquals("AMBARI", resource.getPropertyValue(PermissionResourceProvider.RESOURCE_NAME_PROPERTY_ID)); Assert.assertEquals(1, resource.getPropertyValue(PermissionResourceProvider.SORT_ORDER_PROPERTY_ID)); verify(dao, permissionEntity, resourceTypeEntity); }