Java Code Examples for org.activiti.engine.identity.User#setFirstName()

The following examples show how to use org.activiti.engine.identity.User#setFirstName() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: UserInfoResourceTest.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
/**
 * Test getting the info for a user who doesn't have that info set
 */
public void testGetInfoForUserWithoutInfo() throws Exception {
  User savedUser = null;
  try {
    User newUser = identityService.newUser("testuser");
    newUser.setFirstName("Fred");
    newUser.setLastName("McDonald");
    newUser.setEmail("[email protected]");
    identityService.saveUser(newUser);
    savedUser = newUser;

    closeResponse(executeRequest(new HttpGet(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_USER_INFO, "testuser", "key1")), HttpStatus.SC_NOT_FOUND));

  } finally {

    // Delete user after test passes or fails
    if (savedUser != null) {
      identityService.deleteUser(savedUser.getId());
    }
  }
}
 
Example 2
Source File: UserPictureResourceTest.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
/**
 * Test getting the picture for a user who doesn't have a îcture set
 */
public void testGetPictureForUserWithoutPicture() throws Exception {
  User savedUser = null;
  try {
    User newUser = identityService.newUser("testuser");
    newUser.setFirstName("Fred");
    newUser.setLastName("McDonald");
    newUser.setEmail("[email protected]");
    identityService.saveUser(newUser);
    savedUser = newUser;

    CloseableHttpResponse response = executeRequest(new HttpGet(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_USER_PICTURE, newUser.getId())), HttpStatus.SC_NOT_FOUND);

    // response content type application/json;charset=UTF-8
    assertEquals("application/json", response.getEntity().getContentType().getValue().split(";")[0]);
    closeResponse(response);

  } finally {

    // Delete user after test passes or fails
    if (savedUser != null) {
      identityService.deleteUser(savedUser.getId());
    }
  }
}
 
Example 3
Source File: IdmProfileResource.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
@RequestMapping(value = "/profile", method = RequestMethod.POST, produces = "application/json")
public UserRepresentation updateProfile(@RequestBody UserRepresentation userRepresentation) {
  User currentUser = SecurityUtils.getCurrentUserObject();

  // If user is not externally managed, we need the email address for login, so an empty email is not allowed
  if (StringUtils.isEmpty(userRepresentation.getEmail())) {
    throw new BadRequestException("Empty email is not allowed");
  }
  
  User user = identityService.createUserQuery().userId(currentUser.getId()).singleResult();
  user.setFirstName(userRepresentation.getFirstName());
  user.setLastName(userRepresentation.getLastName());
  user.setEmail(userRepresentation.getEmail());
  identityService.saveUser(user);
  return new UserRepresentation(user);
}
 
Example 4
Source File: IdentityController.java    From activiti-in-action-codes with Apache License 2.0 6 votes vote down vote up
/**
 * 保存User
 *
 * @param redirectAttributes
 * @return
 */
@RequestMapping(value = "user/save", method = RequestMethod.POST)
public String saveUser(@RequestParam("userId") String userId,
                       @RequestParam("firstName") String firstName,
                       @RequestParam("lastName") String lastName,
                       @RequestParam(value = "password", required = false) String password,
                       @RequestParam(value = "email", required = false) String email,
                       RedirectAttributes redirectAttributes) {
    User user = identityService.createUserQuery().userId(userId).singleResult();
    if (user == null) {
        user = identityService.newUser(userId);
    }
    user.setFirstName(firstName);
    user.setLastName(lastName);
    user.setEmail(email);
    if (StringUtils.isNotBlank(password)) {
        user.setPassword(password);
    }
    identityService.saveUser(user);
    redirectAttributes.addFlashAttribute("message", "成功添加用户[" + firstName + " " + lastName + "]");
    return "redirect:/chapter14/identity/user/list";
}
 
Example 5
Source File: UserQueryEscapeClauseTest.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
private User createUser(String id, String firstName, String lastName, String email) {
  User user = identityService.newUser(id);
  user.setFirstName(firstName);
  user.setLastName(lastName);
  user.setEmail(email);
  identityService.saveUser(user);
  return user;
}
 
