use of org.camunda.bpm.engine.rest.dto.identity.UserCredentialsDto 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);
}
Aggregations