@Test
public void testGetResourceOfOtherUser() throws Exception {

  Request request = PropertyHelper.getReadRequest(
          WidgetResourceProvider.WIDGET_ID_PROPERTY_ID,
          WidgetResourceProvider.WIDGET_WIDGET_NAME_PROPERTY_ID,
          WidgetResourceProvider.WIDGET_WIDGET_TYPE_PROPERTY_ID,
          WidgetResourceProvider.WIDGET_TIME_CREATED_PROPERTY_ID,
          WidgetResourceProvider.WIDGET_CLUSTER_NAME_PROPERTY_ID,
          WidgetResourceProvider.WIDGET_AUTHOR_PROPERTY_ID,
          WidgetResourceProvider.WIDGET_DESCRIPTION_PROPERTY_ID,
          WidgetResourceProvider.WIDGET_SCOPE_PROPERTY_ID,
          WidgetResourceProvider.WIDGET_METRICS_PROPERTY_ID,
          WidgetResourceProvider.WIDGET_VALUES_PROPERTY_ID,
          WidgetResourceProvider.WIDGET_PROPERTIES_PROPERTY_ID);
  AmbariManagementController amc = createMock(AmbariManagementController.class);
  Clusters clusters = createMock(Clusters.class);
  Cluster cluster = createMock(Cluster.class);
  expect(amc.getClusters()).andReturn(clusters).atLeastOnce();
  expect(clusters.getClusterById(1L)).andReturn(cluster).atLeastOnce();
  expect(cluster.getClusterName()).andReturn("c1").anyTimes();
  Predicate predicate = new PredicateBuilder().property(
          WidgetResourceProvider.WIDGET_CLUSTER_NAME_PROPERTY_ID).equals("c1")
          .and().property(WidgetResourceProvider.WIDGET_ID_PROPERTY_ID).equals("1")
          .and().property(WidgetResourceProvider.WIDGET_AUTHOR_PROPERTY_ID).equals("username").toPredicate();
  expect(dao.findById(1L)).andReturn(getMockEntities("USER").get(0));
  replay(amc, clusters, cluster, dao);
  WidgetResourceProvider provider = createProvider(amc);
  try {
    Set<Resource> results = provider.getResources(request, predicate);
  } catch (AccessDeniedException ex) {
    //Expected exception
    Assert.assertEquals("User must be author of the widget or widget must have cluster scope", ex.getMessage());
  }
}