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

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


    assertTrue(allowedValuesForPriority.iterator().hasNext());
    final BasicPriority priority = (BasicPriority) allowedValuesForPriority.iterator().next();

    // build issue input
    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");

    final Set<String> summaries = ImmutableSet.of("Summary 1", "Summary 2", "Summary 3", "Summary 4", "Summary 5");

    // 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();
    assertEquals(summaries.size(), Iterables.size(createdIssues.getIssues()));
    assertEquals(0, Iterables.size(createdIssues.getErrors()));

    //check order
    final Set<String> createdSummariesOrder = ImmutableSet.copyOf(Iterables.transform(createdIssues
        .getIssues(), new Function<BasicIssue, String>() {
      @Override
      public String apply(final BasicIssue basicIssue) {
        return issueClient.getIssue(basicIssue.getKey()).claim().getSummary();
      }
    }));

    assertEquals(summaries, createdSummariesOrder);

    final Issue parentIssue = issueClient.getIssue("TST-1").claim();
    final Set<String> subtaskKeys = ImmutableSet.copyOf(Iterables.transform(parentIssue
        .getSubtasks(), new Function<Subtask, String>() {
      @Override
      public String apply(final Subtask subtask) {
        return subtask.getIssueKey();
      }
    }));

    for (final BasicIssue basicIssue : createdIssues.getIssues()) {

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

      assertEquals(basicIssue.getKey(), createdIssue.getKey());
      assertEquals(project.getKey(), createdIssue.getProject().getKey());
      assertEquals(issueType.getId(), createdIssue.getIssueType().getId());
      assertTrue(summaries.contains(createdIssue.getSummary()));
      assertEquals( description, createdIssue.getDescription());

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

      assertTrue(subtaskKeys.contains(createdIssue.getKey()));
    }
  }
View Full Code Here


    assertTrue(allowedValuesForPriority.iterator().hasNext());
    final BasicPriority priority = (BasicPriority) allowedValuesForPriority.iterator().next();

    // build issue input
    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");


    final Set<String> summaries = ImmutableSet.of("Summary 1","Summary 2","Summary 3","Summary 4","Summary 5");
    final Set<String> summariesWithError = ImmutableSet.of("Summary 1", "Summary 4");
    final Set<String> expectedSummariesOrder = Sets.difference(summaries, summariesWithError);

    final int issuecToCreateCount = summaries.size() - summariesWithError.size();
    final int issuesInErrorCount = summariesWithError.size();

    final List<IssueInput> issuesToCreate = Lists.newArrayList();
    // prepare IssueInput
    for (final String summary : summaries) {
      String currentProjectKey = project.getKey();
      //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();
    assertEquals(issuecToCreateCount, Iterables.size(createdIssues.getIssues()));
    assertEquals(issuesInErrorCount, Iterables.size(createdIssues.getErrors()));

    //check order
    final Set<String> createdSummariesOrder = ImmutableSet.copyOf(Iterables.transform(createdIssues
        .getIssues(), new Function<BasicIssue, String>() {
      @Override
      public String apply(final BasicIssue basicIssue) {
        return issueClient.getIssue(basicIssue.getKey()).claim().getSummary();
      }
    }));

    assertEquals(expectedSummariesOrder, createdSummariesOrder);

    final Issue parentIssue = issueClient.getIssue("TST-1").claim();
    final Set<String> subtaskKeys = ImmutableSet.copyOf(Iterables.transform(parentIssue
        .getSubtasks(), new Function<Subtask, String>() {
      @Override
      public String apply(Subtask subtask) {
        return subtask.getIssueKey();
      }
    }));

    for (final BasicIssue basicIssue : createdIssues.getIssues()) {

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

      assertEquals(basicIssue.getKey(), createdIssue.getKey());
      assertEquals(project.getKey(), createdIssue.getProject().getKey());
      assertEquals(issueType.getId(), createdIssue.getIssueType().getId());
      assertEquals( description, createdIssue.getDescription());

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

      assertTrue(summaries.contains(createdIssue.getSummary()));
      assertFalse(summariesWithError.contains(createdIssue.getSummary()));

      assertTrue(subtaskKeys.contains(createdIssue.getKey()));
View Full Code Here

    assertTrue(allowedValuesForPriority.iterator().hasNext());
    final BasicPriority priority = (BasicPriority) allowedValuesForPriority.iterator().next();

    // build issue input
    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");

    final Set<String> summaries = ImmutableSet.of("Summary 1","Summary 2","Summary 3","Summary 4","Summary 5");
View Full Code Here

  private final BasicUserJsonParser parser = new BasicUserJsonParser();

  @Test
  public void testParseWhenAnonymousUser() throws Exception {
    final BasicUser user = parser.parse(getJsonObjectFromResource("/json/user/valid-basic-anonymous.json"));

    Assert.assertNull(user);
  }
View Full Code Here

    Assert.assertNull(user);
  }

  @Test
  public void testParseWhenDeletedUserBugJRA30263() throws Exception {
    final BasicUser user = parser.parse(getJsonObjectFromResource("/json/user/valid-basic-deleted-JRA-30263.json"));

    Assert.assertEquals("mark", user.getName());
    Assert.assertTrue(user.isSelfUriIncomplete());
  }
View Full Code Here

  }


  @Test
  public void testParseWhenValid() throws Exception {
    final BasicUser user = parser.parse(getJsonObjectFromResource("/json/user/valid.json"));

    Assert.assertNotNull(user);
    Assert.assertEquals("admin", user.getName());
    Assert.assertEquals("Administrator", user.getDisplayName());
    Assert.assertEquals(toUri("http://localhost:8090/jira/rest/api/latest/user?username=admin"), user.getSelf());
    Assert.assertFalse(user.isSelfUriIncomplete());
    System.out.println(user);
  }
View Full Code Here

  private final BasicUserJsonGenerator generator = new BasicUserJsonGenerator();

  @Test
  public void testGenerate() throws Exception {
    final BasicUser user = new BasicUser(new URI("http://localhost:2990/jira/rest/api/2/user?username=wseliga"), "wseliga", "Wojciech Seliga");
    Assert.assertThat(generator.generate(user), JSONObjectMatcher.isEqual(
        ResourceUtil.getJsonObjectFromResource("/json/user/valid-generated.json")
    ));
  }
View Full Code Here

      return null; // insane representation for unassigned user - JRADEV-4262
    }

    // deleted user? BUG in REST API: JRA-30263
    final URI selfUri = optSelfUri(json, BasicUser.INCOMPLETE_URI);
    return new BasicUser(selfUri, username, json.optString("displayName", null));
  }
View Full Code Here

TOP

Related Classes of com.atlassian.jira.rest.client.api.domain.BasicUser

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.