@Test void aggregateThreshold() throws Exception { int threshold = 10; when(appSettings.getAggregateThreshold()).thenReturn(threshold); AggregateQuery aggregateQuery = mock(AggregateQuery.class); AggregateResult aggregateResult = mock(AggregateResult.class); when(delegateRepository.aggregate(aggregateQuery)).thenReturn(aggregateResult); AnonymizedAggregateResult anonymizedAggregateResult = mock(AnonymizedAggregateResult.class); when(aggregateAnonymizer.anonymize(aggregateResult, threshold)) .thenReturn(anonymizedAggregateResult); assertEquals( aggregateAnonymizerRepoDecorator.aggregate(aggregateQuery), anonymizedAggregateResult); }
@Override public AggregateResult aggregate(AggregateQuery aggregateQuery) { AggregateResult result = delegate().aggregate(aggregateQuery); Integer threshold = appSettings.getAggregateThreshold(); if (threshold != null && threshold > 0) { result = aggregateAnonymizer.anonymize(result, threshold); } return result; }
AggregateAnonymizerRepositoryDecorator extends AbstractRepositoryDecorator<E> { @Override public AggregateResult aggregate(AggregateQuery aggregateQuery) { AggregateResult result = delegate().aggregate(aggregateQuery); Integer threshold = appSettings.getAggregateThreshold(); if (threshold != null && threshold > 0) { result = aggregateAnonymizer.anonymize(result, threshold); } return result; } }
AggregateAnonymizerRepositoryDecorator extends AbstractRepositoryDecorator<E> { @Override public AggregateResult aggregate(AggregateQuery aggregateQuery) { AggregateResult result = delegate().aggregate(aggregateQuery); Integer threshold = appSettings.getAggregateThreshold(); if (threshold != null && threshold > 0) { result = aggregateAnonymizer.anonymize(result, threshold); } return result; } AggregateAnonymizerRepositoryDecorator(
      Repository<E> delegateRepository,
      AggregateAnonymizer aggregateAnonymizer,
      AppSettings appSettings); }
AggregateAnonymizerRepositoryDecorator extends AbstractRepositoryDecorator<E> { @Override public AggregateResult aggregate(AggregateQuery aggregateQuery) { AggregateResult result = delegate().aggregate(aggregateQuery); Integer threshold = appSettings.getAggregateThreshold(); if (threshold != null && threshold > 0) { result = aggregateAnonymizer.anonymize(result, threshold); } return result; } AggregateAnonymizerRepositoryDecorator(
      Repository<E> delegateRepository,
      AggregateAnonymizer aggregateAnonymizer,
      AppSettings appSettings); @Override AggregateResult aggregate(AggregateQuery aggregateQuery); }
AggregateAnonymizerRepositoryDecorator extends AbstractRepositoryDecorator<E> { @Override public AggregateResult aggregate(AggregateQuery aggregateQuery) { AggregateResult result = delegate().aggregate(aggregateQuery); Integer threshold = appSettings.getAggregateThreshold(); if (threshold != null && threshold > 0) { result = aggregateAnonymizer.anonymize(result, threshold); } return result; } AggregateAnonymizerRepositoryDecorator(
      Repository<E> delegateRepository,
      AggregateAnonymizer aggregateAnonymizer,
      AppSettings appSettings); @Override AggregateResult aggregate(AggregateQuery aggregateQuery);  }