@Test
public void testGetSingleResource() throws Exception {

  Request request = PropertyHelper.getReadRequest(
      WidgetLayoutResourceProvider.WIDGETLAYOUT_CLUSTER_NAME_PROPERTY_ID,
      WidgetLayoutResourceProvider.WIDGETLAYOUT_ID_PROPERTY_ID,
      WidgetLayoutResourceProvider.WIDGETLAYOUT_DISPLAY_NAME_PROPERTY_ID,
      WidgetLayoutResourceProvider.WIDGETLAYOUT_LAYOUT_NAME_PROPERTY_ID,
      WidgetLayoutResourceProvider.WIDGETLAYOUT_SECTION_NAME_PROPERTY_ID,
      WidgetLayoutResourceProvider.WIDGETLAYOUT_USERNAME_PROPERTY_ID,
      WidgetLayoutResourceProvider.WIDGETLAYOUT_SCOPE_PROPERTY_ID,
      WidgetLayoutResourceProvider.WIDGETLAYOUT_WIDGETS_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(
      WidgetLayoutResourceProvider.WIDGETLAYOUT_CLUSTER_NAME_PROPERTY_ID).equals("c1")
        .and().property(WidgetLayoutResourceProvider.WIDGETLAYOUT_ID_PROPERTY_ID).equals("1")
          .and().property(WidgetLayoutResourceProvider.WIDGETLAYOUT_USERNAME_PROPERTY_ID).equals("username").toPredicate();
  expect(dao.findById(1L)).andReturn(getMockEntities().get(0));
  replay(amc, clusters, cluster, dao);
  WidgetLayoutResourceProvider provider = createProvider(amc);
  Set<Resource> results = provider.getResources(request, predicate);
  assertEquals(1, results.size());
  Resource r = results.iterator().next();
  Assert.assertEquals("section0", r.getPropertyValue(WidgetLayoutResourceProvider.WIDGETLAYOUT_SECTION_NAME_PROPERTY_ID));
  Assert.assertEquals("CLUSTER", r.getPropertyValue(WidgetLayoutResourceProvider.WIDGETLAYOUT_SCOPE_PROPERTY_ID));
  Assert.assertEquals("username", r.getPropertyValue(WidgetLayoutResourceProvider.WIDGETLAYOUT_USERNAME_PROPERTY_ID));
  Assert.assertEquals("displ_name", r.getPropertyValue(WidgetLayoutResourceProvider.WIDGETLAYOUT_DISPLAY_NAME_PROPERTY_ID));
  Assert.assertEquals("layout name0", r.getPropertyValue(WidgetLayoutResourceProvider.WIDGETLAYOUT_LAYOUT_NAME_PROPERTY_ID));
  Assert.assertEquals("[]", r.getPropertyValue(WidgetLayoutResourceProvider.WIDGETLAYOUT_WIDGETS_PROPERTY_ID).toString());
}