Example 6
Source File: SerializableVariablesDiabledTest.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
@Before
public void setupServer() {
	if (serverUrlPrefix == null) {
		TestServer testServer = TestServerUtil.createAndStartServer(ObjectVariableSerializationDisabledApplicationConfiguration.class);
		serverUrlPrefix = testServer.getServerUrlPrefix();
		
		this.repositoryService = testServer.getApplicationContext().getBean(RepositoryService.class);
		this.runtimeService = testServer.getApplicationContext().getBean(RuntimeService.class);
		this.identityService = testServer.getApplicationContext().getBean(IdentityService.class);
		this.taskService = testServer.getApplicationContext().getBean(TaskService.class);
		
    User user = identityService.newUser("kermit");
    user.setFirstName("Kermit");
    user.setLastName("the Frog");
    user.setPassword("kermit");
    identityService.saveUser(user);
    
    Group group = identityService.newGroup("admin");
    group.setName("Administrators");
    identityService.saveGroup(group);
    
    identityService.createMembership(user.getId(), group.getId());
    
    this.testUserId = user.getId();
    this.testGroupId = group.getId();
	}
}
 
Example 7
Source File: BaseSpringRestTestCase.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
protected void createUsers() {
  User user = identityService.newUser("kermit");
  user.setFirstName("Kermit");
  user.setLastName("the Frog");
  user.setPassword("kermit");
  identityService.saveUser(user);

  Group group = identityService.newGroup("admin");
  group.setName("Administrators");
  identityService.saveGroup(group);

  identityService.createMembership(user.getId(), group.getId());
}
 
Example 8
Source File: BaseJPARestTestCase.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
protected void createUsers() {
  User user = identityService.newUser("kermit");
  user.setFirstName("Kermit");
  user.setLastName("the Frog");
  user.setPassword("kermit");
  identityService.saveUser(user);

  Group group = identityService.newGroup("admin");
  group.setName("Administrators");
  identityService.saveGroup(group);

  identityService.createMembership(user.getId(), group.getId());
}
 
Example 9
Source File: UserInfoResourceTest.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
/**
 * Test getting info for a user.
 */
public void testGetUserInfo() throws Exception {
  User savedUser = null;
  try {
    User newUser = identityService.newUser("testuser");
    newUser.setFirstName("Fred");
    newUser.setLastName("McDonald");
    newUser.setEmail("[email protected]");
    identityService.saveUser(newUser);
    savedUser = newUser;

    identityService.setUserInfo(newUser.getId(), "key1", "Value 1");

    CloseableHttpResponse response = executeRequest(new HttpGet(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_USER_INFO, newUser.getId(), "key1")), HttpStatus.SC_OK);
    JsonNode responseNode = objectMapper.readTree(response.getEntity().getContent());
    closeResponse(response);
    assertEquals("key1", responseNode.get("key").textValue());
    assertEquals("Value 1", responseNode.get("value").textValue());

    assertTrue(responseNode.get("url").textValue().endsWith(RestUrls.createRelativeResourceUrl(RestUrls.URL_USER_INFO, newUser.getId(), "key1")));

  } finally {

    // Delete user after test passes or fails
    if (savedUser != null) {
      identityService.deleteUser(savedUser.getId());
    }
  }
}
 
Example 10
Source File: UserPictureResourceTest.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
/**
 * Test getting the picture for a user.
 */
public void testGetUserPicture() throws Exception {
  User savedUser = null;
  try {
    User newUser = identityService.newUser("testuser");
    newUser.setFirstName("Fred");
    newUser.setLastName("McDonald");
    newUser.setEmail("[email protected]");
    identityService.saveUser(newUser);
    savedUser = newUser;

    // Create picture for user
    Picture thePicture = new Picture("this is the picture raw byte stream".getBytes(), "image/png");
    identityService.setUserPicture(newUser.getId(), thePicture);

    CloseableHttpResponse response = executeRequest(new HttpGet(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_USER_PICTURE, newUser.getId())), HttpStatus.SC_OK);

    assertEquals("this is the picture raw byte stream", IOUtils.toString(response.getEntity().getContent()));

    // Check if media-type is correct
    assertEquals("image/png", response.getEntity().getContentType().getValue());
    closeResponse(response);

  } finally {

    // Delete user after test passes or fails
    if (savedUser != null) {
      identityService.deleteUser(savedUser.getId());
    }
  }
}
 
