Search in sources :

Example 41 with UserQuery

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

the class UserRestServiceInteractionTest method testPutCredentialsThrowsAuthorizationException.

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