org.camunda.bpm.engine.identity.UserQuery Java Examples

The following examples show how to use org.camunda.bpm.engine.identity.UserQuery. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: IdentityServiceTenantTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@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));
}
 
Example #2
Source File: ProcessEngineRestServiceTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
private void createIdentityMocks() {
  // identity
  UserQuery sampleUserQuery = mock(UserQuery.class);
  GroupQuery sampleGroupQuery = mock(GroupQuery.class);
  List<User> mockUsers = new ArrayList<User>();
  User mockUser = MockProvider.createMockUser();
  mockUsers.add(mockUser);

  // user query
  when(sampleUserQuery.memberOfGroup(anyString())).thenReturn(sampleUserQuery);
  when(sampleUserQuery.list()).thenReturn(mockUsers);

  // group query
  List<Group> mockGroups = MockProvider.createMockGroups();
  when(sampleGroupQuery.groupMember(anyString())).thenReturn(sampleGroupQuery);
  when(sampleGroupQuery.orderByGroupName()).thenReturn(sampleGroupQuery);
  when(sampleGroupQuery.asc()).thenReturn(sampleGroupQuery);
  when(sampleGroupQuery.unlimitedList()).thenReturn(mockGroups);

  when(mockIdentityService.createGroupQuery()).thenReturn(sampleGroupQuery);
  when(mockIdentityService.createUserQuery()).thenReturn(sampleUserQuery);
}
 
Example #3
Source File: IdentityRestServiceQueryTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
private void createMockIdentityQueries() {
  UserQuery sampleUserQuery = mock(UserQuery.class);

  List<User> mockUsers = new ArrayList<User>();

  mockUser = MockProvider.createMockUser();
  mockUsers.add(mockUser);

  when(sampleUserQuery.unlimitedList()).thenReturn(mockUsers);
  when(sampleUserQuery.memberOfGroup(anyString())).thenReturn(sampleUserQuery);
  when(sampleUserQuery.count()).thenReturn((long) mockUsers.size());

  GroupQuery sampleGroupQuery = mock(GroupQuery.class);

  List<Group> mockGroups = MockProvider.createMockGroups();
  when(sampleGroupQuery.unlimitedList()).thenReturn(mockGroups);
  when(sampleGroupQuery.groupMember(anyString())).thenReturn(sampleGroupQuery);
  when(sampleGroupQuery.orderByGroupName()).thenReturn(sampleGroupQuery);
  when(sampleGroupQuery.orderByGroupId()).thenReturn(sampleGroupQuery);
  when(sampleGroupQuery.orderByGroupType()).thenReturn(sampleGroupQuery);
  when(sampleGroupQuery.asc()).thenReturn(sampleGroupQuery);
  when(sampleGroupQuery.desc()).thenReturn(sampleGroupQuery);

  when(processEngine.getIdentityService().createGroupQuery()).thenReturn(sampleGroupQuery);
  when(processEngine.getIdentityService().createUserQuery()).thenReturn(sampleUserQuery);
}
 
Example #4
Source File: UserRestServiceInteractionTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
public void testGetSingleUserProfile() {
  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);

  given()
      .pathParam("id", MockProvider.EXAMPLE_USER_ID)
  .then()
      .statusCode(Status.OK.getStatusCode())
      .body("id", equalTo(MockProvider.EXAMPLE_USER_ID))
      .body("firstName", equalTo(MockProvider.EXAMPLE_USER_FIRST_NAME))
      .body("lastName", equalTo(MockProvider.EXAMPLE_USER_LAST_NAME))
      .body("email", equalTo(MockProvider.EXAMPLE_USER_EMAIL))
  .when()
      .get(USER_PROFILE_URL);
}
 
