AuthorizationQuery authorizationQuery = mock(AuthorizationQuery.class);
when(authorizationServiceMock.createAuthorizationQuery()).thenReturn(authorizationQuery);
when(authorizationQuery.authorizationId(MockProvider.EXAMPLE_AUTHORIZATION_ID)).thenReturn(authorizationQuery);
when(authorizationQuery.singleResult()).thenReturn(authorization);
AuthorizationDto dto = AuthorizationDto.fromAuthorization(authorization);
given()
.pathParam("id", MockProvider.EXAMPLE_AUTHORIZATION_ID)
.body(dto).contentType(ContentType.JSON)
.then().expect()
.statusCode(Status.NO_CONTENT.getStatusCode())
.when()
.put(AUTH_RESOURCE_PATH);
verify(authorizationQuery).authorizationId(MockProvider.EXAMPLE_AUTHORIZATION_ID);
verify(authorization).setGroupId(dto.getGroupId());
verify(authorization).setUserId(dto.getUserId());
verify(authorization).setResourceId(dto.getResourceId());
verify(authorization).setResourceType(dto.getResourceType());
verify(authorizationServiceMock).saveAuthorization(authorization);
}