Package com.atlassian.jira.rest.client.domain

Examples of com.atlassian.jira.rest.client.domain.ProjectRole


    final String name = json.getString("name");
    final String description = json.getString("description");
    final Optional<JSONArray> roleActorsOpt = JsonParseUtil.getOptionalArray(json, "actors");
    final Collection<RoleActor> roleActors = roleActorsOpt.isPresent() ?
        JsonParseUtil.parseJsonArray(roleActorsOpt.get(), roleActorJsonParser) : ImmutableSet.<RoleActor>of();
    return new ProjectRole(id, self, name, description, roleActors);
  }
View Full Code Here


  @JiraBuildNumberDependent(ServerVersionConstants.BN_JIRA_4_4)
  @Test
  public void testGetProjectRoleWithRoleKeyFromAnonymousProject() {
    final Project anonProject = client.getProjectClient().getProject(ANONYMOUS_PROJECT_KEY, pm);
    final ProjectRole role = client.getProjectRolesRestClient().getRole(anonProject.getSelf(), 10000l, pm);
    assertNotNull(role);
    assertEquals("Users", role.getName());
    assertEquals("A project role that represents users in a project", role.getDescription());
    final RoleActor actor = Iterables.getOnlyElement(role.getActors());
    assertEquals("jira-users", actor.getDisplayName());
    assertEquals("atlassian-group-role-actor", actor.getType());
    assertEquals("jira-users", actor.getName());
    assertEquals(jiraUri.resolve("/jira/secure/useravatar?size=small&avatarId=10083"), actor.getAvatarUri());
  }
View Full Code Here

  @JiraBuildNumberDependent(ServerVersionConstants.BN_JIRA_4_4)
  @Test
  public void testGetProjectRoleWithRoleKeyFromRestrictedProject() {
    final Project restrictedProject = client.getProjectClient().getProject(RESTRICTED_PROJECT_KEY, pm);
    final ProjectRole role = client.getProjectRolesRestClient().getRole(restrictedProject.getSelf(), 10000l, pm);
    assertNotNull(role);
    assertEquals("Users", role.getName());
    assertEquals("A project role that represents users in a project", role.getDescription());
    final RoleActor actor = Iterables.getOnlyElement(role.getActors());
    assertEquals("Administrator", actor.getDisplayName());
    assertEquals("atlassian-user-role-actor", actor.getType());
    assertEquals("admin", actor.getName());
    assertEquals(jiraUri.resolve("/jira/secure/useravatar?size=small&ownerId=admin&avatarId=10054"), actor.getAvatarUri());
  }
View Full Code Here

  @JiraBuildNumberDependent(ServerVersionConstants.BN_JIRA_4_4)
  @Test
  public void testGetProjectRoleWithFullURI() {
    final Project anonProject = client.getProjectClient().getProject(ANONYMOUS_PROJECT_KEY, pm);
    final URI roleURI = client.getProjectRolesRestClient().getRole(anonProject.getSelf(), 10000l, pm).getSelf();
    final ProjectRole role = client.getProjectRolesRestClient().getRole(roleURI, pm);
    assertNotNull(role);
    assertEquals("Users", role.getName());
    assertEquals("A project role that represents users in a project", role.getDescription());
    final RoleActor actor = Iterables.getOnlyElement(role.getActors());
    assertEquals("jira-users", actor.getDisplayName());
    assertEquals("atlassian-group-role-actor", actor.getType());
    assertEquals("jira-users", actor.getName());
    assertEquals(jiraUri.resolve("/jira/secure/useravatar?size=small&avatarId=10083"), actor.getAvatarUri());
  }
