### Question:
UnreferencedHousekeepingPathGenerator implements HousekeepingEntityGenerator { @Override public List<HousekeepingEntity> generate(ListenerEvent listenerEvent, String clientId) { List<HousekeepingEntity> housekeepingEntities = new ArrayList<>(); switch (listenerEvent.getEventType()) { case ALTER_PARTITION: housekeepingEntities.add(generateHousekeepingEntity(listenerEvent, clientId, ((AlterPartitionEvent) listenerEvent).getOldPartitionLocation())); break; case ALTER_TABLE: housekeepingEntities.add(generateHousekeepingEntity(listenerEvent, clientId, ((AlterTableEvent) listenerEvent).getOldTableLocation())); break; case DROP_TABLE: housekeepingEntities.add(generateHousekeepingEntity(listenerEvent, clientId, ((DropTableEvent) listenerEvent).getTableLocation())); break; case DROP_PARTITION: housekeepingEntities.add(generateHousekeepingEntity(listenerEvent, clientId, ((DropPartitionEvent) listenerEvent).getPartitionLocation())); break; default: throw new BeekeeperException(format("No handler case for %s event type", listenerEvent.getEventType())); } return housekeepingEntities; } UnreferencedHousekeepingPathGenerator(String cleanupDelay); @VisibleForTesting  UnreferencedHousekeepingPathGenerator(CleanupDelayExtractor cleanupDelayExtractor, Clock clock); @Override List<HousekeepingEntity> generate(ListenerEvent listenerEvent, String clientId); @Override LifecycleEventType getLifecycleEventType(); HousekeepingEntity generateHousekeepingEntity(ListenerEvent listenerEvent, String clientId,
      String cleanupPath); static final String UNREFERENCED_DATA_RETENTION_PERIOD_PROPERTY_KEY; }### Answer:
@Test public void typicalHandleAlterTableEvent() { setupClockAndExtractor(alterTableEvent); setupListenerEvent(alterTableEvent, ALTER_TABLE); when(alterTableEvent.getOldTableLocation()).thenReturn(PATH); List<HousekeepingEntity> housekeepingEntities = generator.generate(alterTableEvent, CLIENT_ID); assertThat(housekeepingEntities.size()).isEqualTo(1); assertUnreferencedHousekeepingPathEntity(housekeepingEntities.get(0)); }
@Test public void typicalHandleDropPartitionEvent() { setupClockAndExtractor(dropPartitionEvent); setupListenerEvent(dropPartitionEvent, DROP_PARTITION); when(dropPartitionEvent.getPartitionLocation()).thenReturn(PATH); List<HousekeepingEntity> housekeepingEntities = generator.generate(dropPartitionEvent, CLIENT_ID); assertThat(housekeepingEntities.size()).isEqualTo(1); assertUnreferencedHousekeepingPathEntity(housekeepingEntities.get(0)); }
@Test public void typicalHandleDropTableEvent() { setupClockAndExtractor(dropTableEvent); setupListenerEvent(dropTableEvent, DROP_TABLE); when(dropTableEvent.getTableLocation()).thenReturn(PATH); List<HousekeepingEntity> housekeepingEntities = generator.generate(dropTableEvent, CLIENT_ID); assertThat(housekeepingEntities.size()).isEqualTo(1); assertUnreferencedHousekeepingPathEntity(housekeepingEntities.get(0)); }
@Test public void exceptionThrownOnUnhandledEvent() { CreateTableEvent createTableEvent = mock(CreateTableEvent.class); when(createTableEvent.getEventType()).thenReturn(CREATE_TABLE); try { generator.generate(createTableEvent, CLIENT_ID); fail("Should have thrown exception"); } catch (BeekeeperException e) { assertThat(e.getMessage()).isEqualTo( format("No handler case for %s event type", createTableEvent.getEventType())); } }
@Test public void typicalHandleAlterPartitionEvent() { setupClockAndExtractor(alterPartitionEvent); setupListenerEvent(alterPartitionEvent, ALTER_PARTITION); when(alterPartitionEvent.getOldPartitionLocation()).thenReturn(PATH); List<HousekeepingEntity> housekeepingEntities = generator.generate(alterPartitionEvent, CLIENT_ID); assertThat(housekeepingEntities.size()).isEqualTo(1); assertUnreferencedHousekeepingPathEntity(housekeepingEntities.get(0)); }