Package com.taskadapter.redmineapi.bean

Examples of com.taskadapter.redmineapi.bean.Issue


  @Test
  public void testParseIssues() throws IOException, JSONException {
    List<Issue> objects = loadRedmine11Issues();
    Integer issueId = 68;
    Issue issue68 = RedmineTestUtils.findIssueInList(objects, issueId);
    Assert.assertNotNull(issue68);
    Assert.assertEquals(issueId, issue68.getId());
    Integer statusId = 1;
    Assert.assertEquals(statusId, issue68.getStatusId());
    Assert.assertEquals("New", issue68.getStatusName());

    User author = issue68.getAuthor();
    Assert.assertNotNull(author);
    Integer userId = 1;
    Assert.assertEquals(userId, author.getId());
  }
View Full Code Here


  @Test
  public void testMultilineIssueDescription() throws IOException,
      JSONException {
    final String json = MyIOUtils
        .getResourceAsString("issue/issue_with_multiline_description.json");
    final Issue issue = RedmineJSONParser.parseIssue(RedmineJSONParser
        .getResponseSingleObject(json, "issue"));
    Assert.assertEquals(
        "This is a description \nwith more than \n\n\none line.",
        issue.getDescription());
  }
View Full Code Here

  }

  @Test
  public void testCreatedOn() throws IOException, JSONException {
    List<Issue> redmine11Issues = loadRedmine11Issues();
    Issue issue = RedmineTestUtils.findIssueInList(redmine11Issues, 39);
    DateComparator.testLongDate(2011, Calendar.FEBRUARY, 12, 16, 0, 31,
        "GMT-8", issue.getCreatedOn());
  }
View Full Code Here

  }

  @Test
  public void testUpdatedOn() throws IOException, JSONException {
    List<Issue> redmine11Issues = loadRedmine11Issues();
    Issue issue = RedmineTestUtils.findIssueInList(redmine11Issues, 39);
    DateComparator.testLongDate(2011, Calendar.SEPTEMBER, 17, 21, 28, 45,
        "GMT-8", issue.getUpdatedOn());
  }
View Full Code Here

      String str = MyIOUtils
          .getResourceAsString("issue/redmine_1.2.2_dev_issues.json");
      List<Issue> issues = JsonInput.getListOrEmpty(
          RedmineJSONParser.getResponse(str), "issues",
          RedmineJSONParser.ISSUE_PARSER);
      Issue issue = RedmineTestUtils.findIssueInList(issues, 4808);
      assertNull(issue.getEstimatedHours());
      Issue issue1 = RedmineTestUtils.findIssueInList(issues, 4809);
      assertNull(issue1.getEstimatedHours());
    } catch (Exception e) {
      e.printStackTrace();
      fail("Error:" + e);
    }
  }
