Search in sources :

Example 6 with UserProfileDto

use of org.camunda.bpm.engine.rest.dto.identity.UserProfileDto in project camunda-bpm-platform by camunda.

the class UserRestServiceInteractionTest method testPutProfile.

@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);
}
Also used : User(org.camunda.bpm.engine.identity.User) UserQuery(org.camunda.bpm.engine.identity.UserQuery) UserProfileDto(org.camunda.bpm.engine.rest.dto.identity.UserProfileDto) Test(org.junit.Test)

Aggregations

UserProfileDto (org.camunda.bpm.engine.rest.dto.identity.UserProfileDto)6 User (org.camunda.bpm.engine.identity.User)5 UserQuery (org.camunda.bpm.engine.identity.UserQuery)3 InvalidRequestException (org.camunda.bpm.engine.rest.exception.InvalidRequestException)3 Test (org.junit.Test)3 ClientResponse (com.sun.jersey.api.client.ClientResponse)1 WebResource (com.sun.jersey.api.client.WebResource)1 WebApplicationException (javax.ws.rs.WebApplicationException)1 AuthorizationException (org.camunda.bpm.engine.AuthorizationException)1 IdentityService (org.camunda.bpm.engine.IdentityService)1 UserCredentialsDto (org.camunda.bpm.engine.rest.dto.identity.UserCredentialsDto)1 UserDto (org.camunda.bpm.engine.rest.dto.identity.UserDto)1 Matchers.anyString (org.mockito.Matchers.anyString)1