@Test(expected = AmbariException.class)
  public void testDefaultGroupInvalidServiceNoCreation() throws Exception {
    initTestData();
    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);

    assertEquals(3, m_dao.findAllGroups().size());

    // create a definition with an invalid service
    AlertDefinitionEntity datanodeProcess = new AlertDefinitionEntity();
    datanodeProcess.setClusterId(m_cluster.getClusterId());
    datanodeProcess.setDefinitionName("datanode_process");
    datanodeProcess.setServiceName("INVALID");
    datanodeProcess.setComponentName("DATANODE");
    datanodeProcess.setHash(UUID.randomUUID().toString());
    datanodeProcess.setScheduleInterval(60);
    datanodeProcess.setScope(Scope.SERVICE);
    datanodeProcess.setSource("{\"type\" : \"SCRIPT\"}");
    datanodeProcess.setSourceType(SourceType.SCRIPT);

    try {
      m_definitionDao.create(datanodeProcess);
    } finally {
      // assert no group was added
      assertEquals(3, m_dao.findAllGroups().size());
    }
  }
Tests that when creating a new {@link AlertDefinitionEntity}, if the group
for its service does not exist, then it will not be created if the service
is invalid.
ambari-server/src/test/java/org/apache/ambari/server/orm/dao/AlertDispatchDAOTest.java