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

    // assert none removed for HDFS
    m_dao.removeCurrentByService(m_cluster.getClusterId(), "HDFS");
    currentAlerts = m_dao.findCurrent();
    assertEquals(5, currentAlerts.size());

    m_dao.removeCurrentByService(m_cluster.getClusterId(), "YARN");
    currentAlerts = m_dao.findCurrent();
    assertEquals(0, 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