private void verifyInsertEventReceived(String defaultDbName, String tblName,
      List<List<String>> partKeyVals, FireEventRequest rqst, long expectedStartEventId,
      int expectedNumOfEvents) throws Exception {
    FireEventResponse response = msClient.fireListenerEvent(rqst);
    assertTrue("Event id must be set in the fireEvent response", response.isSetEventIds());
    Assert.assertNotNull(response.getEventIds());
    Assert.assertTrue(response.getEventIds().size() == expectedNumOfEvents);
    for (int i = 0; i < expectedNumOfEvents; i++) {
      Assert.assertEquals(expectedStartEventId + i, response.getEventIds().get(i).longValue());
    }

    // Get notifications from metastore
    NotificationEventResponse rsp = msClient.getNextNotification(expectedStartEventId-1, 0, null);
    assertEquals(expectedNumOfEvents, rsp.getEventsSize());
    for (int i=0; i<expectedNumOfEvents; i++) {
      NotificationEvent event = rsp.getEvents().get(i);
      assertEquals(expectedStartEventId+i, event.getEventId());
      assertTrue(event.getEventTime() >= startTime);
      assertEquals(EventType.INSERT.toString(), event.getEventType());
      assertEquals(defaultDbName, event.getDbName());
      assertEquals(tblName, event.getTableName());
      // Parse the message field
      verifyInsert(event, defaultDbName, tblName);
      InsertMessage insertMessage = md.getInsertMessage(event.getMessage());
      List<String> ptnValues = insertMessage.getPtnObj().getValues();
      assertFalse(insertMessage.isReplace());
      assertEquals(partKeyVals.get(i), ptnValues);
    }
  }
Tests DbNotificationListener when used as a transactional event listener
(hive.metastore.transactional.event.listeners)
itests/hcatalog-unit/src/test/java/org/apache/hive/hcatalog/listener/TestDbNotificationListener.java