Search in sources :

Example 21 with AggregateQuery

use of org.molgenis.data.aggregation.AggregateQuery in project molgenis by molgenis.

the class IndexedRepositoryDecoratorTest method aggregateUnknownIndexExceptionRecoverable.

@Test
public void aggregateUnknownIndexExceptionRecoverable() {
    AggregateQuery aggregateQuery = mock(AggregateQuery.class);
    AggregateResult aggregateResult = mock(AggregateResult.class);
    when(searchService.aggregate(repositoryEntityType, aggregateQuery)).thenThrow(new UnknownIndexException("msg")).thenReturn(aggregateResult);
    assertEquals(indexedRepositoryDecorator.aggregate(aggregateQuery), aggregateResult);
    verify(delegateRepository, never()).count(unsupportedQuery);
}
Also used : AggregateResult(org.molgenis.data.aggregation.AggregateResult) UnknownIndexException(org.molgenis.data.index.exception.UnknownIndexException) AggregateQuery(org.molgenis.data.aggregation.AggregateQuery) Test(org.testng.annotations.Test)

Example 22 with AggregateQuery

use of org.molgenis.data.aggregation.AggregateQuery 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);
}
Also used : AggregateResult(org.molgenis.data.aggregation.AggregateResult) AggregateQuery(org.molgenis.data.aggregation.AggregateQuery)

Example 23 with AggregateQuery

use of org.molgenis.data.aggregation.AggregateQuery 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));
}
Also used : AggregateResult(org.molgenis.data.aggregation.AggregateResult) AggregateQuery(org.molgenis.data.aggregation.AggregateQuery) Test(org.testng.annotations.Test)

Aggregations

AggregateQuery (org.molgenis.data.aggregation.AggregateQuery)23 Test (org.testng.annotations.Test)19 AggregateResult (org.molgenis.data.aggregation.AggregateResult)13 WithMockUser (org.springframework.security.test.context.support.WithMockUser)10 AggregateQueryImpl (org.molgenis.data.support.AggregateQueryImpl)8 QueryImpl (org.molgenis.data.support.QueryImpl)4 AbstractMockitoTest (org.molgenis.test.AbstractMockitoTest)3 UnknownIndexException (org.molgenis.data.index.exception.UnknownIndexException)2 Attribute (org.molgenis.data.meta.model.Attribute)2 EntityType (org.molgenis.data.meta.model.EntityType)1 EntityPager (org.molgenis.data.rest.EntityPager)1 AttributeFilterToFetchConverter.createDefaultAttributeFetch (org.molgenis.data.rest.v2.AttributeFilterToFetchConverter.createDefaultAttributeFetch)1 TransactionDefinition (org.springframework.transaction.TransactionDefinition)1 UriComponentsBuilder (org.springframework.web.util.UriComponentsBuilder)1