@Test public void testAlterTableChangeDbNameNoTables() throws Exception { Map<String, Collection<String>> update = new HashMap<>(); update.put(DB.toLowerCase(), Collections.singleton(PATH)); String newDbName = "Db2"; NotificationEvent event = new NotificationEvent(0, 0, ALTER_TABLE.toString(), ""); event.setDbName(newDbName); event.setTableName(TABLE); MessageDeserializer deserializer = Mockito.mock(SentryJSONMessageDeserializer.class); SentryJSONAlterTableMessage message = new SentryJSONAlterTableMessage(SERVER, PRINCIPAL, TABLE_OBJ, TABLE_OBJ, 0L); Mockito.when(deserializer.getAlterTableMessage("")).thenReturn(message); FullUpdateModifier.applyEvent(update, event, deserializer); assertEquals(Collections.singleton(PATH), update.get(newDbName.toLowerCase())); assertFalse(update.containsKey(DB.toLowerCase())); }
static void applyEvent(Map<String, Collection<String>> image, NotificationEvent event, MessageDeserializer deserializer) { EventMessage.EventType eventType = EventMessage.EventType.valueOf(event.getEventType()); switch (eventType) { case CREATE_DATABASE: createDatabase(image, event, deserializer); break; case DROP_DATABASE: dropDatabase(image, event, deserializer); break; case CREATE_TABLE: createTable(image, event, deserializer); break; case DROP_TABLE: dropTable(image, event, deserializer); break; case ALTER_TABLE: alterTable(image, event, deserializer); break; case ADD_PARTITION: addPartition(image, event, deserializer); break; case DROP_PARTITION: dropPartition(image, event, deserializer); break; case ALTER_PARTITION: alterPartition(image, event, deserializer); break; default: LOGGER.error("Notification with ID:{} has invalid event type: {}", event.getEventId(), event.getEventType()); break; } }
FullUpdateModifier { static void applyEvent(Map<String, Collection<String>> image, NotificationEvent event, MessageDeserializer deserializer) { EventMessage.EventType eventType = EventMessage.EventType.valueOf(event.getEventType()); switch (eventType) { case CREATE_DATABASE: createDatabase(image, event, deserializer); break; case DROP_DATABASE: dropDatabase(image, event, deserializer); break; case CREATE_TABLE: createTable(image, event, deserializer); break; case DROP_TABLE: dropTable(image, event, deserializer); break; case ALTER_TABLE: alterTable(image, event, deserializer); break; case ADD_PARTITION: addPartition(image, event, deserializer); break; case DROP_PARTITION: dropPartition(image, event, deserializer); break; case ALTER_PARTITION: alterPartition(image, event, deserializer); break; default: LOGGER.error("Notification with ID:{} has invalid event type: {}", event.getEventId(), event.getEventType()); break; } } }
FullUpdateModifier { static void applyEvent(Map<String, Collection<String>> image, NotificationEvent event, MessageDeserializer deserializer) { EventMessage.EventType eventType = EventMessage.EventType.valueOf(event.getEventType()); switch (eventType) { case CREATE_DATABASE: createDatabase(image, event, deserializer); break; case DROP_DATABASE: dropDatabase(image, event, deserializer); break; case CREATE_TABLE: createTable(image, event, deserializer); break; case DROP_TABLE: dropTable(image, event, deserializer); break; case ALTER_TABLE: alterTable(image, event, deserializer); break; case ADD_PARTITION: addPartition(image, event, deserializer); break; case DROP_PARTITION: dropPartition(image, event, deserializer); break; case ALTER_PARTITION: alterPartition(image, event, deserializer); break; default: LOGGER.error("Notification with ID:{} has invalid event type: {}", event.getEventId(), event.getEventType()); break; } } private  FullUpdateModifier(); }
FullUpdateModifier { static void applyEvent(Map<String, Collection<String>> image, NotificationEvent event, MessageDeserializer deserializer) { EventMessage.EventType eventType = EventMessage.EventType.valueOf(event.getEventType()); switch (eventType) { case CREATE_DATABASE: createDatabase(image, event, deserializer); break; case DROP_DATABASE: dropDatabase(image, event, deserializer); break; case CREATE_TABLE: createTable(image, event, deserializer); break; case DROP_TABLE: dropTable(image, event, deserializer); break; case ALTER_TABLE: alterTable(image, event, deserializer); break; case ADD_PARTITION: addPartition(image, event, deserializer); break; case DROP_PARTITION: dropPartition(image, event, deserializer); break; case ALTER_PARTITION: alterPartition(image, event, deserializer); break; default: LOGGER.error("Notification with ID:{} has invalid event type: {}", event.getEventId(), event.getEventType()); break; } } private  FullUpdateModifier();  }
FullUpdateModifier { static void applyEvent(Map<String, Collection<String>> image, NotificationEvent event, MessageDeserializer deserializer) { EventMessage.EventType eventType = EventMessage.EventType.valueOf(event.getEventType()); switch (eventType) { case CREATE_DATABASE: createDatabase(image, event, deserializer); break; case DROP_DATABASE: dropDatabase(image, event, deserializer); break; case CREATE_TABLE: createTable(image, event, deserializer); break; case DROP_TABLE: dropTable(image, event, deserializer); break; case ALTER_TABLE: alterTable(image, event, deserializer); break; case ADD_PARTITION: addPartition(image, event, deserializer); break; case DROP_PARTITION: dropPartition(image, event, deserializer); break; case ALTER_PARTITION: alterPartition(image, event, deserializer); break; default: LOGGER.error("Notification with ID:{} has invalid event type: {}", event.getEventId(), event.getEventType()); break; } } private  FullUpdateModifier();   }