@Test(dataProvider = "strategies") public void shouldUseSpecifiedCapacityAndFalsePositiveProbability(ConcurrencyStrategy strategy) { // Given Funnel<Integer> funnel = Funnels.integerFunnel(); long capacity = 100; double fpp = 0.01d; // When BloomFilter<Integer> result = strategy.<Integer>getFactory(funnel).create(capacity, fpp); // Then assertThat(result.getStatistics().getCapacity()).as("capacity").isEqualTo(capacity); assertThat(result.getStatistics().getConfiguredFalsePositiveProbability()) .as("falsePositiveProbability") .isEqualTo(fpp); }
@Test public void shouldUseCorrectImplementations() { // Given Funnel<Integer> funnel = Funnels.integerFunnel(); long capacity = 100; double fpp = 0.01d; // When BloomFilter<Integer> cowBf = ConcurrencyStrategy.COPY_ON_WRITE.<Integer>getFactory(funnel).create(capacity, fpp); BloomFilter<Integer> syncBf = ConcurrencyStrategy.SYNCHRONIZED.<Integer>getFactory(funnel).create(capacity, fpp); BloomFilter<Integer> atomicBf = ConcurrencyStrategy.ATOMIC.<Integer>getFactory(funnel).create(capacity, fpp); // Then assertThat(cowBf).isInstanceOf(CopyOnWriteBloomFilter.class); assertThat(syncBf).isInstanceOf(SynchronizedBloomFilter.class); assertThat(atomicBf).isInstanceOf(AtomicBloomFilter.class); }