Search in sources :

Example 31 with UserQuery

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

the class UserQueryTest method testQueryByFirstName.

public void testQueryByFirstName() {
    UserQuery query = identityService.createUserQuery().userFirstName("Gonzo");
    verifyQueryResults(query, 1);
    User result = query.singleResult();
    assertEquals("gonzo", result.getId());
}
Also used : User(org.camunda.bpm.engine.identity.User) UserQuery(org.camunda.bpm.engine.identity.UserQuery)

Example 32 with UserQuery

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

the class UserQueryTest method testQueryByMemberOfTenant.

public void testQueryByMemberOfTenant() {
    UserQuery query = identityService.createUserQuery().memberOfTenant("nonExisting");
    verifyQueryResults(query, 0);
    query = identityService.createUserQuery().memberOfTenant("tenant");
    verifyQueryResults(query, 1);
    User result = query.singleResult();
    assertEquals("kermit", result.getId());
}
Also used : User(org.camunda.bpm.engine.identity.User) UserQuery(org.camunda.bpm.engine.identity.UserQuery)

Example 33 with UserQuery

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

the class UserQueryTest method testQueryByNoCriteria.

public void testQueryByNoCriteria() {
    UserQuery query = identityService.createUserQuery();
    verifyQueryResults(query, 3);
}
Also used : UserQuery(org.camunda.bpm.engine.identity.UserQuery)

Example 34 with UserQuery

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

the class IdentityServiceTenantTest method deleteTenantMembershipsOfTenant.

@Test
public void deleteTenantMembershipsOfTenant() {
    Tenant tenant = identityService.newTenant(TENANT_ONE);
    identityService.saveTenant(tenant);
    User user = identityService.newUser(USER_ONE);
    identityService.saveUser(user);
    Group group = identityService.newGroup(GROUP_ONE);
    identityService.saveGroup(group);
    identityService.createTenantUserMembership(TENANT_ONE, USER_ONE);
    identityService.createTenantGroupMembership(TENANT_ONE, GROUP_ONE);
    UserQuery userQuery = identityService.createUserQuery().memberOfTenant(TENANT_ONE);
    GroupQuery groupQuery = identityService.createGroupQuery().memberOfTenant(TENANT_ONE);
    assertThat(userQuery.count(), is(1L));
    assertThat(groupQuery.count(), is(1L));
    identityService.deleteTenant(TENANT_ONE);
    assertThat(userQuery.count(), is(0L));
    assertThat(groupQuery.count(), is(0L));
}
Also used : Group(org.camunda.bpm.engine.identity.Group) Tenant(org.camunda.bpm.engine.identity.Tenant) User(org.camunda.bpm.engine.identity.User) UserQuery(org.camunda.bpm.engine.identity.UserQuery) GroupQuery(org.camunda.bpm.engine.identity.GroupQuery) Test(org.junit.Test)

Example 35 with UserQuery

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

the class UserRestServiceInteractionTest method testUserResourceOptionsUnauthenticated.

@Test
public void testUserResourceOptionsUnauthenticated() {
    String fullUserUrl = "http://localhost:" + PORT + TEST_RESOURCE_ROOT_PATH + "/user/" + MockProvider.EXAMPLE_USER_ID;
    User sampleUser = MockProvider.createMockUser();
    UserQuery sampleUserQuery = mock(UserQuery.class);
    when(identityServiceMock.createUserQuery()).thenReturn(sampleUserQuery);
    when(sampleUserQuery.userId(MockProvider.EXAMPLE_USER_ID)).thenReturn(sampleUserQuery);
    when(sampleUserQuery.singleResult()).thenReturn(sampleUser);
    when(identityServiceMock.getCurrentAuthentication()).thenReturn(null);
    when(processEngineConfigurationMock.isAuthorizationEnabled()).thenReturn(true);
    given().pathParam("id", MockProvider.EXAMPLE_USER_ID).then().statusCode(Status.OK.getStatusCode()).body("links[0].href", equalTo(fullUserUrl + "/profile")).body("links[0].method", equalTo(HttpMethod.GET)).body("links[0].rel", equalTo("self")).body("links[1].href", equalTo(fullUserUrl)).body("links[1].method", equalTo(HttpMethod.DELETE)).body("links[1].rel", equalTo("delete")).body("links[2].href", equalTo(fullUserUrl + "/profile")).body("links[2].method", equalTo(HttpMethod.PUT)).body("links[2].rel", equalTo("update")).when().options(USER_URL);
    verify(identityServiceMock, times(2)).getCurrentAuthentication();
}
Also used : User(org.camunda.bpm.engine.identity.User) UserQuery(org.camunda.bpm.engine.identity.UserQuery) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Aggregations

UserQuery (org.camunda.bpm.engine.identity.UserQuery)41 User (org.camunda.bpm.engine.identity.User)24 Test (org.junit.Test)17 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)8 Matchers.anyString (org.mockito.Matchers.anyString)8 UserCredentialsDto (org.camunda.bpm.engine.rest.dto.identity.UserCredentialsDto)5 Group (org.camunda.bpm.engine.identity.Group)4 GroupQuery (org.camunda.bpm.engine.identity.GroupQuery)4 Authentication (org.camunda.bpm.engine.impl.identity.Authentication)4 HashMap (java.util.HashMap)3 UserProfileDto (org.camunda.bpm.engine.rest.dto.identity.UserProfileDto)3 InvalidRequestException (org.camunda.bpm.engine.rest.exception.InvalidRequestException)3 Response (com.jayway.restassured.response.Response)2 ArrayList (java.util.ArrayList)2 Map (java.util.Map)2 AuthorizationException (org.camunda.bpm.engine.AuthorizationException)2 CaseDefinition (org.camunda.bpm.engine.repository.CaseDefinition)2 CaseDefinitionQuery (org.camunda.bpm.engine.repository.CaseDefinitionQuery)2 ProcessDefinition (org.camunda.bpm.engine.repository.ProcessDefinition)2 ProcessDefinitionQuery (org.camunda.bpm.engine.repository.ProcessDefinitionQuery)2