Example #5
Source File: UserRestServiceInteractionTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
public void testPutProfileNonexistingFails() {
  String exceptionMessage = "User with id aNonExistingUser does not exist";
  User userUpdate = MockProvider.createMockUserUpdate();

  UserQuery sampleUserQuery = mock(UserQuery.class);
  when(identityServiceMock.createUserQuery()).thenReturn(sampleUserQuery);
  when(sampleUserQuery.userId("aNonExistingUser")).thenReturn(sampleUserQuery);
  when(sampleUserQuery.singleResult()).thenReturn(null);

  UserProfileDto updateDto = UserProfileDto.fromUser(userUpdate);

  given()
      .pathParam("id", "aNonExistingUser")
      .body(updateDto).contentType(ContentType.JSON)
  .then()
      .then().expect().statusCode(Status.NOT_FOUND.getStatusCode()).contentType(ContentType.JSON)
      .body("type", equalTo(InvalidRequestException.class.getSimpleName()))
      .body("message", equalTo(exceptionMessage))
  .when()
      .put(USER_PROFILE_URL);

  // nothing was saved
  verify(identityServiceMock, never()).saveUser(any(User.class));
  verifyLogs(Level.DEBUG, exceptionMessage);
}
 
Example #6
Source File: UserRestServiceInteractionTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
public void testPutCredentialsNonExistingUserFails() {
  String exceptionMessage = "User with id aNonExistingUser does not exist";
  UserQuery sampleUserQuery = mock(UserQuery.class);
  when(identityServiceMock.createUserQuery()).thenReturn(sampleUserQuery);
  when(sampleUserQuery.userId("aNonExistingUser")).thenReturn(sampleUserQuery);
  when(sampleUserQuery.singleResult()).thenReturn(null);

  UserCredentialsDto dto = new UserCredentialsDto();
  dto.setPassword("new-password");

  given()
      .pathParam("id", "aNonExistingUser")
      .body(dto).contentType(ContentType.JSON)
  .then()
      .then().expect().statusCode(Status.NOT_FOUND.getStatusCode()).contentType(ContentType.JSON)
      .body("type", equalTo(InvalidRequestException.class.getSimpleName()))
      .body("message", equalTo(exceptionMessage))
  .when()
      .put(USER_CREDENTIALS_URL);

  // user was not updated
  verify(identityServiceMock, never()).saveUser(any(User.class));
  verifyLogs(Level.DEBUG, exceptionMessage);
}
 
Example #7
Source File: UserQueryTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
public void testQuerySorting() {
  // asc
  assertEquals(3, identityService.createUserQuery().orderByUserId().asc().count());
  assertEquals(3, identityService.createUserQuery().orderByUserEmail().asc().count());
  assertEquals(3, identityService.createUserQuery().orderByUserFirstName().asc().count());
  assertEquals(3, identityService.createUserQuery().orderByUserLastName().asc().count());

  // desc
  assertEquals(3, identityService.createUserQuery().orderByUserId().desc().count());
  assertEquals(3, identityService.createUserQuery().orderByUserEmail().desc().count());
  assertEquals(3, identityService.createUserQuery().orderByUserFirstName().desc().count());
  assertEquals(3, identityService.createUserQuery().orderByUserLastName().desc().count());

  // Combined with criteria
  UserQuery query = identityService.createUserQuery().userLastNameLike("%ea%").orderByUserFirstName().asc();
  List<User> users = query.list();
  assertEquals(2,users.size());
  assertEquals("Fozzie", users.get(0).getFirstName());
  assertEquals("Gonzo", users.get(1).getFirstName());
}
 
Example #8
Source File: UserRestServiceInteractionTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
public void testPutCredentials() {
  User initialUser = 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(initialUser);

  UserCredentialsDto dto = new UserCredentialsDto();
  dto.setPassword("new-password");

  given()
      .pathParam("id", MockProvider.EXAMPLE_USER_ID)
      .body(dto).contentType(ContentType.JSON)
  .then()
      .statusCode(Status.NO_CONTENT.getStatusCode())
  .when()
      .put(USER_CREDENTIALS_URL);

  // password was updated
  verify(initialUser).setPassword(dto.getPassword());

  // and then saved
  verify(identityServiceMock).saveUser(initialUser);
}
 
