### Question:
DynamicFiltersCollector { public DynamicFiltersCollector(Runnable notifyTaskStatusChanged) { this.notifyTaskStatusChanged = requireNonNull(notifyTaskStatusChanged, "notifyTaskStatusChanged is null"); } DynamicFiltersCollector(Runnable notifyTaskStatusChanged); void updateDomains(Map<DynamicFilterId, Domain> newDynamicFilterDomains); synchronized long getDynamicFiltersVersion(); synchronized VersionedDynamicFilterDomains acknowledgeAndGetNewDomains(long callersCurrentVersion); static final long INITIAL_DYNAMIC_FILTERS_VERSION; static final VersionedDynamicFilterDomains INITIAL_DYNAMIC_FILTER_DOMAINS; }### Answer:
@Test public void testDynamicFiltersCollector() { DynamicFilterId filter = new DynamicFilterId("filter"); DynamicFiltersCollector collector = new DynamicFiltersCollector(() -> {}); VersionedDynamicFilterDomains domains = collector.acknowledgeAndGetNewDomains(INITIAL_DYNAMIC_FILTERS_VERSION); assertEquals(domains.getVersion(), INITIAL_DYNAMIC_FILTERS_VERSION); assertEquals(domains.getDynamicFilterDomains(), ImmutableMap.of()); Domain initialDomain = multipleValues(BIGINT, ImmutableList.of(1L, 2L, 3L)); collector.updateDomains(ImmutableMap.of(filter, initialDomain)); domains = collector.acknowledgeAndGetNewDomains(INITIAL_DYNAMIC_FILTERS_VERSION); assertEquals(domains.getVersion(), 1L); assertEquals(domains.getDynamicFilterDomains(), ImmutableMap.of(filter, initialDomain)); domains = collector.acknowledgeAndGetNewDomains(INITIAL_DYNAMIC_FILTERS_VERSION); assertEquals(domains.getVersion(), 1L); assertEquals(domains.getDynamicFilterDomains(), ImmutableMap.of(filter, initialDomain)); collector.updateDomains(ImmutableMap.of(filter, multipleValues(BIGINT, ImmutableList.of(2L)))); collector.updateDomains(ImmutableMap.of(filter, multipleValues(BIGINT, ImmutableList.of(3L, 4L)))); domains = collector.acknowledgeAndGetNewDomains(1L); assertEquals(domains.getVersion(), 3L); assertEquals(domains.getDynamicFilterDomains(), ImmutableMap.of(filter, Domain.none(BIGINT))); DynamicFilterId filter2 = new DynamicFilterId("filter2"); collector.updateDomains(ImmutableMap.of(filter2, singleValue(BIGINT, 1L))); domains = collector.acknowledgeAndGetNewDomains(3L); assertEquals(domains.getVersion(), 4L); assertEquals(domains.getDynamicFilterDomains(), ImmutableMap.of(filter2, singleValue(BIGINT, 1L))); }