@Test
  public void testAlertDefinitionRemoval() throws Exception {
    Assert.assertEquals(0, definitionDao.findAll().size());
    AlertDefinitionEntity definition = ormHelper.createAlertDefinition(cluster.getClusterId());
    Assert.assertEquals(1, definitionDao.findAll().size());

    AggregateSource source = new AggregateSource();
    source.setAlertName(definition.getDefinitionName());

    AlertDefinition aggregate = new AlertDefinition();
    aggregate.setClusterId(cluster.getClusterId());
    aggregate.setComponentName("DATANODE");
    aggregate.setEnabled(true);
    aggregate.setInterval(1);
    aggregate.setLabel("DataNode Aggregate");
    aggregate.setName("datanode_aggregate");
    aggregate.setScope(Scope.ANY);
    aggregate.setServiceName("HDFS");
    aggregate.setSource(source);
    aggregate.setUuid("uuid");

    aggregateMapping.registerAggregate(cluster.getClusterId(), aggregate);
    Assert.assertNotNull(aggregateMapping.getAggregateDefinition(cluster.getClusterId(),
        source.getAlertName()));

    definitionDao.remove(definition);

    Assert.assertNull(aggregateMapping.getAggregateDefinition(cluster.getClusterId(),
        source.getAlertName()));
  }
Tests that {@link AlertDefinitionDeleteEvent} instances are fired when a
definition is removed.

@throws Exception
ambari-server/src/test/java/org/apache/ambari/server/state/alerts/AlertEventPublisherTest.java