Search in sources :

Example 1 with TenantQuery

use of org.camunda.bpm.engine.identity.TenantQuery in project camunda-bpm-platform by camunda.

the class TenantRestServiceInteractionTest method setUpMockQuery.

protected TenantQuery setUpMockQuery(Tenant tenant) {
    TenantQuery query = mock(TenantQuery.class);
    when(query.tenantId(anyString())).thenReturn(query);
    when(query.singleResult()).thenReturn(tenant);
    when(identityServiceMock.createTenantQuery()).thenReturn(query);
    return query;
}
Also used : TenantQuery(org.camunda.bpm.engine.identity.TenantQuery)

Example 2 with TenantQuery

use of org.camunda.bpm.engine.identity.TenantQuery in project camunda-bpm-platform by camunda.

the class TenantRestServiceImpl method queryTenants.

public List<TenantDto> queryTenants(UriInfo uriInfo, Integer firstResult, Integer maxResults) {
    TenantQueryDto queryDto = new TenantQueryDto(getObjectMapper(), uriInfo.getQueryParameters());
    TenantQuery query = queryDto.toQuery(getProcessEngine());
    List<Tenant> tenants;
    if (firstResult != null || maxResults != null) {
        tenants = executePaginatedQuery(query, firstResult, maxResults);
    } else {
        tenants = query.list();
    }
    return TenantDto.fromTenantList(tenants);
}
Also used : Tenant(org.camunda.bpm.engine.identity.Tenant) TenantQueryDto(org.camunda.bpm.engine.rest.dto.identity.TenantQueryDto) TenantQuery(org.camunda.bpm.engine.identity.TenantQuery)

Example 3 with TenantQuery

use of org.camunda.bpm.engine.identity.TenantQuery in project camunda-bpm-platform by camunda.

the class TenantRestServiceImpl method getTenantCount.

public CountResultDto getTenantCount(UriInfo uriInfo) {
    TenantQueryDto queryDto = new TenantQueryDto(getObjectMapper(), uriInfo.getQueryParameters());
    TenantQuery query = queryDto.toQuery(getProcessEngine());
    long count = query.count();
    return new CountResultDto(count);
}
Also used : TenantQueryDto(org.camunda.bpm.engine.rest.dto.identity.TenantQueryDto) CountResultDto(org.camunda.bpm.engine.rest.dto.CountResultDto) TenantQuery(org.camunda.bpm.engine.identity.TenantQuery)

Example 4 with TenantQuery

use of org.camunda.bpm.engine.identity.TenantQuery in project camunda-bpm-platform by camunda.

the class AbstractAuthenticationFilterTest method setupTenantQueryMock.

protected List<String> setupTenantQueryMock(List<Tenant> tenants) {
    TenantQuery mockTenantQuery = mock(TenantQuery.class);
    when(identityServiceMock.createTenantQuery()).thenReturn(mockTenantQuery);
    when(mockTenantQuery.userMember(anyString())).thenReturn(mockTenantQuery);
    when(mockTenantQuery.includingGroupsOfUser(anyBoolean())).thenReturn(mockTenantQuery);
    when(mockTenantQuery.list()).thenReturn(tenants);
    List<String> tenantIds = new ArrayList<String>();
    for (Tenant tenant : tenants) {
        tenantIds.add(tenant.getId());
    }
    return tenantIds;
}
Also used : Tenant(org.camunda.bpm.engine.identity.Tenant) TenantQuery(org.camunda.bpm.engine.identity.TenantQuery) ArrayList(java.util.ArrayList) Matchers.anyString(org.mockito.Matchers.anyString)

Example 5 with TenantQuery

use of org.camunda.bpm.engine.identity.TenantQuery in project camunda-bpm-platform by camunda.

the class FetchAndLockRestServiceInteractionTest method setupTenantQueryMock.

private List<String> setupTenantQueryMock(List<Tenant> tenants) {
    TenantQuery mockTenantQuery = mock(TenantQuery.class);
    when(identityServiceMock.createTenantQuery()).thenReturn(mockTenantQuery);
    when(mockTenantQuery.userMember(anyString())).thenReturn(mockTenantQuery);
    when(mockTenantQuery.includingGroupsOfUser(anyBoolean())).thenReturn(mockTenantQuery);
    when(mockTenantQuery.list()).thenReturn(tenants);
    List<String> tenantIds = new ArrayList<String>();
    for (Tenant tenant : tenants) {
        tenantIds.add(tenant.getId());
    }
    return tenantIds;
}
Also used : Tenant(org.camunda.bpm.engine.identity.Tenant) TenantQuery(org.camunda.bpm.engine.identity.TenantQuery) ArrayList(java.util.ArrayList) Matchers.anyString(org.mockito.Matchers.anyString) Matchers.containsString(org.hamcrest.Matchers.containsString)

Aggregations

TenantQuery (org.camunda.bpm.engine.identity.TenantQuery)20 Test (org.junit.Test)13 Tenant (org.camunda.bpm.engine.identity.Tenant)10 ArrayList (java.util.ArrayList)3 Matchers.anyString (org.mockito.Matchers.anyString)3 Group (org.camunda.bpm.engine.identity.Group)2 User (org.camunda.bpm.engine.identity.User)2 TenantQueryDto (org.camunda.bpm.engine.rest.dto.identity.TenantQueryDto)2 CountResultDto (org.camunda.bpm.engine.rest.dto.CountResultDto)1 Matchers.containsString (org.hamcrest.Matchers.containsString)1