View Full Code Here

    final Iterable<ProjectRole> projectRolesWithoutSelf = Iterables.transform(
        projectRoles,
        new Function<ProjectRole, ProjectRole>() {
          @Override
          public ProjectRole apply(final ProjectRole role) {
            return new ProjectRole(role.getId(), null, role.getName(), role.getDescription(), Lists.newArrayList(role.getActors()));
          }
        }
    );
    assertThat(projectRolesWithoutSelf, containsInAnyOrder(
        new ProjectRole(10000l, null, "Users", "A project role that represents users in a project",
            ImmutableList.<RoleActor>of(
                new RoleActor(10062l, "jira-users", "atlassian-group-role-actor", "jira-users",
                    jiraUri.resolve("/jira/secure/useravatar?size=small&avatarId=10083"))
            )),
        new ProjectRole(10001l, null, "Developers", "A project role that represents developers in a project",
            ImmutableList.<RoleActor>of(
                new RoleActor(10061l, "jira-developers", "atlassian-group-role-actor", "jira-developers",
                    jiraUri.resolve("/jira/secure/useravatar?size=small&avatarId=10083")),
                new RoleActor(10063l, "My Test User", "atlassian-user-role-actor", "user",
                    jiraUri.resolve("/jira/secure/useravatar?size=small&avatarId=10082"))
            )),
        new ProjectRole(10002l, null, "Administrators", "A project role that represents administrators in a project",
            ImmutableList.<RoleActor>of(
                new RoleActor(10060l, "jira-administrators", "atlassian-group-role-actor", "jira-administrators",
                    jiraUri.resolve("/jira/secure/useravatar?size=small&avatarId=10083"))
            ))
    ));
View Full Code Here

  @Rule
  public final ExpectedException exception = ExpectedException.none();

  @Test
  public void testParseRoleDetail() throws Exception {
    final ProjectRole role = parser.parse(ResourceUtil.getJsonObjectFromResource("/json/role/valid-role-single-actor.json"));
    assertEquals(TestUtil.toUri("http://www.example.com/jira/rest/api/2/project/MKY/role/10360"), role.getSelf());
    assertEquals("Developers", role.getName());
    assertEquals("A project role that represents developers in a project", role.getDescription());
    assertNotNull(role.getActors());
    final RoleActor actor = Iterables.getOnlyElement(role.getActors());
    assertEquals("jira-developers", actor.getDisplayName());
    assertEquals("atlassian-group-role-actor", actor.getType());
    assertEquals("jira-developers", actor.getName());
  }
View Full Code Here

    assertEquals("jira-developers", actor.getName());
  }

  @Test
  public void testParseRoleWithMultipleActors() throws Exception {
    final ProjectRole role = parser.parse(ResourceUtil.getJsonObjectFromResource("/json/role/valid-role-multiple-actors.json"));
    assertEquals(TestUtil.toUri("http://localhost:2990/jira/rest/api/2/project/TST/role/10000"), role.getSelf());
    assertEquals("Users", role.getName());
    assertEquals("A project role that represents users in a project", role.getDescription());
    assertNotNull(role.getActors());
    assertThat(role.getActors(),
        containsInAnyOrder(new RoleActor(10020l, "jira-users", "atlassian-group-role-actor", "jira-users",
                toUri("http://localhost:2990/jira/secure/useravatar?size=small&avatarId=10083")
            ),
            new RoleActor(10030l, "jira-superuser", "atlassian-user-role-actor", "superuser", null)
        )
View Full Code Here

    );
  }

  @Test
  public void testParseRoleWithNoActors() throws Exception {
    final ProjectRole role = parser.parse(ResourceUtil.getJsonObjectFromResource("/json/role/valid-role-no-actors.json"));
    assertEquals(toUri("http://localhost:2990/jira/rest/api/2/project/TST/role/10000"), role.getSelf());
    assertEquals("Users", role.getName());
    assertEquals("A project role that represents users in a project", role.getDescription());
    assertNotNull(role.getActors());
  }
View Full Code Here

  // This test checks the special "admin" case.
  // Id field should not be optional, unfortunately it is not returned for an admin role actor.
  @Test
  public void testParseProjectRoleContainingActorWithoutIdField() throws JSONException, MalformedURLException {
    final ProjectRole role = parser.parse(ResourceUtil.getJsonObjectFromResource("/json/role/valid-role-without-user-actor-id.json"));
    assertNotNull(role);
    assertEquals("Users", role.getName());
    assertEquals(TestUtil.toUri("http://localhost:2990/jira/rest/api/2/project/TST/role/10000"), role.getSelf());
    assertEquals(10000, role.getId().longValue());
    assertEquals("A project role that represents users in a project", role.getDescription());
    assertThat(
        role.getActors(),
        containsInAnyOrder(
            new RoleActor(null, "Administrator", "atlassian-user-role-actor", "admin",
                baseJiraURI.resolve("/jira/secure/useravatar?size=small&ownerId=admin&avatarId=10054")
            ),
            new RoleActor(10020l, "jira-users", "atlassian-group-role-actor", "jira-users",
View Full Code Here

TOP

Related Classes of com.atlassian.jira.rest.client.domain.ProjectRole

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.