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

Examples of com.atlassian.jira.rest.client.api.domain.input.IssueInputBuilder


      final IssueRestClient issueClient = restClient.getIssueClient();

      System.out.println("Sending issue creation requests...");
      for (int i = 0; i < 100; i++) {
        final String summary = "NewIssue#" + i;
        final IssueInput newIssue = new IssueInputBuilder("TST", 1L, summary).build();
        System.out.println("\tCreating: " + summary);
        promises.add(issueClient.createIssue(newIssue));
      }

      System.out.println("Collecting responses...");
View Full Code Here


    // build issue input
    final String summary = "Some subtask";
    final String description = "Some description for substask";

    // prepare IssueInput
    final IssueInputBuilder issueInputBuilder = new IssueInputBuilder(project, issueType, summary)
        .setDescription(description)
        .setFieldValue("parent", ComplexIssueInputFieldValue.with("key", issue.getKey()));

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

    return basicCreatedIssue;
  }
View Full Code Here

    log.log("");

    final CimIssueType issueType = project.getIssueTypes().iterator().next();
    log.log(MessageFormat.format("Selected issue type: [{0}] {1}\n", issueType.getId(), issueType.getName()));

    final IssueInputBuilder builder = new IssueInputBuilder(project.getKey(), issueType.getId());

    // fill fields
    log.log("Filling fields:");
    for (Map.Entry<String, CimFieldInfo> entry : issueType.getFields().entrySet()) {
      final CimFieldInfo fieldInfo = entry.getValue();
      final String fieldCustomType = fieldInfo.getSchema().getCustom();
      final String fieldType = fieldInfo.getSchema().getType();
      final String fieldId = fieldInfo.getId();

      if ("project".equals(fieldId) || "issuetype".equals(fieldId)) {
        // this field was already set by IssueInputBuilder constructor - skip it
        continue;
      }

      log.log(MessageFormat.format("\t* [{0}] {1}\n\t\t| schema: {2}\n\t\t| required: {3}", fieldId, fieldInfo
          .getName(), fieldInfo.getSchema(), fieldInfo.isRequired()));

      // choose value for this field
      Object value = null;
      final Iterable<Object> allowedValues = fieldInfo.getAllowedValues();
      if (allowedValues != null) {
        log.log("\t\t| field only accepts those values:");
        for (Object val : allowedValues) {
          log.log("\t\t\t* " + val);
        }
        if (allowedValues.iterator().hasNext()) {
          final boolean expectedArray = "array".equals(fieldType);
          Object singleValue = allowedValues.iterator().next();

          if ("com.atlassian.jira.plugin.system.customfieldtypes:cascadingselect".equals(fieldCustomType)) {
            // select option with children - if any
            final Iterable<Object> optionsWithChildren = Iterables.filter(allowedValues, new Predicate<Object>() {
              @Override
              public boolean apply(Object input) {
                return ((CustomFieldOption) input).getChildren().iterator().hasNext();
              }
            });

            if (optionsWithChildren.iterator().hasNext()) {
              // there is option with children - set it
              final CustomFieldOption option = (CustomFieldOption) optionsWithChildren.iterator().next();
              value = new CustomFieldOption(option.getId(), option.getSelf(), option.getValue(),
                  Collections.<CustomFieldOption>emptyList(), option.getChildren().iterator().next());
            }
            else {
              // no sub-values available, set only top level value
              value = allowedValues.iterator().next();
            }
          }
          else {
            value = expectedArray ? Collections.singletonList(singleValue) : singleValue;
          }
          log.log("\t\t| selecting value: " + value);
        } else {
          log.log("\t\t| there is no allowed value - leaving field blank");
        }
      } else {
        if ("com.atlassian.jirafisheyeplugin:jobcheckbox".equals(fieldCustomType)) {
          value = "false";
        }
        else if ("com.atlassian.jira.plugin.system.customfieldtypes:url".equals(fieldCustomType)) {
          value = "http://www.atlassian.com/";
        }
        else if ("string".equals(fieldType)) {
          value = "This is simple string value for field " + fieldId + " named " + fieldInfo.getName() + ".";
        } else if ("number".equals(fieldType)) {
          value = 124;
        } else if ("user".equals(fieldType)) {
          value = IntegrationTestUtil.USER_ADMIN;
        } else if ("array".equals(fieldType) && "user".equals(fieldInfo.getSchema().getItems())) {
          value = ImmutableList.of(IntegrationTestUtil.USER_ADMIN);
        } else if ("group".equals(fieldType)) {
          // TODO change to group object when implemented
          value = ComplexIssueInputFieldValue.with("name", IntegrationTestUtil.GROUP_JIRA_ADMINISTRATORS);
        } else if ("array".equals(fieldType) && "group".equals(fieldInfo.getSchema().getItems())) {
          // TODO change to group object when implemented
          value = ImmutableList.of(ComplexIssueInputFieldValue.with("name", IntegrationTestUtil.GROUP_JIRA_ADMINISTRATORS));
        } else if ("date".equals(fieldType)) {
          value = JsonParseUtil.formatDate(new DateTime());
        } else if ("datetime".equals(fieldType)) {
          value = JsonParseUtil.formatDateTime(new DateTime());
        } else if ("array".equals(fieldType) && "string".equals(fieldInfo.getSchema().getItems())) {
          value = ImmutableList.of("one", "two", "three");
        } else if ("timetracking".equals(fieldType)) {
          value = new TimeTracking(60, 40, null); // time spent is not allowed
        } else {
          if (fieldInfo.isRequired()) {
            fail("I don't know how to fill that required field, sorry.");
          } else {
            log.log("\t\t| field value is not required, leaving blank");
          }
        }
      }
      if (value == null) {
        log.log("\t\t| value is null, skipping filed");
      } else {
        log.log(MessageFormat.format("\t\t| setting value => {0}", value));
        builder.setFieldValue(fieldId, value);
      }
    }
    log.log("");

    // all required data is provided, let's create issue
    final IssueInput issueInput = builder.build();

    final BasicIssue basicCreatedIssue = issueClient.createIssue(issueInput).claim();
    assertNotNull(basicCreatedIssue);

    final Issue createdIssue = issueClient.getIssue(basicCreatedIssue.getKey()).claim();
    assertNotNull(createdIssue);

    log.log("Created new issue successfully, key: " + basicCreatedIssue.getKey());

    // assert few fields
    IssueInputBuilder actualBuilder = new IssueInputBuilder(createdIssue.getProject(), createdIssue
        .getIssueType(), createdIssue.getSummary())
        .setPriority(createdIssue.getPriority())
        .setReporter(createdIssue.getReporter())
        .setAssignee(createdIssue.getAssignee())
        .setDescription(createdIssue.getDescription());

    final Collection<FieldInput> actualValues = actualBuilder.build().getFields().values();
    final Collection<FieldInput> expectedValues = issueInput.getFields().values();

    assertThat(expectedValues, hasItems(toArray(actualValues, FieldInput.class)));
  }
