FullUpdateModifier { private static void createTable(Map<String, Collection<String>> image, NotificationEvent event, MessageDeserializer deserializer) { SentryJSONCreateTableMessage message = (SentryJSONCreateTableMessage) deserializer .getCreateTableMessage(event.getMessage()); String dbName = message.getDB(); if ((dbName == null) || dbName.isEmpty()) { LOGGER.error("Create table event is missing database name"); return; } String tableName = message.getTable(); if ((tableName == null) || tableName.isEmpty()) { LOGGER.error("Create table event is missing table name"); return; } String location = message.getLocation(); if ((location == null) || location.isEmpty()) { LOGGER.error("Create table event is missing table location"); return; } String path = FullUpdateInitializer.pathFromURI(location); if (path == null) { return; } String authName = dbName.toLowerCase() + "." + tableName.toLowerCase(); if (!image.containsKey(authName)) { LOGGER.debug("create table {} with location {}", authName, location); Set<String> locations = new HashSet<>(1); locations.add(path); image.put(authName.intern(), locations); } else { Set<String> oldLocations = (Set<String>)image.get(authName); LOGGER.debug("Table {} already exists, ignored", authName); if (!oldLocations.contains(location)) { LOGGER.warn("Table {} exists but location is different from {}", authName, location); } } } private  FullUpdateModifier();   }
@Test public void testCreateTable() throws Exception { Map<String, Collection<String>> update = new HashMap<>(); NotificationEvent event = new NotificationEvent(0, 0, CREATE_TABLE.toString(), ""); MessageDeserializer deserializer = Mockito.mock(SentryJSONMessageDeserializer.class); SentryJSONCreateTableMessage message = new SentryJSONCreateTableMessage(SERVER, PRINCIPAL, TABLE_OBJ, Collections.emptyIterator(), 0L); Mockito.when(deserializer.getCreateTableMessage("")).thenReturn(message); FullUpdateModifier.applyEvent(update, event, deserializer); Map<String, Set<String>> expected = new HashMap<>(); expected.put(AUTH, Collections.singleton(PATH)); assertEquals(expected, update); }