FullUpdateModifier { private static void dropTable(Map<String, Collection<String>> image, NotificationEvent event, MessageDeserializer deserializer) { SentryJSONDropTableMessage message = (SentryJSONDropTableMessage) deserializer .getDropTableMessage(event.getMessage()); String dbName = message.getDB(); if ((dbName == null) || dbName.isEmpty()) { LOGGER.error("Drop table event is missing database name"); return; } String tableName = message.getTable(); if ((tableName == null) || tableName.isEmpty()) { LOGGER.error("Drop table event is missing table name"); return; } String location = message.getLocation(); if ((location == null) || location.isEmpty()) { LOGGER.error("Drop table event is missing table location"); return; } String path = FullUpdateInitializer.pathFromURI(location); if (path == null) { return; } String authName = dbName.toLowerCase() + "." + tableName.toLowerCase(); Set<String> locations = (Set<String>)image.get(authName); if (locations != null && locations.contains(path)) { LOGGER.debug("Removing {}", authName); image.remove(authName); } else { LOGGER.warn("can't find matching table {} with location {}", authName, location); } } private  FullUpdateModifier();   }
@Test public void testDropTable() throws Exception { Map<String, Collection<String>> update = new HashMap<>(); update.put(AUTH, Collections.singleton(PATH)); NotificationEvent event = new NotificationEvent(0, 0, DROP_TABLE.toString(), ""); MessageDeserializer deserializer = Mockito.mock(SentryJSONMessageDeserializer.class); SentryJSONDropTableMessage message = new SentryJSONDropTableMessage(SERVER, PRINCIPAL, DB, TABLE, 0L, LOCATION); Mockito.when(deserializer.getDropTableMessage("")).thenReturn(message); FullUpdateModifier.applyEvent(update, event, deserializer); assertTrue(update.isEmpty()); }