@Test
  public void testGlobalTargetAssociatedWithNewGroup() throws Exception {
    AlertTargetEntity target1 = m_helper.createGlobalAlertTarget();
    AlertTargetEntity target2 = m_helper.createGlobalAlertTarget();
    assertTrue(target1.isGlobal());
    assertTrue(target2.isGlobal());

    AlertGroupEntity group = m_helper.createAlertGroup(
        m_cluster.getClusterId(), null);

    group = m_dao.findGroupById(group.getGroupId());
    assertNotNull(group);
    assertEquals(2, group.getAlertTargets().size());

    Iterator<AlertTargetEntity> iterator = group.getAlertTargets().iterator();
    AlertTargetEntity groupTarget1 = iterator.next();
    AlertTargetEntity groupTarget2 = iterator.next();

    assertTrue(groupTarget1.isGlobal());
    assertTrue(groupTarget2.isGlobal());
  }
Tests that a newly created group is correctly associated with all global
targets.
ambari-server/src/test/java/org/apache/ambari/server/orm/dao/AlertDispatchDAOTest.java