Example #1
0
 private static void generateXMLForTimeEntry() {
   TimeEntry o = new TimeEntry();
   o.setId(13);
   o.setIssueId(45);
   o.setActivityId(3);
   o.setProjectId(55);
   o.setUserId(66);
   o.setHours(123f);
   o.setComment("text here");
   o.setSpentOn(new Date());
   String xml = RedmineXMLGenerator.toXML(o);
   logger.debug(xml);
 }
  @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());
  }