Example 11
Source File: UserAndGroupInUserTaskTest.java    From activiti-in-action-codes with Apache License 2.0 5 votes vote down vote up
@Test
@Deployment(resources = {"chapter5/userAndGroupInUserTask.bpmn"})
public void testUserTaskWithGroupContainsTwoUser() throws Exception {

    // 在setUp()的基础上再添加一个用户然后加入到组deptLeader中
    User user = identityService.newUser("jackchen");
    user.setFirstName("Jack");
    user.setLastName("Chen");
    user.setEmail("[email protected]");
    identityService.saveUser(user);

    // 把用户henryyan加入到组deptLeader中
    identityService.createMembership("jackchen", "deptLeader");

    // 启动流程
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("userAndGroupInUserTask");
    assertNotNull(processInstance);

    // jackchen作为候选人的任务
    Task jackchenTask = taskService.createTaskQuery().taskCandidateUser("jackchen").singleResult();
    assertNotNull(jackchenTask);

    // henryyan作为候选人的任务
    Task henryyanTask = taskService.createTaskQuery().taskCandidateUser("henryyan").singleResult();
    assertNotNull(henryyanTask);

    // jackchen签收任务
    taskService.claim(jackchenTask.getId(), "jackchen");

    // 再次查询用户henryyan是否拥有刚刚的候选任务
    henryyanTask = taskService.createTaskQuery().taskCandidateUser("henryyan").singleResult();
    assertNull(henryyanTask);
}
 
Example 12
Source File: UserPictureResourceTest.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
public void testUpdatePicture() throws Exception {
  User savedUser = null;
  try {
    User newUser = identityService.newUser("testuser");
    newUser.setFirstName("Fred");
    newUser.setLastName("McDonald");
    newUser.setEmail("[email protected]");
    identityService.saveUser(newUser);
    savedUser = newUser;

    HttpPut httpPut = new HttpPut(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_USER_PICTURE, newUser.getId()));
    httpPut.setEntity(HttpMultipartHelper.getMultiPartEntity("myPicture.png", "image/png", new ByteArrayInputStream("this is the picture raw byte stream".getBytes()), null));
    closeResponse(executeBinaryRequest(httpPut, HttpStatus.SC_NO_CONTENT));

    Picture picture = identityService.getUserPicture(newUser.getId());
    assertNotNull(picture);
    assertEquals("image/png", picture.getMimeType());
    assertEquals("this is the picture raw byte stream", new String(picture.getBytes()));

  } finally {

    // Delete user after test passes or fails
    if (savedUser != null) {
      identityService.deleteUser(savedUser.getId());
    }
  }
}
 
Example 13
Source File: UserPictureResourceTest.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
public void testUpdatePictureWithCustomMimeType() throws Exception {
  User savedUser = null;
  try {
    User newUser = identityService.newUser("testuser");
    newUser.setFirstName("Fred");
    newUser.setLastName("McDonald");
    newUser.setEmail("[email protected]");
    identityService.saveUser(newUser);
    savedUser = newUser;

    Map<String, String> additionalFields = new HashMap<String, String>();
    additionalFields.put("mimeType", MediaType.IMAGE_PNG.toString());

    HttpPut httpPut = new HttpPut(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_USER_PICTURE, newUser.getId()));
    httpPut.setEntity(HttpMultipartHelper.getMultiPartEntity("myPicture.png", "image/png", new ByteArrayInputStream("this is the picture raw byte stream".getBytes()), additionalFields));
    closeResponse(executeBinaryRequest(httpPut, HttpStatus.SC_NO_CONTENT));

    Picture picture = identityService.getUserPicture(newUser.getId());
    assertNotNull(picture);
    assertEquals("image/png", picture.getMimeType());
    assertEquals("this is the picture raw byte stream", new String(picture.getBytes()));

  } finally {

    // Delete user after test passes or fails
    if (savedUser != null) {
      identityService.deleteUser(savedUser.getId());
    }
  }
}
 
Example 14
Source File: SecurityAutoConfigurationTest.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
protected User user(String userName, String f, String l) {
    User u = identityService.newUser(userName);
    u.setFirstName(f);
    u.setLastName(l);
    u.setPassword("password");
    identityService.saveUser(u);
    return u;
}
 
Example 15
Source File: UserResourceTest.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
/**
 * Test updating a single user passing in no fields in the json, user should remain unchanged.
 */
