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

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



  @Test
  @JiraBuildNumberDependent(BN_JIRA_4_4)
  public void testUpdateComponent() {
    final BasicComponent basicComponent = Iterables.get(client.getProjectClient().getProject("TST", pm).getComponents(), 0);
    final Component component = client.getComponentClient().getComponent(basicComponent.getSelf(), pm);
    final String newName = basicComponent.getName() + "updated";
    Component adjustedComponent = new Component(component.getSelf(), component.getId(), newName, component.getDescription(), component.getLead(), component.getAssigneeInfo());

    Component updatedComponent = client.getComponentClient().updateComponent(basicComponent.getSelf(), new ComponentInput(newName, null, null, null), pm);
    assertEquals(adjustedComponent, updatedComponent);
    assertEquals(adjustedComponent, client.getComponentClient().getComponent(basicComponent.getSelf(), pm));

    final String newDescription = "updated description";
    adjustedComponent = new Component(component.getSelf(), component.getId(), newName, newDescription, IntegrationTestUtil.USER1_LATEST, component.getAssigneeInfo());
    updatedComponent = client.getComponentClient().updateComponent(basicComponent.getSelf(), new ComponentInput(null, newDescription, IntegrationTestUtil.USER1.getName(), null), pm);
    assertEquals(adjustedComponent, updatedComponent);

    adjustedComponent = new Component(component.getSelf(), component.getId(), newName, newDescription, IntegrationTestUtil.USER1_LATEST,
        new Component.AssigneeInfo(IntegrationTestUtil.USER1_LATEST, AssigneeType.COMPONENT_LEAD, IntegrationTestUtil.USER1_LATEST, AssigneeType.COMPONENT_LEAD, true));

    updatedComponent = client.getComponentClient().updateComponent(basicComponent.getSelf(), new ComponentInput(null, newDescription, IntegrationTestUtil.USER1.getName(), AssigneeType.COMPONENT_LEAD), pm);
    assertEquals(adjustedComponent, updatedComponent);


    // now with non-assignable assignee (thus we are inheriting assignee from project settings and component-level settings are ignored)
    adjustedComponent = new Component(component.getSelf(), component.getId(), newName, newDescription, IntegrationTestUtil.USER2_LATEST,
        new Component.AssigneeInfo(IntegrationTestUtil.USER2_LATEST, AssigneeType.COMPONENT_LEAD, IntegrationTestUtil.USER_ADMIN_LATEST, AssigneeType.PROJECT_DEFAULT, false));

    updatedComponent = client.getComponentClient().updateComponent(basicComponent.getSelf(), new ComponentInput(null, newDescription, IntegrationTestUtil.USER2.getName(), AssigneeType.COMPONENT_LEAD), pm);
    assertEquals(adjustedComponent, updatedComponent);

  }
View Full Code Here



  @Test
  @JiraBuildNumberDependent(BN_JIRA_4_4)
  public void testGetComponentRelatedIssuesCount() {
    final BasicComponent bc = findEntityByName(client.getProjectClient().getProject("TST", pm).getComponents(), "Component A");
    assertEquals(1, client.getComponentClient().getComponentRelatedIssuesCount(bc.getSelf(), pm));
    final ComponentInput componentInput = new ComponentInput("my component name", "a description", "admin", AssigneeType.COMPONENT_LEAD);
    final Component component = client.getComponentClient().createComponent("TST", componentInput, pm);
    assertEquals(0, client.getComponentClient().getComponentRelatedIssuesCount(component.getSelf(), pm));

    client.getComponentClient().removeComponent(bc.getSelf(), component.getSelf(), pm);
    assertEquals(1, client.getComponentClient().getComponentRelatedIssuesCount(component.getSelf(), pm));

    // smelly error code/message returned here - JRA-25062
    setAnonymousMode();
    TestUtil.assertErrorCode(Response.Status.NOT_FOUND, IntegrationTestUtil.TESTING_JIRA_5_OR_NEWER ?
                "The component with id 10000 does not exist." : "This user does not have permission to complete this operation.", new Runnable() {
      @Override
      public void run() {
        client.getComponentClient().getComponentRelatedIssuesCount(component.getSelf(), pm);
      }
    });

    setAdmin();
    final BasicComponent restrictedComponent = Iterables.getOnlyElement(client.getProjectClient().getProject("RST", pm).getComponents());
    setUser1();
    TestUtil.assertErrorCode(Response.Status.NOT_FOUND, IntegrationTestUtil.TESTING_JIRA_5_OR_NEWER ?
                "The component with id 10010 does not exist." : "The user wseliga does not have permission to complete this operation.", new Runnable() {
      @Override
      public void run() {
        client.getComponentClient().getComponentRelatedIssuesCount(restrictedComponent.getSelf(), pm);
      }
    });

    setAdmin();
    TestUtil.assertErrorCode(Response.Status.NOT_FOUND, "The component with id " + TestUtil.getLastPathSegment(restrictedComponent.getSelf())
        + "999 does not exist.", new Runnable() {
      @Override
      public void run() {
        client.getComponentClient().getComponentRelatedIssuesCount(TestUtil.toUri(restrictedComponent.getSelf() + "999"), pm);
      }
    });

  }
