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

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


    // 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

    // 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

    // 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

    // 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

@Restore(TestConstants.DEFAULT_JIRA_DUMP_FILE)
public class AsynchronousComponentRestClientTest extends AbstractAsynchronousRestClientTest {

  @Test
  public void testGetComponent() throws Exception {
    final BasicComponent basicComponent = findEntityByName(client.getProjectClient().getProject("TST").claim()
        .getComponents(), "Component A");
    final Component component = client.getComponentClient().getComponent(basicComponent.getSelf()).claim();
    assertEquals("Component A", component.getName());
    assertEquals("this is some description of component A", component.getDescription());
    assertEquals(IntegrationTestUtil.USER_ADMIN_60, component.getLead());
  }
View Full Code Here

  }

  @Test
  @JiraBuildNumberDependent(BN_JIRA_4_4)
  public void testGetComponentOnJira4xOrNewerShouldContainNotNullId() throws Exception {
    final BasicComponent basicComponent = findEntityByName(client.getProjectClient().getProject("TST").claim()
        .getComponents(), "Component A");
    final Component component = client.getComponentClient().getComponent(basicComponent.getSelf()).claim();
    assertEquals("Component A", component.getName());
    assertEquals("this is some description of component A", component.getDescription());
    assertEquals(Long.valueOf(10000), component.getId());
    assertEquals(IntegrationTestUtil.USER_ADMIN_60, component.getLead());
  }
View Full Code Here

    assertEquals(IntegrationTestUtil.USER_ADMIN_60, 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

    });
  }

  @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

  @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

TOP

Related Classes of com.atlassian.jira.rest.client.api.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.