Example #9
Source File: UserRestServiceInteractionTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
public void testGetNonExistingUserProfile() {
  String exceptionMessage = "User with id aNonExistingUser does not exist";
  UserQuery sampleUserQuery = mock(UserQuery.class);
  when(identityServiceMock.createUserQuery()).thenReturn(sampleUserQuery);
  when(sampleUserQuery.userId(anyString())).thenReturn(sampleUserQuery);
  when(sampleUserQuery.singleResult()).thenReturn(null);

  given()
      .pathParam("id", "aNonExistingUser")
  .then()
      .statusCode(Status.NOT_FOUND.getStatusCode()).contentType(ContentType.JSON)
      .body("type", equalTo(InvalidRequestException.class.getSimpleName()))
      .body("message", equalTo(exceptionMessage))
  .when()
      .get(USER_PROFILE_URL);

  verifyLogs(Level.DEBUG, exceptionMessage);
}
 
Example #10
Source File: UserRestServiceInteractionTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Test
public void testPutProfileThrowsAuthorizationException() {
  User initialUser = MockProvider.createMockUser();
  User userUpdate = MockProvider.createMockUserUpdate();

  UserQuery sampleUserQuery = mock(UserQuery.class);
  when(identityServiceMock.createUserQuery()).thenReturn(sampleUserQuery);
  when(sampleUserQuery.userId(MockProvider.EXAMPLE_USER_ID)).thenReturn(sampleUserQuery);
  when(sampleUserQuery.singleResult()).thenReturn(initialUser);

  String message = "exception expected";
  doThrow(new AuthorizationException(message)).when(identityServiceMock).saveUser(any(User.class));

  UserProfileDto updateDto = UserProfileDto.fromUser(userUpdate);

  given()
      .pathParam("id", MockProvider.EXAMPLE_USER_ID)
      .body(updateDto).contentType(ContentType.JSON)
  .then()
      .statusCode(Status.FORBIDDEN.getStatusCode())
      .contentType(ContentType.JSON)
      .body("type", equalTo(AuthorizationException.class.getSimpleName()))
      .body("message", equalTo(message))
  .when()
      .put(USER_PROFILE_URL);

  verifyLogs(Level.DEBUG, message);
}
 
Example #11
Source File: UserQueryDto.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Override
protected void applyFilters(UserQuery query) {
  if (id != null) {
    query.userId(id);
  }
  if(idIn != null) {
    query.userIdIn(idIn);
  }
  if (firstName != null) {
    query.userFirstName(firstName);
  }
  if (firstNameLike != null) {
    query.userFirstNameLike(firstNameLike);
  }
  if (lastName != null) {
    query.userLastName(lastName);
  }
  if (lastNameLike != null) {
    query.userLastNameLike(lastNameLike);
  }
  if (email != null) {
    query.userEmail(email);
  }
  if (emailLike != null) {
    query.userEmailLike(emailLike);
  }
  if (memberOfGroup != null) {
    query.memberOfGroup(memberOfGroup);
  }
  if (potentialStarter != null) {
    query.potentialStarter(potentialStarter);
  }
  if (tenantId != null) {
    query.memberOfTenant(tenantId);
  }
}
 
Example #12
Source File: UserRestServiceInteractionTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Test
public void testPutCredentialsThrowsAuthorizationException() {
  User initialUser = 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(initialUser);

  String message = "exception expected";
  doThrow(new AuthorizationException(message)).when(identityServiceMock).saveUser(any(User.class));

  UserCredentialsDto dto = new UserCredentialsDto();
  dto.setPassword("new-password");

  given()
      .pathParam("id", MockProvider.EXAMPLE_USER_ID)
      .body(dto).contentType(ContentType.JSON)
  .then()
    .statusCode(Status.FORBIDDEN.getStatusCode())
    .contentType(ContentType.JSON)
    .body("type", equalTo(AuthorizationException.class.getSimpleName()))
    .body("message", equalTo(message))
  .when()
      .put(USER_CREDENTIALS_URL);

  verifyLogs(Level.DEBUG, message);
}
 
Example #13
Source File: DemoUserConfigurationTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Test
public void shouldFindDemoUser() {
  // given
  UserQuery userQuery = identityService.createUserQuery();

  // when
  long userCount = userQuery.count();
  List<User> userList = userQuery.list();

  // then
  assertThat(userCount).isEqualTo(1);
  String userId = userList.get(0).getId();
  assertThat(userId).isEqualTo("demo");
  assertThat(identityService.checkPassword(userId, "demo")).isTrue();
}
 
