Examples of BasicComponent


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

    assertEquals(IntegrationTestUtil.USER_ADMIN_LATEST, component.getLead());
  }

  @Test
  public void testGetInvalidComponent() throws Exception {
    final BasicComponent basicComponent = Iterables.get(client.getProjectClient().getProject("TST").claim()
        .getComponents(), 0);
    final String uriForUnexistingComponent = basicComponent.getSelf().toString() + "1234";
    TestUtil.assertErrorCode(Response.Status.NOT_FOUND, "The component with id "
        + TestUtil.getLastPathSegment(basicComponent.getSelf()) + "1234 does not exist.", new Runnable() {
      @Override
      public void run() {
        client.getComponentClient().getComponent(TestUtil.toUri(uriForUnexistingComponent)).claim();
      }
    });
View Full Code Here

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

    });
  }

  @Test
  public void testGetComponentFromRestrictedProject() throws Exception {
    final BasicComponent basicComponent = Iterables.getOnlyElement(client.getProjectClient().getProject("RST").claim()
        .getComponents());
    assertEquals("One Great Component", client.getComponentClient().getComponent(basicComponent.getSelf()).claim().getName());

    // now as unauthorized user
    setClient(TestConstants.USER2_USERNAME, TestConstants.USER2_PASSWORD);
    TestUtil.assertErrorCode(Response.Status.NOT_FOUND, IntegrationTestUtil.TESTING_JIRA_5_OR_NEWER ?
        "The component with id 10010 does not exist."
        : "The user user does not have permission to complete this operation.", new Runnable() {
      @Override
      public void run() {
        client.getComponentClient().getComponent(basicComponent.getSelf()).claim().getName();
      }
    });

    setAnonymousMode();
    TestUtil.assertErrorCode(Response.Status.NOT_FOUND, IntegrationTestUtil.TESTING_JIRA_5_OR_NEWER ?
        "The component with id 10010 does not exist."
        : "This user does not have permission to complete this operation.", new Runnable() {
      @Override
      public void run() {
        client.getComponentClient().getComponent(basicComponent.getSelf()).claim().getName();
      }
    });
  }
View Full Code Here

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

  @Test
  @JiraBuildNumberDependent(BN_JIRA_4_4)
  public void testCreateAndRemoveComponent() {
    final Iterable<BasicComponent> components = client.getProjectClient().getProject("TST").claim().getComponents();
    assertEquals(2, Iterables.size(components));
    final BasicComponent basicComponent = Iterables.get(components, 0);
    final BasicComponent basicComponent2 = Iterables.get(components, 1);
    final String componentName = "my component";
    final ComponentInput componentInput = new ComponentInput(componentName, "a description", null, null);
    final Component component = client.getComponentClient().createComponent("TST", componentInput).claim();
    assertEquals(componentInput.getName(), component.getName());
    assertEquals(componentInput.getDescription(), component.getDescription());
    assertNull(component.getLead());
    assertProjectHasComponents(basicComponent.getName(), basicComponent2.getName(), componentName);

    client.getComponentClient().removeComponent(basicComponent.getSelf(), null).claim();
    assertProjectHasComponents(basicComponent2.getName(), componentName);
    client.getComponentClient().removeComponent(basicComponent2.getSelf(), null).claim();
    assertProjectHasComponents(componentName);
    client.getComponentClient().removeComponent(component.getSelf(), null).claim();
    assertProjectHasComponents();

  }
