@Test public void testDropPartitions() throws Exception { String partPath = "hello/world"; String partLocation = uri(partPath); Map<String, Collection<String>> update = new HashMap<>(); Set<String> locations = new HashSet<>(); locations.add(PATH); locations.add(partPath); update.put(AUTH, locations); NotificationEvent event = new NotificationEvent(0, 0, DROP_PARTITION.toString(), ""); MessageDeserializer deserializer = Mockito.mock(SentryJSONMessageDeserializer.class); SentryJSONDropPartitionMessage message = new SentryJSONDropPartitionMessage(SERVER, PRINCIPAL, TABLE_OBJ, Collections.<Map<String,String>>emptyList(), 0L, Collections.singletonList(partLocation)); Mockito.when(deserializer.getDropPartitionMessage("")).thenReturn(message); FullUpdateModifier.applyEvent(update, event, deserializer); assertEquals(Collections.singleton(PATH), update.get(AUTH)); }
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();   }