use of org.camunda.bpm.engine.identity.UserQuery in project camunda-bpm-platform by camunda.
the class UserRestServiceInteractionTest method testChangeCredentials.
@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);
}
use of org.camunda.bpm.engine.identity.UserQuery in project camunda-bpm-platform by camunda.
the class UserRestServiceInteractionTest method testGetSingleUserProfile.
@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);
}
use of org.camunda.bpm.engine.identity.UserQuery in project camunda-bpm-platform by camunda.
the class ProcessEngineRestServiceTest method createIdentityMocks.
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.list()).thenReturn(mockGroups);
when(mockIdentityService.createGroupQuery()).thenReturn(sampleGroupQuery);
when(mockIdentityService.createUserQuery()).thenReturn(sampleUserQuery);
}
use of org.camunda.bpm.engine.identity.UserQuery in project camunda-bpm-platform by camunda.
the class UserRestServiceImpl method getUserCount.
protected CountResultDto getUserCount(UserQueryDto queryDto) {
UserQuery query = queryDto.toQuery(getProcessEngine());
long count = query.count();
return new CountResultDto(count);
}
use of org.camunda.bpm.engine.identity.UserQuery in project camunda-bpm-platform by camunda.
the class IdentityRestServiceQueryTest method createMockIdentityQueries.
private void createMockIdentityQueries() {
UserQuery sampleUserQuery = mock(UserQuery.class);
List<User> mockUsers = new ArrayList<User>();
mockUser = MockProvider.createMockUser();
mockUsers.add(mockUser);
when(sampleUserQuery.list()).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.list()).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);
}
Aggregations