View Full Code Here

    return result;
  }

  @SuppressWarnings("deprecation")
  public static Issue parseIssue(JSONObject content) throws JSONException {
    final Issue result = IssueFactory.create(JsonInput.getIntOrNull(content, "id"));
    result.setSubject(JsonInput.getStringOrNull(content, "subject"));
    final JSONObject parentIssueObject = JsonInput.getObjectOrNull(content,
        "parent");
    if (parentIssueObject != null)
      result.setParentId(JsonInput.getInt(parentIssueObject, "id"));
    result.setEstimatedHours(JsonInput.getFloatOrNull(content,
        "estimated_hours"));
    result.setSpentHours(JsonInput.getFloatOrNull(content, "spent_hours"));
    result.setAssignee(JsonInput.getObjectOrNull(content, "assigned_to",
        USER_PARSER));

    final JSONObject priorityObject = JsonInput.getObjectOrNull(content,
        "priority");
    if (priorityObject != null) {
      result.setPriorityText(JsonInput.getStringOrNull(priorityObject,
          "name"));
      result.setPriorityId(JsonInput.getIntOrNull(priorityObject, "id"));
    }

    result.setDoneRatio(JsonInput.getIntOrNull(content, "done_ratio"));
    result.setProject(JsonInput.getObjectOrNull(content, "project",
        MINIMAL_PROJECT_PARSER));
    result.setAuthor(JsonInput.getObjectOrNull(content, "author",
        USER_PARSER));
    result.setStartDate(getShortDateOrNull(content, "start_date"));
    result.setDueDate(getShortDateOrNull(content, "due_date"));
    result.setTracker(JsonInput.getObjectOrNull(content, "tracker",
        TRACKER_PARSER));
    result.setDescription(JsonInput
        .getStringOrEmpty(content, "description"));
    result.setCreatedOn(getDateOrNull(content, "created_on"));
    result.setUpdatedOn(getDateOrNull(content, "updated_on"));
    final JSONObject statusObject = JsonInput.getObjectOrNull(content,
        "status");
    if (statusObject != null) {
      result.setStatusName(JsonInput
          .getStringOrNull(statusObject, "name"));
      result.setStatusId(JsonInput.getIntOrNull(statusObject, "id"));
    }

    result.addCustomFields(JsonInput.getListOrEmpty(content,
        "custom_fields", CUSTOM_FIELD_PARSER));
    result.setNotes(JsonInput.getStringOrNull(content, "notes"));
    result.addJournals(JsonInput.getListOrEmpty(content, "journals",
        JOURNAL_PARSER));
    result.addAttachments(
        JsonInput.getListOrEmpty(content, "attachments",
            ATTACHMENT_PARSER));
    result.addRelations(JsonInput.getListOrEmpty(content, "relations", RELATION_PARSER));
    result.setTargetVersion(JsonInput.getObjectOrNull(content, "fixed_version", VERSION_PARSER));
    result.setCategory(JsonInput.getObjectOrNull(content, "category",
        CATEGORY_PARSER));
    result.addChangesets(JsonInput.getListOrEmpty(content, "changesets",
        CHANGESET_PARSER));
    result.addWatchers(JsonInput.getListOrEmpty(content, "watchers",
        WATCHER_PARSER));
    return result;
  }
View Full Code Here

    }

    @Test
    public void issueCreated() {
        try {
            Issue issueToCreate = IssueFactory.createWithSubject("test zzx");

            Calendar startCal = Calendar.getInstance();
            // have to clear them because they are ignored by Redmine and
            // prevent from comparison later
            startCal.clear(Calendar.HOUR_OF_DAY);
            startCal.clear(Calendar.MINUTE);
            startCal.clear(Calendar.SECOND);
            startCal.clear(Calendar.MILLISECOND);

            startCal.add(Calendar.DATE, 5);
            issueToCreate.setStartDate(startCal.getTime());

            Calendar due = Calendar.getInstance();
            due.add(Calendar.MONTH, 1);
            issueToCreate.setDueDate(due.getTime());
            User assignee = IntegrationTestHelper.getOurUser();
            issueToCreate.setAssignee(assignee);

            String description = "This is the description for the new task."
                    + "\nIt has several lines." + "\nThis is the last line.";
            issueToCreate.setDescription(description);

            float estimatedHours = 44;
            issueToCreate.setEstimatedHours(estimatedHours);

            Issue newIssue = issueManager.createIssue(projectKey, issueToCreate);
            assertNotNull("Checking returned result", newIssue);
            assertNotNull("New issue must have some ID",
                    newIssue.getId());

            // check startDate
            Calendar returnedStartCal = Calendar.getInstance();
            returnedStartCal.setTime(newIssue.getStartDate());

            assertEquals(startCal.get(Calendar.YEAR),
                    returnedStartCal.get(Calendar.YEAR));
            assertEquals(startCal.get(Calendar.MONTH),
                    returnedStartCal.get(Calendar.MONTH));
            assertEquals(startCal.get(Calendar.DAY_OF_MONTH),
                    returnedStartCal.get(Calendar.DAY_OF_MONTH));

            // check dueDate
            Calendar returnedDueCal = Calendar.getInstance();
            returnedDueCal.setTime(newIssue.getDueDate());

            assertEquals(due.get(Calendar.YEAR),
                    returnedDueCal.get(Calendar.YEAR));
            assertEquals(due.get(Calendar.MONTH),
                    returnedDueCal.get(Calendar.MONTH));
            assertEquals(due.get(Calendar.DAY_OF_MONTH),
                    returnedDueCal.get(Calendar.DAY_OF_MONTH));

            // check ASSIGNEE
            User actualAssignee = newIssue.getAssignee();
            assertNotNull("Checking assignee not null", actualAssignee);
            assertEquals("Checking assignee id", assignee.getId(),
                    actualAssignee.getId());

            // check AUTHOR
            Integer EXPECTED_AUTHOR_ID = IntegrationTestHelper.getOurUser().getId();
            assertEquals(EXPECTED_AUTHOR_ID, newIssue.getAuthor()
                    .getId());

            // check ESTIMATED TIME
            assertEquals((Float) estimatedHours,
                    newIssue.getEstimatedHours());

            // check multi-line DESCRIPTION
            String regexpStripExtra = "\\r|\\n|\\s";
            description = description.replaceAll(regexpStripExtra, "");
            String actualDescription = newIssue.getDescription();
            actualDescription = actualDescription.replaceAll(regexpStripExtra,
                    "");
            assertEquals(description, actualDescription);

            // PRIORITY
            assertNotNull(newIssue.getPriorityId());
            assertTrue(newIssue.getPriorityId() > 0);
        } catch (Exception e) {
            e.printStackTrace();
            fail();
        }
    }