View Full Code Here

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

  @Test
  @JiraBuildNumberDependent(BN_JIRA_4_4)
  public void testCreateAndRemoveComponentAsUnauthorizedUsers() {
    final Iterable<BasicComponent> components = client.getProjectClient().getProject("TST").claim().getComponents();
    assertEquals(2, Iterables.size(components));
    final BasicComponent basicComponent = Iterables.get(components, 0);

    final ComponentInput componentInput = new ComponentInput("my component", "a description", null, null);
    setUser1();

    final Response.Status expectedForbiddenErrorCode =
        (doesJiraReturnCorrectErrorCodeForForbiddenOperation()) ? Response.Status.FORBIDDEN
            : Response.Status.UNAUTHORIZED;
    TestUtil.assertErrorCode(expectedForbiddenErrorCode, "The user wseliga does not have permission to complete this operation.", new Runnable() {
      @Override
      public void run() {
        client.getComponentClient().removeComponent(basicComponent.getSelf(), null).claim();
      }
    });
    TestUtil.assertErrorCode(expectedForbiddenErrorCode, "You cannot edit the configuration of this project.", new Runnable() {
      @Override
      public void run() {
        client.getComponentClient().createComponent("TST", componentInput).claim();
      }
    });

    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().removeComponent(basicComponent.getSelf(), null).claim();
      }
    });

    if (IntegrationTestUtil.TESTING_JIRA_5_OR_NEWER) {
      TestUtil.assertErrorCode(Response.Status.NOT_FOUND, "No project could be found with key 'TST'.", new Runnable() {
        @Override
        public void run() {
          client.getComponentClient().createComponent("TST", componentInput).claim();
        }
      });
    } else {
      // IMO for anonymous access still Response.Status.UNAUTHORIZED should be returned - JRADEV-7671
      TestUtil.assertErrorCode(expectedForbiddenErrorCode, "You cannot edit the configuration of this project.", new Runnable() {
        @Override
        public void run() {
          client.getComponentClient().createComponent("TST", componentInput).claim();
        }
      });
    }


    setAdmin();
    // now let's try to add a component with colliding name
    final ComponentInput dupeComponentInput = new ComponentInput(basicComponent.getName(), "a description", null, null);
    TestUtil.assertErrorCode(Response.Status.BAD_REQUEST, "A component with the name Component A already exists in this project.", new Runnable() {
      @Override
      public void run() {
        client.getComponentClient().createComponent("TST", dupeComponentInput).claim();
      }
View Full Code Here

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


  @Test
  @JiraBuildNumberDependent(BN_JIRA_4_4)
  public void testUpdateComponent() {
    final BasicComponent basicComponent = Iterables.get(client.getProjectClient().getProject("TST").claim()
        .getComponents(), 0);
    final Component component = client.getComponentClient().getComponent(basicComponent.getSelf()).claim();
    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)).claim();
    assertEquals(adjustedComponent, updatedComponent);
    assertEquals(adjustedComponent, client.getComponentClient().getComponent(basicComponent.getSelf()).claim());

    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)).claim();
    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)).claim();
    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)).claim();
    assertEquals(adjustedComponent, updatedComponent);

  }
View Full Code Here

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


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

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

    // 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()).claim();
      }
    });

    setAdmin();
    final BasicComponent restrictedComponent = Iterables.getOnlyElement(client.getProjectClient().getProject("RST").claim()
        .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()).claim();
      }
    });

    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"))
            .claim();
      }
    });

  }
View Full Code Here

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

import org.codehaus.jettison.json.JSONObject;

public class ComponentJsonParser implements JsonObjectParser<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

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

    // 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 String multiUserCustomFieldId = "customfield_10031";
    final ImmutableList<BasicUser> multiUserCustomFieldValues = ImmutableList.of(IntegrationTestUtil.USER1, IntegrationTestUtil.USER2);
    final IssueInputBuilder issueInputBuilder = new IssueInputBuilder(project, issueType, summary)
        .setDescription(description)
        .setAssignee(assignee)
        .setAffectedVersionsNames(affectedVersionsNames)
        .setFixVersionsNames(fixVersionsNames)
        .setComponents(component)
        .setDueDate(dueDate)
        .setPriority(priority)
        .setFieldValue(multiUserCustomFieldId, multiUserCustomFieldValues);

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

    // get issue and check if everything was set as we expected
    final Issue createdIssue = issueClient.getIssue(basicCreatedIssue.getKey()).claim();
    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 User actualAssignee = createdIssue.getAssignee();
    assertNotNull(actualAssignee);
    assertEquals(assignee.getSelf(), actualAssignee.getSelf());
    // TODO we need some users for integration tests!
    assertEquals(actualAssignee.getEmailAddress(), "wojciech.seliga@spartez.com");

    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

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

    // 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 first substask!";
    final String description = "Some description for substask";
    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)
        .setFieldValue("parent", ComplexIssueInputFieldValue.with("key", "TST-1"));

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

    // get issue and check if everything was set as we expected
    final Issue createdIssue = issueClient.getIssue(basicCreatedIssue.getKey()).claim();
    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

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

    // 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());
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.