Search in sources :

Example 6 with AggregateQuery

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

the class RepositorySecurityDecoratorTest method testAggregatePermissionGranted.

@Test
public void testAggregatePermissionGranted() {
    initPermissionServiceMock(EntityTypePermission.COUNT, true);
    AggregateQuery aggregateQuery = mock(AggregateQuery.class);
    repositorySecurityDecorator.aggregate(aggregateQuery);
    verify(delegateRepository).aggregate(aggregateQuery);
}
Also used : AggregateQuery(org.molgenis.data.aggregation.AggregateQuery) Test(org.testng.annotations.Test) AbstractMockitoTest(org.molgenis.test.AbstractMockitoTest)

Example 7 with AggregateQuery

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

the class RepositorySecurityDecoratorTest method testAggregatePermissionDenied.

@Test(expectedExceptions = MolgenisDataAccessException.class, expectedExceptionsMessageRegExp = MESSAGE_NO_COUNT_PERMISSION)
public void testAggregatePermissionDenied() {
    initPermissionServiceMock(EntityTypePermission.COUNT, false);
    AggregateQuery aggregateQuery = mock(AggregateQuery.class);
    repositorySecurityDecorator.aggregate(aggregateQuery);
    verify(delegateRepository).aggregate(aggregateQuery);
}
Also used : AggregateQuery(org.molgenis.data.aggregation.AggregateQuery) Test(org.testng.annotations.Test) AbstractMockitoTest(org.molgenis.test.AbstractMockitoTest)

Example 8 with AggregateQuery

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

the class AttributeRepositorySecurityDecoratorTest 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 9 with AggregateQuery

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

the class AttributeRepositorySecurityDecoratorTest method aggregateUser.

@WithMockUser(username = USERNAME)
@Test(expectedExceptions = MolgenisDataAccessException.class)
public void aggregateUser() {
    AggregateQuery aggregateQuery = mock(AggregateQuery.class);
    repo.aggregate(aggregateQuery);
}
Also used : AggregateQuery(org.molgenis.data.aggregation.AggregateQuery) WithMockUser(org.springframework.security.test.context.support.WithMockUser) Test(org.testng.annotations.Test)

Example 10 with AggregateQuery

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

the class AggregateAnonymizerRepositoryDecoratorTest method aggregateNoThreshold.

@Test
public void aggregateNoThreshold() throws Exception {
    when(appSettings.getAggregateThreshold()).thenReturn(null);
    AggregateQuery aggregateQuery = mock(AggregateQuery.class);
    AggregateResult aggregateResult = mock(AggregateResult.class);
    when(delegateRepository.aggregate(aggregateQuery)).thenReturn(aggregateResult);
    assertEquals(aggregateResult, aggregateAnonymizerRepoDecorator.aggregate(aggregateQuery));
    verifyZeroInteractions(aggregateAnonymizer);
    verifyZeroInteractions(aggregateResult);
}
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