public void testUpdateUserNoFields() throws Exception {
  User savedUser = null;
  try {
    User newUser = identityService.newUser("testuser");
    newUser.setFirstName("Fred");
    newUser.setLastName("McDonald");
    newUser.setEmail("[email protected]");
    identityService.saveUser(newUser);
    savedUser = newUser;

    ObjectNode taskUpdateRequest = objectMapper.createObjectNode();

    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("Fred", responseNode.get("firstName").textValue());
    assertEquals("McDonald", responseNode.get("lastName").textValue());
    assertEquals("[email protected]", 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("McDonald", newUser.getLastName());
    assertEquals("Fred", newUser.getFirstName());
    assertEquals("[email protected]", newUser.getEmail());
    assertNull(newUser.getPassword());

  } finally {

    // Delete user after test fails
    if (savedUser != null) {
      identityService.deleteUser(savedUser.getId());
    }
  }
}
 
Example 16
Source File: SpringIdentityServiceTest.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
@Override
public void notify(DelegateTask delegateTask) {

  User user = identityService.newUser("User1");
  user.setFirstName("User1");
  user.setLastName("Created");
  user.setEmail("[email protected]");
  user.setPassword("User1");
  identityService.saveUser(user);
}
 
Example 17
Source File: UserResourceTest.java    From activiti6-boot2 with Apache License 2.0 4 votes vote down vote up
/**
 * 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("[email protected]");
    identityService.saveUser(newUser);
    savedUser = newUser;

    ObjectNode taskUpdateRequest = objectMapper.createObjectNode();
    taskUpdateRequest.put("firstName", "Tijs");
    taskUpdateRequest.put("lastName", "Barrez");
    taskUpdateRequest.put("email", "[email protected]");
    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("[email protected]", 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("[email protected]", newUser.getEmail());
    assertEquals("updatedpassword", newUser.getPassword());

  } finally {

    // Delete user after test fails
    if (savedUser != null) {
      identityService.deleteUser(savedUser.getId());
    }
  }
}
 
Example 18
Source File: AppTest.java    From tutorial with MIT License 4 votes vote down vote up
@Test
public void listTasks() {
    // 1. 查寻/设置 用户和组
    logger.trace("query and create managers group and user waytt if they are not exist.");
    String groupId = "hosts";
    String userId = "dolores";
    //查询有没有ID为 managers 的组
    List<Group> hostGroups = identityService.createGroupQuery().groupId(groupId).list();
    Group hostGroup;
    if(hostGroups == null || hostGroups.size() == 0) {
        // 没有,增加一个
        hostGroup = identityService.newGroup(groupId); //参数是groupId
        hostGroup.setName("接待员");
        hostGroup.setType("business-role");
        identityService.saveGroup(hostGroup);
    }else{
        hostGroup = hostGroups.get(0);
    }

    List<User> users = identityService.createUserQuery().userId(userId).list();
    User userDolores;
    if(users == null || users.size() == 0) {
        userDolores = identityService.newUser(userId);
        userDolores.setFirstName("Dolores");
        userDolores.setLastName("Abernathy");
        userDolores.setPassword("none");
        userDolores.setEmail("[email protected]");
        identityService.saveUser(userDolores);
        identityService.createMembership(userDolores.getId(), hostGroup.getId());
    }else{
        userDolores = users.get(0);
    }


    logger.trace("listTasks");
    List<Task> tasks = taskService.createTaskQuery().list();

    if(tasks == null || tasks.size() == 0){
        logger.trace("donot found any tasks; add one");

        Map<String, Object> variables = new HashMap<String, Object>();
        variables.put("applicantName", "Bernard Lowe");
        variables.put("email", "[email protected]");
        variables.put("phoneNumber", "123456789");
        runtimeService.startProcessInstanceByKey("hireProcess", variables);
    }else{
        for(Task t : tasks){
            logger.trace("  task {}, {}, {}, {}, {}", t.getCategory(), t.getClaimTime(),
                    t.getName(), t.getId(), t.getFormKey());


            TaskFormData taskFormData = formService.getTaskFormData(t.getId());
            List<FormProperty> formProperties = taskFormData.getFormProperties();
            for (FormProperty property : formProperties) {
                logger.trace("  FormData property  id: {}, name: {}, type: {} value: {}", property.getId(), property.getName(), property.getType(), property.getValue());
            }

        }
    }

    //query again
    tasks = taskService.createTaskQuery().list();
    assertTrue(tasks.size() > 0);
    for(int i=0; i<tasks.size() && i < 3; i++) {
        //认领几个任务(最多3个)
        Task task = tasks.get(i);
        //认领此任务
        taskService.claim(task.getId(), userDolores.getId());
    }

    //查看dolores用户当前的任务列表
    List<Task> tasksOfDolores = taskService.createTaskQuery().taskAssignee(userDolores.getId()).list();
    for (Task dt : tasksOfDolores) {
        logger.trace("Dolores's task: {}, {}, {}", dt.getId(), dt.getCreateTime(), dt.getProcessVariables());
        // 设置此任务为完成状态
        Map<String, Object> vars = new HashMap<>();
        vars.put("telephoneInterviewOutcome", true);
        vars.put("techOk", false);
        vars.put("financialOk", true);
        taskService.complete(dt.getId(), vars);

        // 查询这个任务对应的流程的最终状态
        HistoricProcessInstance hpi = historyService.createHistoricProcessInstanceQuery().processInstanceId(dt.getProcessInstanceId()).singleResult();
        logger.trace("HistoricProcessInstance {}, {}, {}, {}", hpi.getName(), hpi.getEndActivityId(), hpi.getStartTime(), hpi.getEndTime());
    }


}
 
Example 19
Source File: UserInfoResourceTest.java    From activiti6-boot2 with Apache License 2.0 4 votes vote down vote up
/**
 * Test getting the collection of info for a user.
 */
public void testGetUserInfoCollection() throws Exception {
  User savedUser = null;
  try {
    User newUser = identityService.newUser("testuser");
    newUser.setFirstName("Fred");
    newUser.setLastName("McDonald");
    newUser.setEmail("[email protected]");
    identityService.saveUser(newUser);
    savedUser = newUser;

    identityService.setUserInfo(newUser.getId(), "key1", "Value 1");
    identityService.setUserInfo(newUser.getId(), "key2", "Value 2");

    CloseableHttpResponse response = executeRequest(new HttpGet(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_USER_INFO_COLLECTION, newUser.getId())), HttpStatus.SC_OK);
    JsonNode responseNode = objectMapper.readTree(response.getEntity().getContent());
    closeResponse(response);
    assertNotNull(responseNode);
    assertTrue(responseNode.isArray());
    assertEquals(2, responseNode.size());

    boolean foundFirst = false;
    boolean foundSecond = false;

    for (int i = 0; i < responseNode.size(); i++) {
      ObjectNode info = (ObjectNode) responseNode.get(i);
      assertNotNull(info.get("key").textValue());
      assertNotNull(info.get("url").textValue());

      if (info.get("key").textValue().equals("key1")) {
        foundFirst = true;
        assertTrue(info.get("url").textValue().endsWith(RestUrls.createRelativeResourceUrl(RestUrls.URL_USER_INFO, newUser.getId(), "key1")));
      } else if (info.get("key").textValue().equals("key2")) {
        assertTrue(info.get("url").textValue().endsWith(RestUrls.createRelativeResourceUrl(RestUrls.URL_USER_INFO, newUser.getId(), "key2")));
        foundSecond = true;
      }
    }
    assertTrue(foundFirst);
    assertTrue(foundSecond);

  } finally {

    // Delete user after test passes or fails
    if (savedUser != null) {
      identityService.deleteUser(savedUser.getId());
    }
  }
}
 
Example 20
Source File: UserResourceTest.java    From activiti6-boot2 with Apache License 2.0 4 votes vote down vote up
/**
 * Test updating a single user passing in no fields in the json, user should remain unchanged.
 */
public void testUpdateUserNullFields() throws Exception {
  User savedUser = null;
  try {
    User newUser = identityService.newUser("testuser");
    newUser.setFirstName("Fred");
    newUser.setLastName("McDonald");
    newUser.setEmail("[email protected]");
    identityService.saveUser(newUser);
    savedUser = newUser;

    ObjectNode taskUpdateRequest = objectMapper.createObjectNode();
    taskUpdateRequest.putNull("firstName");
    taskUpdateRequest.putNull("lastName");
    taskUpdateRequest.putNull("email");
    taskUpdateRequest.putNull("password");

    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());
    assertTrue(responseNode.get("firstName").isNull());
    assertTrue(responseNode.get("lastName").isNull());
    assertTrue(responseNode.get("email").isNull());
    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();
    assertNull(newUser.getLastName());
    assertNull(newUser.getFirstName());
    assertNull(newUser.getEmail());

  } finally {

    // Delete user after test fails
    if (savedUser != null) {
      identityService.deleteUser(savedUser.getId());
    }
  }
}