use of org.molgenis.data.aggregation.AggregateResult in project molgenis by molgenis.
the class EntityTypeRepositorySecurityDecoratorTest method aggregateSuOrSystem.
private void aggregateSuOrSystem() {
AggregateQuery aggregateQuery = mock(AggregateQuery.class);
AggregateResult aggregateResult = mock(AggregateResult.class);
when(delegateRepository.aggregate(aggregateQuery)).thenReturn(aggregateResult);
assertEquals(repo.aggregate(aggregateQuery), aggregateResult);
}
use of org.molgenis.data.aggregation.AggregateResult in project molgenis by molgenis.
the class AggregateAnonymizerRepositoryDecoratorTest method aggregateThreshold.
@Test
public 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(anonymizedAggregateResult, aggregateAnonymizerRepoDecorator.aggregate(aggregateQuery));
}
use of org.molgenis.data.aggregation.AggregateResult in project molgenis by molgenis.
the class EntityAggregatesResponseTest method testAggregateResultResponseToResponseAggregateResult.
// regression test for https://github.com/molgenis/molgenis/issues/6581
@Test
public void testAggregateResultResponseToResponseAggregateResult() {
EntityType entityType = mock(EntityType.class);
Attribute longAttribute = when(mock(Attribute.class).getDataType()).thenReturn(LONG).getMock();
when(longAttribute.getName()).thenReturn("longAttribute");
Iterable<Attribute> attributes = singletonList(longAttribute);
when(entityType.getAtomicAttributes()).thenReturn(attributes);
Entity entity = mock(Entity.class);
when(entity.get("longAttribute")).thenReturn(123L);
when(entity.getEntityType()).thenReturn(entityType);
List<List<Long>> matrix = emptyList();
List<Object> xLabels = Collections.singletonList(entity);
List<Object> yLabels = emptyList();
AggregateResult aggregateResult = mock(AggregateResult.class);
when(aggregateResult.getMatrix()).thenReturn(matrix);
when(aggregateResult.getxLabels()).thenReturn(xLabels);
when(aggregateResult.getyLabels()).thenReturn(yLabels);
AggregateResultResponse aggregateResultResponse = AggregateResultResponse.toResponse(aggregateResult);
assertEquals(aggregateResultResponse.getMatrix(), matrix);
assertEquals(aggregateResultResponse.getxLabels(), singletonList(singletonMap("longAttribute", "123")));
assertEquals(aggregateResultResponse.getyLabels(), emptyList());
}
use of org.molgenis.data.aggregation.AggregateResult in project molgenis by molgenis.
the class AggregateAnonymizerRepositoryDecorator method aggregate.
@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;
}
Aggregations