/**
* Test updating a single user.
*/
public void testUpdateUser() throws Exception {
User savedUser = null;
try {
User newUser = identityService.newUser("testuser");
newUser.setFirstName("Fred");
newUser.setLastName("McDonald");
newUser.setEmail("no-reply@activiti.org");
identityService.saveUser(newUser);
savedUser = newUser;
ObjectNode taskUpdateRequest = objectMapper.createObjectNode();
taskUpdateRequest.put("firstName", "Tijs");
taskUpdateRequest.put("lastName", "Barrez");
taskUpdateRequest.put("email", "no-reply@alfresco.org");
taskUpdateRequest.put("password", "updatedpassword");
HttpPut httpPut = new HttpPut(SERVER_URL_PREFIX +
RestUrls.createRelativeResourceUrl(RestUrls.URL_USER, newUser.getId()));
httpPut.setEntity(new StringEntity(taskUpdateRequest.toString()));
CloseableHttpResponse response = executeRequest(httpPut, HttpStatus.SC_OK);
JsonNode responseNode = objectMapper.readTree(response.getEntity().getContent());
closeResponse(response);
assertNotNull(responseNode);
assertEquals("testuser", responseNode.get("id").textValue());
assertEquals("Tijs", responseNode.get("firstName").textValue());
assertEquals("Barrez", responseNode.get("lastName").textValue());
assertEquals("no-reply@alfresco.org", responseNode.get("email").textValue());
assertTrue(responseNode.get("url").textValue().endsWith(RestUrls.createRelativeResourceUrl(RestUrls.URL_USER, newUser.getId())));
// Check user is updated in activiti
newUser = identityService.createUserQuery().userId(newUser.getId()).singleResult();
assertEquals("Barrez", newUser.getLastName());
assertEquals("Tijs", newUser.getFirstName());
assertEquals("no-reply@alfresco.org", newUser.getEmail());
assertEquals("updatedpassword", newUser.getPassword());
} finally {
// Delete user after test fails
if(savedUser != null) {