private void testGetClusterSummary(Authentication authentication) throws Exception {
    expect(m_dao.findAll(capture(EasyMock.<AlertCurrentRequest>newCapture()))).andReturn(
        getMockEntitiesManyStates()).anyTimes();

    replay(m_dao);

    SecurityContextHolder.getContext().setAuthentication(authentication);

    Request request = PropertyHelper.getReadRequest(
        AlertResourceProvider.ALERT_ID, AlertResourceProvider.ALERT_DEFINITION_NAME,
        AlertResourceProvider.ALERT_LABEL, AlertResourceProvider.ALERT_STATE,
        AlertResourceProvider.ALERT_ORIGINAL_TIMESTAMP);

    Predicate predicate = new PredicateBuilder().property(
        AlertResourceProvider.ALERT_CLUSTER_NAME).equals("c1").toPredicate();

    AlertResourceProvider provider = createProvider();
    Set<Resource> results = provider.getResources(request, predicate);

    verify(m_dao);

    AlertSummaryRenderer renderer = new AlertSummaryRenderer();
    ResultImpl result = new ResultImpl(true);
    TreeNode<Resource> resources = result.getResultTree();

    AtomicInteger alertResourceId = new AtomicInteger(1);
    for (Resource resource : results) {
      resources.addChild(resource, "Alert " + alertResourceId.getAndIncrement());
    }

    Result summary = renderer.finalizeResult(result);
    Assert.assertNotNull(summary);

    // pull out the alerts_summary child set by the renderer
    TreeNode<Resource> summaryResultTree = summary.getResultTree();
    TreeNode<Resource> summaryResources = summaryResultTree.getChild("alerts_summary");

    Resource summaryResource = summaryResources.getObject();
    AlertStateSummary alertStateSummary = (AlertStateSummary) summaryResource.getPropertyValue("alerts_summary");

    Assert.assertEquals(10, alertStateSummary.Ok.Count);
    Assert.assertEquals(2, alertStateSummary.Warning.Count);
    Assert.assertEquals(1, alertStateSummary.Critical.Count);
    Assert.assertEquals(3, alertStateSummary.Unknown.Count);
  }
Tests that the {@link AlertSummaryRenderer} correctly transforms the alert
data.

@throws Exception
ambari-server/src/test/java/org/apache/ambari/server/controller/internal/AlertResourceProviderTest.java