Example #14
Source File: UserRestServiceQueryTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
private UserQuery setUpMockUserQuery(List<User> list) {
  UserQuery sampleUserQuery = mock(UserQuery.class);
  when(sampleUserQuery.list()).thenReturn(list);
  when(sampleUserQuery.count()).thenReturn((long) list.size());

  when(processEngine.getIdentityService().createUserQuery()).thenReturn(sampleUserQuery);

  return sampleUserQuery;
}
 
Example #15
Source File: UserQueryTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public void testQueryByInvalidMemberOfGoup() {
  UserQuery query = identityService.createUserQuery().memberOfGroup("invalid");
  verifyQueryResults(query, 0);

  try {
    identityService.createUserQuery().memberOfGroup(null).list();
    fail();
  } catch (ProcessEngineException e) { }
}
 
Example #16
Source File: UserRestServiceInteractionTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Test
public void testPutProfile() {
  User initialUser = MockProvider.createMockUser();
  User userUpdate = MockProvider.createMockUserUpdate();

  UserQuery sampleUserQuery = mock(UserQuery.class);
  when(identityServiceMock.createUserQuery()).thenReturn(sampleUserQuery);
  when(sampleUserQuery.userId(MockProvider.EXAMPLE_USER_ID)).thenReturn(sampleUserQuery);
  when(sampleUserQuery.singleResult()).thenReturn(initialUser);

  UserProfileDto updateDto = UserProfileDto.fromUser(userUpdate);

  given()
      .pathParam("id", MockProvider.EXAMPLE_USER_ID)
      .body(updateDto).contentType(ContentType.JSON)
  .then()
      .statusCode(Status.NO_CONTENT.getStatusCode())
  .when()
      .put(USER_PROFILE_URL);

  // password was updated
  verify(initialUser).setEmail(updateDto.getEmail());
  verify(initialUser).setFirstName(updateDto.getFirstName());
  verify(initialUser).setLastName(updateDto.getLastName());

  // and then saved
  verify(identityServiceMock).saveUser(initialUser);
}
 
Example #17
Source File: UserRestServiceInteractionTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Test
public void testChangeCredentialsWithWrongAuthenticatedUserPassword() {
  String exceptionMessage = "The given authenticated user password is not valid.";
  User initialUser = 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(initialUser);

  Authentication authentication = MockProvider.createMockAuthentication();
  when(identityServiceMock.getCurrentAuthentication()).thenReturn(authentication);

  when(identityServiceMock.checkPassword(MockProvider.EXAMPLE_USER_ID, MockProvider.EXAMPLE_USER_PASSWORD)).thenReturn(false);

  UserCredentialsDto dto = new UserCredentialsDto();
  dto.setPassword("new-password");
  dto.setAuthenticatedUserPassword(MockProvider.EXAMPLE_USER_PASSWORD);

  given()
      .pathParam("id", MockProvider.EXAMPLE_USER_ID)
      .contentType(ContentType.JSON)
      .body(dto)
  .then()
      .statusCode(Status.BAD_REQUEST.getStatusCode())
      .contentType(ContentType.JSON)
      .body("type", equalTo("InvalidRequestException"))
      .body("message", equalTo(exceptionMessage))
  .when()
      .put(USER_CREDENTIALS_URL);

  verifyLogs(Level.DEBUG, exceptionMessage);
}
 
Example #18
Source File: UserRestServiceInteractionTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Test
public void testChangeCredentials() {
  User initialUser = 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(initialUser);

  Authentication authentication = MockProvider.createMockAuthentication();
  when(identityServiceMock.getCurrentAuthentication()).thenReturn(authentication);

  when(identityServiceMock.checkPassword(MockProvider.EXAMPLE_USER_ID, MockProvider.EXAMPLE_USER_PASSWORD)).thenReturn(true);

  UserCredentialsDto dto = new UserCredentialsDto();
  dto.setPassword("new-password");
  dto.setAuthenticatedUserPassword(MockProvider.EXAMPLE_USER_PASSWORD);

  given()
      .pathParam("id", MockProvider.EXAMPLE_USER_ID)
      .contentType(ContentType.JSON)
      .body(dto)
  .then()
      .statusCode(Status.NO_CONTENT.getStatusCode())
  .when()
      .put(USER_CREDENTIALS_URL);

  verify(identityServiceMock).getCurrentAuthentication();
  verify(identityServiceMock).checkPassword(MockProvider.EXAMPLE_USER_ID, MockProvider.EXAMPLE_USER_PASSWORD);

  // password was updated
  verify(initialUser).setPassword(dto.getPassword());

  // and then saved
  verify(identityServiceMock).saveUser(initialUser);
}
 
