### Question:
CleanupDelayExtractor { public Duration extractCleanupDelay(ListenerEvent listenerEvent) { String tableCleanupDelay = listenerEvent.getTableParameters().get(propertyKey); try { return Duration.parse(tableCleanupDelay); } catch (DateTimeParseException | NullPointerException e) { log.error( "Overridden delay value '{}' for key '{}' cannot be parsed to a Duration for table '{}.{}'. Using default setting.", tableCleanupDelay, propertyKey, listenerEvent.getDbName(), listenerEvent.getTableName()); return defaultValue; } } CleanupDelayExtractor(String propertyKey, String defaultValue); Duration extractCleanupDelay(ListenerEvent listenerEvent);  }### Answer:
@Test public void typicalExtractCleanUpDelay() { String cleanupDelayInput = "P30D"; when(listenerEvent.getTableParameters()).thenReturn(Map.of(EXTRACTOR_KEY, cleanupDelayInput)); Duration cleanupDelay = cleanupDelayExtractor.extractCleanupDelay(listenerEvent); assertThat(cleanupDelay).isEqualTo(Duration.parse(cleanupDelayInput)); }
@Test public void noKeyExtractCleanUpDelay() { when(listenerEvent.getTableParameters()).thenReturn(Map.of()); Duration cleanupDelay = cleanupDelayExtractor.extractCleanupDelay(listenerEvent); assertThat(cleanupDelay).isEqualTo(Duration.parse(EXTRACTOR_DEFAULT_VALUE)); }
@Test public void parseErrorExtractCleanUpDelay() { when(listenerEvent.getTableParameters()).thenReturn(Map.of(EXTRACTOR_KEY, "1")); Duration cleanupDelay = cleanupDelayExtractor.extractCleanupDelay(listenerEvent); assertThat(cleanupDelay).isEqualTo(Duration.parse(EXTRACTOR_DEFAULT_VALUE)); }