@Test
public void testGetResources() throws Exception {

  List<PermissionEntity> permissionEntities = new LinkedList<PermissionEntity>();
  PermissionEntity permissionEntity = createNiceMock(PermissionEntity.class);
  PermissionEntity viewUsePermissionEntity = createNiceMock(PermissionEntity.class);
  ResourceTypeEntity resourceTypeEntity = createNiceMock(ResourceTypeEntity.class);
  ViewEntity viewEntity = createMock(ViewEntity.class);
  permissionEntities.add(permissionEntity);
  expect(dao.findViewUsePermission()).andReturn(viewUsePermissionEntity);
  expect(dao.findAll()).andReturn(Collections.singletonList(permissionEntity));
  expect(permissionEntity.getId()).andReturn(99);
  expect(permissionEntity.getPermissionName()).andReturn("P1");
  expect(permissionEntity.getResourceType()).andReturn(resourceTypeEntity);
  expect(resourceTypeEntity.getName()).andReturn("V1");
  expect(viewEntity.isDeployed()).andReturn(true).anyTimes();
  expect(viewEntity.getCommonName()).andReturn("V1").anyTimes();
  expect(viewEntity.getVersion()).andReturn("1.0.0").anyTimes();
  expect(viewRegistry.getDefinition(resourceTypeEntity)).andReturn(viewEntity);
  replay(dao, permissionEntity, viewUsePermissionEntity, resourceTypeEntity, viewEntity, viewRegistry);
  ViewPermissionResourceProvider provider = new ViewPermissionResourceProvider();
  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("P1", resource.getPropertyValue(PermissionResourceProvider.PERMISSION_NAME_PROPERTY_ID));
  Assert.assertEquals("V1", resource.getPropertyValue(PermissionResourceProvider.RESOURCE_NAME_PROPERTY_ID));
  verify(dao, permissionEntity, viewUsePermissionEntity, resourceTypeEntity, viewEntity, viewRegistry);
}