Search in sources :

Example 6 with UserDto

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

the class UserRestServiceInteractionTest method testSaveNewUserThrowsAuthorizationException.

@Test
public void testSaveNewUserThrowsAuthorizationException() {
    User newUser = MockProvider.createMockUser();
    when(identityServiceMock.newUser(MockProvider.EXAMPLE_USER_ID)).thenReturn(newUser);
    String message = "exception expected";
    doThrow(new AuthorizationException(message)).when(identityServiceMock).saveUser(newUser);
    UserDto userDto = UserDto.fromUser(newUser, true);
    given().body(userDto).contentType(ContentType.JSON).then().statusCode(Status.FORBIDDEN.getStatusCode()).contentType(ContentType.JSON).body("type", equalTo(AuthorizationException.class.getSimpleName())).body("message", equalTo(message)).when().post(USER_CREATE_URL);
}
Also used : User(org.camunda.bpm.engine.identity.User) AuthorizationException(org.camunda.bpm.engine.AuthorizationException) UserDto(org.camunda.bpm.engine.rest.dto.identity.UserDto) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Aggregations

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