View Full Code Here

    // grab the first component
    final Iterable<Object> allowedValuesForComponents = issueType.getField(IssueFieldId.COMPONENTS_FIELD).getAllowedValues();
    assertNotNull(allowedValuesForComponents);
    assertTrue(allowedValuesForComponents.iterator().hasNext());
    final BasicComponent component = (BasicComponent) allowedValuesForComponents.iterator().next();

    // grab the first priority
    final Iterable<Object> allowedValuesForPriority = issueType.getField(IssueFieldId.PRIORITY_FIELD).getAllowedValues();
    assertNotNull(allowedValuesForPriority);
    assertTrue(allowedValuesForPriority.iterator().hasNext());
    final BasicPriority priority = (BasicPriority) allowedValuesForPriority.iterator().next();

    // build issue input
    final String summary = "My new issue!";
    final String description = "Some description";
    final BasicUser assignee = IntegrationTestUtil.USER1;
    final List<String> affectedVersionsNames = Collections.emptyList();
    final DateTime dueDate = new DateTime(new Date().getTime());
    final ArrayList<String> fixVersionsNames = Lists.newArrayList("1.1");

    // prepare IssueInput
    final IssueInputBuilder issueInputBuilder = new IssueInputBuilder(project, issueType, summary)
        .setDescription(description)
        .setAssignee(assignee)
        .setAffectedVersionsNames(affectedVersionsNames)
        .setFixVersionsNames(fixVersionsNames)
        .setComponents(component)
        .setDueDate(dueDate)
        .setPriority(priority);

    // create
    final BasicIssue basicCreatedIssue = issueClient.createIssue(issueInputBuilder.build(), pm);
    assertNotNull(basicCreatedIssue.getKey());

    // get issue and check if everything was set as we expected
    final Issue createdIssue = issueClient.getIssue(basicCreatedIssue.getKey(), pm);
    assertNotNull(createdIssue);

    assertEquals(basicCreatedIssue.getKey(), createdIssue.getKey());
    assertEquals(project.getKey(), createdIssue.getProject().getKey());
    assertEquals(issueType.getId(), createdIssue.getIssueType().getId());
    assertEquals(summary, createdIssue.getSummary());
    assertEquals(description, createdIssue.getDescription());

    final BasicUser actualAssignee = createdIssue.getAssignee();
    assertNotNull(actualAssignee);
    assertEquals(assignee.getSelf(), actualAssignee.getSelf());

    final Iterable<String> actualAffectedVersionsNames = EntityHelper.toNamesList(createdIssue.getAffectedVersions());
    assertThat(affectedVersionsNames, containsInAnyOrder(toArray(actualAffectedVersionsNames, String.class)));

    final Iterable<String> actualFixVersionsNames = EntityHelper.toNamesList(createdIssue.getFixVersions());
    assertThat(fixVersionsNames, containsInAnyOrder(toArray(actualFixVersionsNames, String.class)));

    assertTrue(createdIssue.getComponents().iterator().hasNext());
    assertEquals(component.getId(), createdIssue.getComponents().iterator().next().getId());

    // strip time from dueDate
    final DateTime expectedDueDate = JsonParseUtil.parseDate(JsonParseUtil.formatDate(dueDate));
    assertEquals(expectedDueDate, createdIssue.getDueDate());
View Full Code Here

import org.codehaus.jettison.json.JSONObject;

public class ComponentJsonParser implements JsonParser<Component> {
  @Override
  public Component parse(JSONObject json) throws JSONException {
    final BasicComponent basicComponent = BasicComponentJsonParser.parseBasicComponent(json);
    final JSONObject leadJson = json.optJSONObject("lead");
    final BasicUser lead = leadJson != null ? JsonParseUtil.parseBasicUser(leadJson) : null;
    final String assigneeTypeStr = JsonParseUtil.getOptionalString(json, "assigneeType");
    final Component.AssigneeInfo assigneeInfo;
    if (assigneeTypeStr != null) {
      final AssigneeType assigneeType = parseAssigneeType(assigneeTypeStr);
      final JSONObject assigneeJson = json.optJSONObject("assignee");
      final BasicUser assignee = assigneeJson != null ? JsonParseUtil.parseBasicUser(assigneeJson) : null;
      final AssigneeType realAssigneeType = parseAssigneeType(json.getString("realAssigneeType"));
      final JSONObject realAssigneeJson = json.optJSONObject("realAssignee");
      final BasicUser realAssignee = realAssigneeJson != null ? JsonParseUtil.parseBasicUser(realAssigneeJson) : null;
      final boolean isAssigneeTypeValid = json.getBoolean("isAssigneeTypeValid");
      assigneeInfo = new Component.AssigneeInfo(assignee, assigneeType, realAssignee, realAssigneeType, isAssigneeTypeValid);
    } else {
      assigneeInfo = null;
    }

    return new Component(basicComponent.getSelf(), basicComponent.getId(), basicComponent.getName(), basicComponent.getDescription(), lead, assigneeInfo);
  }
View Full Code Here

  static BasicComponent parseBasicComponent(JSONObject json) throws JSONException {
    final URI selfUri = JsonParseUtil.getSelfUri(json);
    final String name = json.getString("name");
    final Long id = JsonParseUtil.getOptionalLong(json, "id");
    final String description = JsonParseUtil.getOptionalString(json, "description");
    return new BasicComponent(selfUri, id, name, description);
  }
View Full Code Here

TOP

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

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.