@Test
  public void testDefaultGroupAutomaticCreation() throws Exception {
    m_helper.addHost(m_clusters, m_cluster, HOSTNAME);
    m_helper.installHdfsService(m_cluster, m_serviceFactory, m_componentFactory, m_schFactory, HOSTNAME);
    //m_helper.installYarnService(m_cluster, m_serviceFactory, m_componentFactory, m_schFactory, HOSTNAME);

    AlertGroupEntity hdfsGroup = m_dao.findDefaultServiceGroup(
            m_cluster.getClusterId(), "HDFS");

    // remove the HDFS default group
    m_dao.remove(hdfsGroup);
    hdfsGroup = m_dao.findDefaultServiceGroup(m_cluster.getClusterId(), "HDFS");
    assertNull(hdfsGroup);

    AlertDefinitionEntity datanodeProcess = new AlertDefinitionEntity();
    datanodeProcess.setClusterId(m_cluster.getClusterId());
    datanodeProcess.setDefinitionName("datanode_process");
    datanodeProcess.setServiceName("HDFS");
    datanodeProcess.setComponentName("DATANODE");
    datanodeProcess.setHash(UUID.randomUUID().toString());
    datanodeProcess.setScheduleInterval(60);
    datanodeProcess.setScope(Scope.SERVICE);
    datanodeProcess.setSource("{\"type\" : \"SCRIPT\"}");
    datanodeProcess.setSourceType(SourceType.SCRIPT);
    m_definitionDao.create(datanodeProcess);

    // the group should be created and should be default
    hdfsGroup = m_dao.findDefaultServiceGroup(m_cluster.getClusterId(), "HDFS");
    assertNotNull(hdfsGroup);
    assertTrue(hdfsGroup.isDefault());
  }
Tests that when creating a new {@link AlertDefinitionEntity}, if the group
for its service does not exist, then it will be created.
ambari-server/src/test/java/org/apache/ambari/server/orm/dao/AlertDispatchDAOTest.java