Example #19
Source File: UserRestServiceInteractionTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@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();

}
 
Example #20
Source File: UserRestServiceImpl.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public List<UserProfileDto> queryUsers(UserQueryDto queryDto, Integer firstResult, Integer maxResults) {

    queryDto.setObjectMapper(getObjectMapper());
    UserQuery query = queryDto.toQuery(getProcessEngine());

    List<User> resultList;
    if(firstResult != null || maxResults != null) {
      resultList = executePaginatedQuery(query, firstResult, maxResults);
    } else {
      resultList = query.list();
    }

    return UserProfileDto.fromUserList(resultList);
  }
 
Example #21
Source File: UserQueryTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
private void verifyQueryResults(UserQuery query, int countExpected) {
  assertEquals(countExpected, query.list().size());
  assertEquals(countExpected, query.count());

  if (countExpected == 1) {
    assertNotNull(query.singleResult());
  } else if (countExpected > 1){
    verifySingleResultFails(query);
  } else if (countExpected == 0) {
    assertNull(query.singleResult());
  }
}
 
Example #22
Source File: UserQueryTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
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());
}
 
Example #23
Source File: UserQueryTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public void testQueryByLastName() {
  UserQuery query = identityService.createUserQuery().userLastName("Bear");
  verifyQueryResults(query, 1);

  User result = query.singleResult();
  assertEquals("fozzie", result.getId());
}
 
Example #24
Source File: UserQueryTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public void testQueryByMemberOfGroup() {
  UserQuery query = identityService.createUserQuery().memberOfGroup("muppets");
  verifyQueryResults(query, 3);

  query = identityService.createUserQuery().memberOfGroup("frogs");
  verifyQueryResults(query, 1);

  User result = query.singleResult();
  assertEquals("kermit", result.getId());
}
 
Example #25
Source File: UserQueryTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public void testQueryByInvalidEmailLike() {
  UserQuery query = identityService.createUserQuery().userEmailLike("%invalid%");
  verifyQueryResults(query, 0);

  try {
    identityService.createUserQuery().userEmailLike(null).singleResult();
    fail();
  } catch (ProcessEngineException e) { }
}
 
Example #26
Source File: UserQueryTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public void testQueryByEmailLike() {
  UserQuery query = identityService.createUserQuery().userEmailLike("%muppetshow.com");
  verifyQueryResults(query, 3);

  query = identityService.createUserQuery().userEmailLike("%kermit\\_%");
  verifyQueryResults(query, 1);
}
 
Example #27
Source File: UserQueryTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public void testQueryByInvalidEmail() {
  UserQuery query = identityService.createUserQuery().userEmail("invalid");
  verifyQueryResults(query, 0);

  try {
    identityService.createUserQuery().userEmail(null).singleResult();
    fail();
  } catch (ProcessEngineException e) { }
}
 
Example #28
Source File: UserQueryTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public void testQueryByInvalidLastNameLike() {
  UserQuery query = identityService.createUserQuery().userLastNameLike("%invalid%");
  verifyQueryResults(query, 0);

  try {
    identityService.createUserQuery().userLastNameLike(null).singleResult();
    fail();
  } catch (ProcessEngineException e) { }
}
 
Example #29
Source File: UserQueryTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public void testQueryByInvalidLastName() {
  UserQuery query = identityService.createUserQuery().userLastName("invalid");
  verifyQueryResults(query, 0);

  try {
    identityService.createUserQuery().userLastName(null).singleResult();
    fail();
  } catch (ProcessEngineException e) { }
}
 
Example #30
Source File: UserQueryTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public void testQueryByLastNameLike() {
  UserQuery query = identityService.createUserQuery().userLastNameLike("%\\_frog%");
  verifyQueryResults(query, 1);

  query = identityService.createUserQuery().userLastNameLike("%ea%");
  verifyQueryResults(query, 2);
}