### Question:
DefaultMetaStoreEventAggregator implements MetaStoreEventAggregator { @Override public List<MetaStoreEvent> aggregate(List<MetaStoreEvent> events) { Map<String, List<MetaStoreEvent>> eventsPerTable = mapEvents(events); List<MetaStoreEvent> aggregatedEvents = new ArrayList<>(); for (List<MetaStoreEvent> tableEvents : eventsPerTable.values()) { aggregatedEvents.addAll(compactor.compact(tableEvents)); } return aggregatedEvents; } DefaultMetaStoreEventAggregator();  DefaultMetaStoreEventAggregator(DefaultMetaStoreEventCompactor compactor); @Override List<MetaStoreEvent> aggregate(List<MetaStoreEvent> events);  }### Answer:
@Test public void eventsFromSingleTable() { List<MetaStoreEvent> events = Arrays.asList(mockEvent(DATABASE, TABLE1), mockEvent(DATABASE, TABLE1)); when(compactor.compact(events)).thenReturn(events); List<MetaStoreEvent> aggregatedEvents = aggregator.aggregate(events); assertThat(aggregatedEvents).isEqualTo(events); verify(compactor).compact(events); }
@Test public void eventsFromMultipleTables() { List<MetaStoreEvent> table1Events = Arrays.asList(mockEvent(DATABASE, TABLE1)); List<MetaStoreEvent> table2Events = Arrays.asList(mockEvent(DATABASE, TABLE2)); List<MetaStoreEvent> events = new ArrayList<>(); events.addAll(table1Events); events.addAll(table2Events); when(compactor.compact(table1Events)).thenReturn(table1Events); when(compactor.compact(table2Events)).thenReturn(table2Events); List<MetaStoreEvent> aggregatedEvents = aggregator.aggregate(events); assertThat(aggregatedEvents).isEqualTo(events); verify(compactor).compact(table1Events); verify(compactor).compact(table2Events); }