@Test
  public void testRemoveCurrenyByComponentHost() throws Exception {
    List<AlertCurrentEntity> currentAlerts = m_dao.findCurrent();
    assertNotNull(currentAlerts);
    assertEquals(5, currentAlerts.size());

    AlertCurrentEntity entity = m_dao.findCurrentByHostAndName(
        m_cluster.getClusterId(), "h1", "Alert Definition 1");

    assertNotNull(entity);

    m_dao.removeCurrentByServiceComponentHost(m_cluster.getClusterId(),
        entity.getAlertHistory().getServiceName(),
        entity.getAlertHistory().getComponentName(),
        entity.getAlertHistory().getHostName());

    currentAlerts = m_dao.findCurrent();
    assertEquals(4, currentAlerts.size());
  }
Tests that JPA does the sorting work for us.

@throws Exception
ambari-server/src/test/java/org/apache/ambari/server/orm/dao/AlertsDAOTest.java