@Test
public void testGetResources() throws Exception {

  List<PermissionEntity> permissionEntities = new LinkedList<PermissionEntity>();
  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);
  // built in permissions
  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);
}