@Test
 public void testParseIssueNonUnicodeSymbols() throws IOException, JSONException {
   String json = MyIOUtils.getResourceAsString("issues_foreign_symbols.json");
   String nonLatinAccentSymbols = "Accent symbols: Ação";
   String nonLatinRussianSymbols = "Russian symbols: Привет";
   List<Issue> issues =
       JsonInput.getListOrEmpty(
           RedmineJSONParser.getResponse(json), "issues", RedmineJSONParser.ISSUE_PARSER);
   // must be 2 issues in the file
   Assert.assertTrue(issues.size() == 2);
   assertNotNull(RedmineTestUtils.findIssueInList(issues, nonLatinRussianSymbols));
   assertNotNull(RedmineTestUtils.findIssueInList(issues, nonLatinAccentSymbols));
 }
 /**
  * regression test for http://code.google.com/p/redmine-java-api/issues/detail?id=91 with Redmine
  * 1.3.0: NULL value returned by getIssues call is interpreted as 0.0
  */
 @Test
 public void nullEstimatedTimeProcessedCorrectlyWithRedmine122() {
   try {
     String str = MyIOUtils.getResourceAsString("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();
     Assert.fail("Error:" + e);
   }
 }
 @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());
 }
 @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());
 }
 @Test
 public void testParseDescription() {
   try {
     List<Issue> issues = loadRedmine11Issues();
     Issue issue65 = RedmineTestUtils.findIssueInList(issues, 65);
     Assert.assertTrue(
         issue65.getDescription().startsWith("This is the description for the new task."));
     Assert.assertTrue(issue65.getDescription().endsWith("This is the last line."));
   } catch (Exception e) {
     Assert.fail(e.getMessage());
   }
 }
  @Test
  public void estimatedTimeIsNULL() throws JSONException {
    try {
      List<Issue> issues = loadRedmine11Issues();
      Integer issueID = 52;
      Issue issue52 = RedmineTestUtils.findIssueInList(issues, issueID);
      Assert.assertNotNull(issue52);

      // must be NULL and not "0"
      Assert.assertNull("estimated time must be null", issue52.getEstimatedHours());
    } catch (IOException e) {
      Assert.fail(e.getMessage());
    }
  }
  @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());
  }
  @Test
  public void testParseTimeEntries() throws IOException, JSONException {
    String xml = MyIOUtils.getResourceAsString("redmine_time_entries.json");
    List<TimeEntry> objects =
        JsonInput.getListOrEmpty(
            RedmineJSONParser.getResponse(xml),
            "time_entries",
            RedmineJSONParser.TIME_ENTRY_PARSER);
    Integer objId = 2;
    TimeEntry obj2 = RedmineTestUtils.findTimeEntry(objects, objId);
    Assert.assertNotNull(obj2);

    Integer expectedIssueId = 44;
    String expectedProjectName = "Permanent test project for Task Adapter";
    Integer expectedProjectId = 1;
    String expectedUserName = "******";
    Integer expectedUserId = 1;
    String expectedActivityName = "Design";
    Integer expectedActivityId = 8;
    Float expectedHours = 2f;

    Assert.assertEquals(objId, obj2.getId());
    Assert.assertEquals(expectedIssueId, obj2.getIssueId());
    Assert.assertEquals(expectedProjectName, obj2.getProjectName());
    Assert.assertEquals(expectedProjectId, obj2.getProjectId());
    Assert.assertEquals(expectedUserName, obj2.getUserName());
    Assert.assertEquals(expectedUserId, obj2.getUserId());
    Assert.assertEquals(expectedActivityName, obj2.getActivityName());
    Assert.assertEquals(expectedActivityId, obj2.getActivityId());
    Assert.assertEquals(expectedHours, obj2.getHours());
    Assert.assertEquals("spent 2 hours working on ABC", obj2.getComment());

    DateComparator.testLongDate(
        2011, Calendar.JANUARY, 31, 11, 10, 40, "GMT-8", obj2.getCreatedOn());
    DateComparator.testLongDate(
        2011, Calendar.JANUARY, 31, 11, 12, 32, "GMT-8", obj2.getUpdatedOn());

    DateComparator.testShortDate(2011, Calendar.JANUARY, 30, obj2.getSpentOn());
  }