Package org.activiti.engine.identity

Examples of org.activiti.engine.identity.Group


    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());
  }
View Full Code Here


  /**
   * Test getting a single group.
   */
  public void testGetGroup() throws Exception {
    try {
      Group testGroup = identityService.newGroup("testgroup");
      testGroup.setName("Test group");
      testGroup.setType("Test type");
      identityService.saveGroup(testGroup);
     
      CloseableHttpResponse response = executeRequest(new HttpGet(SERVER_URL_PREFIX +
          RestUrls.createRelativeResourceUrl(RestUrls.URL_GROUP, "testgroup")), HttpStatus.SC_OK);
     
      JsonNode responseNode = objectMapper.readTree(response.getEntity().getContent());
      closeResponse(response);
      assertNotNull(responseNode);
      assertEquals("testgroup", responseNode.get("id").textValue());
      assertEquals("Test group", responseNode.get("name").textValue());
      assertEquals("Test type", responseNode.get("type").textValue());
      assertTrue(responseNode.get("url").textValue().endsWith(RestUrls.createRelativeResourceUrl(
              RestUrls.URL_GROUP, testGroup.getId())));     
     
      Group createdGroup  = identityService.createGroupQuery().groupId("testgroup").singleResult();
      assertNotNull(createdGroup);
      assertEquals("Test group", createdGroup.getName());
      assertEquals("Test type", createdGroup.getType());
     
    } finally {
      try {
        identityService.deleteGroup("testgroup");
      } catch(Throwable ignore) {
View Full Code Here

  /**
   * Test deleting a single group.
   */
  public void testDeleteGroup() throws Exception {
    try {
      Group testGroup = identityService.newGroup("testgroup");
      testGroup.setName("Test group");
      testGroup.setType("Test type");
      identityService.saveGroup(testGroup);
     
      closeResponse(executeRequest(new HttpDelete(SERVER_URL_PREFIX +
          RestUrls.createRelativeResourceUrl(RestUrls.URL_GROUP, "testgroup")), HttpStatus.SC_NO_CONTENT));
     
View Full Code Here

  /**
   * Test updating a single group.
   */
  public void testUpdateGroup() throws Exception {
    try {
      Group testGroup = identityService.newGroup("testgroup");
      testGroup.setName("Test group");
      testGroup.setType("Test type");
      identityService.saveGroup(testGroup);
     
      ObjectNode requestNode = objectMapper.createObjectNode();
      requestNode.put("name", "Updated group");
      requestNode.put("type", "Updated type");
     
      HttpPut httpPut = new HttpPut(SERVER_URL_PREFIX +
          RestUrls.createRelativeResourceUrl(RestUrls.URL_GROUP, "testgroup"));
      httpPut.setEntity(new StringEntity(requestNode.toString()));
      CloseableHttpResponse response = executeRequest(httpPut, HttpStatus.SC_OK);
     
      JsonNode responseNode = objectMapper.readTree(response.getEntity().getContent());
      closeResponse(response);
      assertNotNull(responseNode);
      assertEquals("testgroup", responseNode.get("id").textValue());
      assertEquals("Updated group", responseNode.get("name").textValue());
      assertEquals("Updated type", responseNode.get("type").textValue());
      assertTrue(responseNode.get("url").textValue().endsWith(RestUrls.createRelativeResourceUrl(
              RestUrls.URL_GROUP, testGroup.getId())));     
     
      Group createdGroup  = identityService.createGroupQuery().groupId("testgroup").singleResult();
      assertNotNull(createdGroup);
      assertEquals("Updated group", createdGroup.getName());
      assertEquals("Updated type", createdGroup.getType());
     
    } finally {
      try {
        identityService.deleteGroup("testgroup");
      } catch(Throwable ignore) {
View Full Code Here

  /**
   * Test updating a single group passing in no fields in the json, user should remain unchanged.
   */
  public void testUpdateGroupNoFields() throws Exception {
    try {
      Group testGroup = identityService.newGroup("testgroup");
      testGroup.setName("Test group");
      testGroup.setType("Test type");
      identityService.saveGroup(testGroup);
     
      ObjectNode requestNode = objectMapper.createObjectNode();
     
      HttpPut httpPut = new HttpPut(SERVER_URL_PREFIX +
          RestUrls.createRelativeResourceUrl(RestUrls.URL_GROUP, "testgroup"));
      httpPut.setEntity(new StringEntity(requestNode.toString()));
      CloseableHttpResponse response = executeRequest(httpPut, HttpStatus.SC_OK);
     
      JsonNode responseNode = objectMapper.readTree(response.getEntity().getContent());
      closeResponse(response);
      assertNotNull(responseNode);
      assertEquals("testgroup", responseNode.get("id").textValue());
      assertEquals("Test group", responseNode.get("name").textValue());
      assertEquals("Test type", responseNode.get("type").textValue());
      assertTrue(responseNode.get("url").textValue().endsWith(RestUrls.createRelativeResourceUrl(
              RestUrls.URL_GROUP, testGroup.getId())));     
     
      Group createdGroup  = identityService.createGroupQuery().groupId("testgroup").singleResult();
      assertNotNull(createdGroup);
      assertEquals("Test group", createdGroup.getName());
      assertEquals("Test type", createdGroup.getType());
     
    } finally {
      try {
        identityService.deleteGroup("testgroup");
      } catch(Throwable ignore) {
View Full Code Here

      assertTextPresent("userId and groupId cannot both be null", ae.getMessage());
    }
  }
 
  public void testAddCandidateGroupUnexistingTask() {
    Group group = identityService.newGroup("group");
    identityService.saveGroup(group);
    try {
      taskService.addCandidateGroup("unexistingTaskId", group.getId());
      fail("ActivitiException expected");
    } catch (ActivitiObjectNotFoundException ae) {
      assertTextPresent("Cannot find task with id unexistingTaskId", ae.getMessage());
      assertEquals(Task.class, ae.getObjectClass());
    }
    identityService.deleteGroup(group.getId());
  }
View Full Code Here

  /**
   * Test updating a single user passing in null-values.
   */
  public void testUpdateGroupNullFields() throws Exception {
    try {
      Group testGroup = identityService.newGroup("testgroup");
      testGroup.setName("Test group");
      testGroup.setType("Test type");
      identityService.saveGroup(testGroup);
     
      ObjectNode requestNode = objectMapper.createObjectNode();
      requestNode.put("name", (JsonNode) null);
      requestNode.put("type",(JsonNode) null);
     
      HttpPut httpPut = new HttpPut(SERVER_URL_PREFIX +
          RestUrls.createRelativeResourceUrl(RestUrls.URL_GROUP, "testgroup"));
      httpPut.setEntity(new StringEntity(requestNode.toString()));
      CloseableHttpResponse response = executeRequest(httpPut, HttpStatus.SC_OK);
      JsonNode responseNode = objectMapper.readTree(response.getEntity().getContent());
      closeResponse(response);
      assertNotNull(responseNode);
      assertEquals("testgroup", responseNode.get("id").textValue());
      assertNull(responseNode.get("name").textValue());
      assertNull(responseNode.get("type").textValue());
      assertTrue(responseNode.get("url").textValue().endsWith(RestUrls.createRelativeResourceUrl(
              RestUrls.URL_GROUP, testGroup.getId())));     
     
      Group createdGroup  = identityService.createGroupQuery().groupId("testgroup").singleResult();
      assertNotNull(createdGroup);
      assertNull(createdGroup.getName());
      assertNull(createdGroup.getType());
     
    } finally {
      try {
        identityService.deleteGroup("testgroup");
      } catch(Throwable ignore) {
View Full Code Here

   */
  @Deployment
  public void testGetGroups() throws Exception {
    List<Group> savedGroups = new ArrayList<Group>();
    try {
      Group group1 = identityService.newGroup("testgroup1");
      group1.setName("Test group");
      group1.setType("Test type");
      identityService.saveGroup(group1);
      savedGroups.add(group1);
     
      Group group2 = identityService.newGroup("testgroup2");
      group2.setName("Another group");
      group2.setType("Another type");
      identityService.saveGroup(group2);
      savedGroups.add(group2);
     
      Group group3 = identityService.createGroupQuery().groupId("admin").singleResult();
      assertNotNull(group3);
     
      // Test filter-less
      String url = RestUrls.createRelativeResourceUrl(RestUrls.URL_GROUP_COLLECTION);
      assertResultsPresentInDataResponse(url, group1.getId(), group2.getId(), group3.getId());
     
      // Test based on name
      url = RestUrls.createRelativeResourceUrl(RestUrls.URL_GROUP_COLLECTION) + "?name=" + encode("Test group");
      assertResultsPresentInDataResponse(url, group1.getId());
     
      // Test based on name like
      url = RestUrls.createRelativeResourceUrl(RestUrls.URL_GROUP_COLLECTION) +"?nameLike=" + encode("% group");
      assertResultsPresentInDataResponse(url, group2.getId(), group1.getId());
     
      // Test based on type
      url = RestUrls.createRelativeResourceUrl(RestUrls.URL_GROUP_COLLECTION) +"?type=" + encode("Another type");
      assertResultsPresentInDataResponse(url, group2.getId());
     
      // Test based on group member
      url = RestUrls.createRelativeResourceUrl(RestUrls.URL_GROUP_COLLECTION) + "?member=kermit";
      assertResultsPresentInDataResponse(url, group3.getId());
     
      // Test based on potentialStarter
      String processDefinitionId = repositoryService.createProcessDefinitionQuery().processDefinitionKey("simpleProcess")
              .singleResult().getId();
      repositoryService.addCandidateStarterGroup(processDefinitionId, "admin");
    
      url = RestUrls.createRelativeResourceUrl(RestUrls.URL_GROUP_COLLECTION) + "?potentialStarter=" + processDefinitionId;
      assertResultsPresentInDataResponse(url, group3.getId());
     
    } finally {
     
      // Delete groups after test passes or fails
      if(!savedGroups.isEmpty()) {
View Full Code Here

    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());
  }
View Full Code Here

    identityService.deleteUser("johndoe");
  }

  public void testFindGroupsByUserAndType() {
    Group sales = identityService.newGroup("sales");
    sales.setType("hierarchy");
    identityService.saveGroup(sales);

    Group development = identityService.newGroup("development");
    development.setType("hierarchy");
    identityService.saveGroup(development);

    Group admin = identityService.newGroup("admin");
    admin.setType("security-role");
    identityService.saveGroup(admin);

    Group user = identityService.newGroup("user");
    user.setType("security-role");
    identityService.saveGroup(user);

    User johndoe = identityService.newUser("johndoe");
    identityService.saveUser(johndoe);
View Full Code Here

TOP

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

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.