Package org.activiti.engine.identity

Examples of org.activiti.engine.identity.User


  public Object execute(CommandContext commandContext) {
    if(userId == null) {
      throw new ActivitiIllegalArgumentException("userId is null");
    }
    User user = commandContext
      .getUserIdentityManager()
      .findUserById(userId);
    if(user == null) {
      throw new ActivitiObjectNotFoundException("user "+userId+" doesn't exist", User.class);
    }
View Full Code Here


      }
    }
  }
 
  protected void initUserLink(final String userId) {
    User user = ProcessEngines.getDefaultProcessEngine().getIdentityService().createUserQuery().userId(userId).singleResult();
    Button userButton = new Button(user.getFirstName() + " " + user.getLastName());
    ClickListener buttonClickListener = new ClickListener() {
     
      private static final long serialVersionUID = 1L;

      public void buttonClick(ClickEvent event) {
View Full Code Here

* @author Frederik Heremans
*/
public class IdentityServiceTest extends PluggableActivitiTestCase {

  public void testUserInfo() {
    User user = identityService.newUser("testuser");
    identityService.saveUser(user);
   
    identityService.setUserInfo("testuser", "myinfo", "myvalue");
    assertEquals("myvalue", identityService.getUserInfo("testuser", "myinfo"));
   
    identityService.setUserInfo("testuser", "myinfo", "myvalue2");
    assertEquals("myvalue2", identityService.getUserInfo("testuser", "myinfo"));
   
    identityService.deleteUserInfo("testuser", "myinfo");
    assertNull(identityService.getUserInfo("testuser", "myinfo"));
   
    identityService.deleteUser(user.getId());
  }
View Full Code Here

   
    identityService.deleteUser(user.getId());
  }
 
  public void testCreateExistingUser() {
    User user = identityService.newUser("testuser");
    identityService.saveUser(user);
    try {
      User secondUser = identityService.newUser("testuser");
      identityService.saveUser(secondUser);
      fail("Exception should have been thrown");
    } catch (RuntimeException re) {
      // Expected exception while saving new user with the same name as an existing one.
    }
View Full Code Here

    identityService.deleteUser(user.getId());
  }
 
  public void testUpdateUser() {
    // First, create a new user
    User user = identityService.newUser("johndoe");
    user.setFirstName("John");
    user.setLastName("Doe");
    user.setEmail("johndoe@alfresco.com");
    identityService.saveUser(user);

    // Fetch and update the user
    user = identityService.createUserQuery().userId("johndoe").singleResult();
    user.setEmail("updated@alfresco.com");
    user.setFirstName("Jane");
    user.setLastName("Donnel");
    identityService.saveUser(user);

    user = identityService.createUserQuery().userId("johndoe").singleResult();
    assertEquals("Jane", user.getFirstName());
    assertEquals("Donnel", user.getLastName());
    assertEquals("updated@alfresco.com", user.getEmail());

    identityService.deleteUser(user.getId());
  }
View Full Code Here

    identityService.deleteUser(user.getId());
  }

  public void testUserPicture() {
    // First, create a new user
    User user = identityService.newUser("johndoe");
    identityService.saveUser(user);
    String userId = user.getId();

    Picture picture = new Picture("niceface".getBytes(), "image/string");
    identityService.setUserPicture(userId, picture);
   
    picture = identityService.getUserPicture(userId);

    // Fetch and update the user
    user = identityService.createUserQuery().userId("johndoe").singleResult();
    assertTrue("byte arrays differ", Arrays.equals("niceface".getBytes(), picture.getBytes()));
    assertEquals("image/string", picture.getMimeType());

    identityService.deleteUser(user.getId());
  }
View Full Code Here

    identityService.deleteGroup(group.getId());
  }

  public void findUserByUnexistingId() {
    User user = identityService.createUserQuery().userId("unexistinguser").singleResult();
    assertNull(user);
  }
View Full Code Here

  }



  public void testCreateMembershipUnexistingGroup() {
    User johndoe = identityService.newUser("johndoe");
    identityService.saveUser(johndoe);
   
    try {
      identityService.createMembership(johndoe.getId(), "unexistinggroup");
      fail("Expected exception");
    } catch(RuntimeException re) {
      // Exception expected
    }
   
    identityService.deleteUser(johndoe.getId());
  }
View Full Code Here

  }
 
  public void testCreateMembershipAlreadyExisting() {
    Group sales = identityService.newGroup("sales");
    identityService.saveGroup(sales);
    User johndoe = identityService.newUser("johndoe");
    identityService.saveUser(johndoe);
   
    // Create the membership
    identityService.createMembership(johndoe.getId(), sales.getId());
   
    try {
      identityService.createMembership(johndoe.getId(), sales.getId());     
    } catch(RuntimeException re) {
     // Expected exception, membership already exists
    }
   
    identityService.deleteGroup(sales.getId());
    identityService.deleteUser(johndoe.getId());
  }
View Full Code Here

  public void testDeleteMembership() {
    Group sales = identityService.newGroup("sales");
    identityService.saveGroup(sales);

    User johndoe = identityService.newUser("johndoe");
    identityService.saveUser(johndoe);
    // Add membership
    identityService.createMembership(johndoe.getId(), sales.getId());

    List<Group> groups = identityService.createGroupQuery().groupMember(johndoe.getId()).list();
    assertTrue(groups.size() == 1);
    assertEquals("sales", groups.get(0).getId());

    // Delete the membership and check members of sales group
    identityService.deleteMembership(johndoe.getId(), sales.getId());
    groups = identityService.createGroupQuery().groupMember(johndoe.getId()).list();
    assertTrue(groups.isEmpty());

    identityService.deleteGroup("sales");
    identityService.deleteUser("johndoe");
  }
View Full Code Here

TOP

Related Classes of org.activiti.engine.identity.User

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.