Examples of JiraRestClient


Examples of com.atlassian.jira.rest.client.api.JiraRestClient

  public static void main(String[] args) throws URISyntaxException, JSONException, IOException {
    parseArgs(args);

    final AsynchronousJiraRestClientFactory factory = new AsynchronousJiraRestClientFactory();
    final JiraRestClient restClient = factory.createWithBasicHttpAuthentication(jiraServerUri, "admin", "admin");
    try {
      final int buildNumber = restClient.getMetadataClient().getServerInfo().claim().getBuildNumber();

      // first let's get and print all visible projects (only jira4.3+)
      if (buildNumber >= ServerVersionConstants.BN_JIRA_4_3) {
        final Iterable<BasicProject> allProjects = restClient.getProjectClient().getAllProjects().claim();
        for (BasicProject project : allProjects) {
          println(project);
        }
      }

      // let's now print all issues matching a JQL string (here: all assigned issues)
      if (buildNumber >= ServerVersionConstants.BN_JIRA_4_3) {
        final SearchResult searchResult = restClient.getSearchClient().searchJql("assignee is not EMPTY").claim();
        for (BasicIssue issue : searchResult.getIssues()) {
          println(issue.getKey());
        }
      }

      final Issue issue = restClient.getIssueClient().getIssue("TST-7").claim();

      println(issue);

      // now let's vote for it
      restClient.getIssueClient().vote(issue.getVotesUri()).claim();

      // now let's watch it
      final BasicWatchers watchers = issue.getWatchers();
      if (watchers != null) {
        restClient.getIssueClient().watch(watchers.getSelf()).claim();
      }

      // now let's start progress on this issue
      final Iterable<Transition> transitions = restClient.getIssueClient().getTransitions(issue.getTransitionsUri()).claim();
      final Transition startProgressTransition = getTransitionByName(transitions, "Start Progress");
      restClient.getIssueClient().transition(issue.getTransitionsUri(), new TransitionInput(startProgressTransition.getId()))
          .claim();

      // and now let's resolve it as Incomplete
      final Transition resolveIssueTransition = getTransitionByName(transitions, "Resolve Issue");
      final Collection<FieldInput> fieldInputs;

      // Starting from JIRA 5, fields are handled in different way -
      if (buildNumber > ServerVersionConstants.BN_JIRA_5) {
        fieldInputs = Arrays.asList(new FieldInput("resolution", ComplexIssueInputFieldValue.with("name", "Incomplete")));
      } else {
        fieldInputs = Arrays.asList(new FieldInput("resolution", "Incomplete"));
      }
      final TransitionInput transitionInput = new TransitionInput(resolveIssueTransition.getId(), fieldInputs, Comment
          .valueOf("My comment"));
      restClient.getIssueClient().transition(issue.getTransitionsUri(), transitionInput).claim();
    }
    finally {
      restClient.close();
    }
  }
View Full Code Here

Examples of com.atlassian.jira.rest.client.api.JiraRestClient

        .getName());
    final Session session2 = client.getSessionClient().getCurrentSession().claim();
    assertEquals(TestConstants.USER1.getName(), session2.getUsername());
    final DateTime lastFailedLoginDate = session2.getLoginInfo().getLastFailedLoginDate();

    final JiraRestClient client2 = clientFactory.createWithBasicHttpAuthentication(jiraUri, TestConstants.USER1
        .getName(), "bad-ppassword");
    final DateTime now = new DateTime();
    TestUtil.assertErrorCode(401, new Runnable() {
      @Override
      public void run() {
        client2.getSessionClient().getCurrentSession().claim();
      }
    });
    while (!new DateTime().isAfter(lastFailedLoginDate)) {
      Thread.sleep(20);
    }
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.