View Full Code Here

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

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

    // prepare IssueInput
    final List<IssueInput> issuesToCreate = Lists.newArrayList();
    for (final String summary : summaries) {

      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"));

      issuesToCreate.add(issueInputBuilder.build());
    }
    assertEquals(summaries.size(), issuesToCreate.size());

    // create
    final BulkOperationResult<BasicIssue> createdIssues = issueClient.createIssues(issuesToCreate).claim();
View Full Code Here

      //last issue to create will have a non existing project - to simulate creation error
      if (summariesWithError.contains(summary)) {
        currentProjectKey = "FAKE_KEY";
      }

      final IssueInputBuilder issueInputBuilder =
          new IssueInputBuilder(currentProjectKey, issueType.getId(), summary)
              .setDescription(description)
              .setAssignee(assignee)
              .setAffectedVersionsNames(affectedVersionsNames)
              .setFixVersionsNames(fixVersionsNames)
              .setComponents(component)
              .setDueDate(dueDate)
              .setPriority(priority)
              .setFieldValue("parent", ComplexIssueInputFieldValue.with("key", "TST-1"));

      issuesToCreate.add(issueInputBuilder.build());
    }
    assertEquals(summaries.size(), issuesToCreate.size());

    // create
    final BulkOperationResult<BasicIssue> createdIssues = issueClient.createIssues(issuesToCreate).claim();
View Full Code Here

      //last issue to create will have a non existing project - to simulate creation error
      if (summariesWithError.contains(summary)) {
        currentProjectKey = "FAKE_KEY";
      }

      final IssueInputBuilder issueInputBuilder =
          new IssueInputBuilder(currentProjectKey, issueType.getId(), summary)
              .setDescription(description)
              .setAssignee(assignee)
              .setAffectedVersionsNames(affectedVersionsNames)
              .setFixVersionsNames(fixVersionsNames)
              .setComponents(component)
              .setDueDate(dueDate)
              .setPriority(priority)
              .setFieldValue("parent", ComplexIssueInputFieldValue.with("key", "TST-1"));

      issuesToCreate.add(issueInputBuilder.build());
    }
    assertEquals(summaries.size(), issuesToCreate.size());

    // create
    try {
View Full Code Here

    // build issue input
    final String summary = "My new issue!";

    // create
    final IssueInput issueInput = new IssueInputBuilder(project, issueType, summary).build();
    final BasicIssue basicCreatedIssue = issueClient.createIssue(issueInput).claim();
    assertNotNull(basicCreatedIssue.getKey());

    // get issue and check if everything was set as we expected
    final Issue createdIssue = issueClient.getIssue(basicCreatedIssue.getKey()).claim();
View Full Code Here

    final IssueRestClient issueClient = client.getIssueClient();

    thrown.expect(RestClientException.class);
    thrown.expectMessage("You must specify a summary of the issue.");

    final IssueInput issueInput = new IssueInputBuilder("TST", 1L).build();
    issueClient.createIssue(issueInput).claim();
  }
View Full Code Here

TOP

Related Classes of com.atlassian.jira.rest.client.api.domain.input.IssueInputBuilder

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.