View Full Code Here

    }

    @Test
    public void issueWithParentCreated() {
        try {
            Issue parentIssue = IssueFactory.createWithSubject("parent 1");
            Issue newParentIssue = issueManager.createIssue(projectKey, parentIssue);

            assertNotNull("Checking parent was created", newParentIssue);
            assertNotNull("Checking ID of parent issue is not null",
                    newParentIssue.getId());

            // Integer parentId = 46;
            Integer parentId = newParentIssue.getId();

            Issue childIssue = IssueFactory.createWithSubject("child 1");
            childIssue.setParentId(parentId);

            Issue newChildIssue = issueManager.createIssue(projectKey, childIssue);

            assertEquals("Checking parent ID of the child issue",
                    parentId, newChildIssue.getParentId());

        } catch (Exception e) {
            e.printStackTrace();
            fail();
        }
View Full Code Here

    @Test
    public void testUpdateIssue() {
        try {
            String originalSubject = "Issue " + new Date();
            Issue issue = IssueFactory.createWithSubject(originalSubject);

            Issue newIssue = issueManager.createIssue(projectKey, issue);
            String changedSubject = "changed subject";
            newIssue.setSubject(changedSubject);

            issueManager.update(newIssue);

            Issue reloadedFromRedmineIssue = issueManager.getIssueById(newIssue.getId());

            assertEquals(
                    "Checking if 'update issue' operation changed the 'subject' field",
                    changedSubject, reloadedFromRedmineIssue.getSubject());
        } catch (Exception e) {
            e.printStackTrace();
            fail();
        }
    }
View Full Code Here

     *                                        thrown in case the objects requested for could not be found
     */
    @Test
    public void testGetIssueById() throws RedmineException {
        String originalSubject = "Issue " + new Date();
        Issue issue = IssueFactory.createWithSubject(originalSubject);

        Issue newIssue = issueManager.createIssue(projectKey, issue);

        Issue reloadedFromRedmineIssue = issueManager.getIssueById(newIssue.getId());

        assertEquals(
                "Checking if 'get issue by ID' operation returned issue with same 'subject' field",
                originalSubject, reloadedFromRedmineIssue.getSubject());
        Tracker tracker = reloadedFromRedmineIssue.getTracker();
        assertNotNull("Tracker of issue should not be null", tracker);
        assertNotNull("ID of tracker of issue should not be null",
                tracker.getId());
        assertNotNull("Name of tracker of issue should not be null",
                tracker.getName());
View Full Code Here

TOP

Related Classes of com.taskadapter.redmineapi.bean.Issue

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.