Ejemplo n.º 1
0
 @AfterClass
 public static void afterClass() throws Exception {
   jToggl.destroyTimeEntry(timeEntry.getId());
   jToggl.destroyClient(client.getId());
   try {
     jToggl.destroyTask(task.getId());
   } catch (Exception e) {
     // Ignore because Task is only for paying customers
   }
 }
Ejemplo n.º 2
0
  @Test
  public void startStopTimeEntry() throws Exception {
    TimeEntry current = jToggl.getCurrentTimeEntry();
    Assert.assertNull(current);

    TimeEntry timeEntry = new TimeEntry();
    timeEntry.setWorkspace(workspace);
    timeEntry.setProject(project);
    timeEntry.setDescription("ABCD");
    timeEntry.setCreated_with("JToggl Unit Test");

    TimeEntry te = jToggl.startTimeEntry(timeEntry);

    try {
      Assert.assertNotNull(te.getId()); // created
      Assert.assertTrue(te.getDuration() < 0); // running

      current = jToggl.getCurrentTimeEntry();
      Assert.assertNotNull(current);
      Assert.assertEquals(current.getId(), te.getId());

      Thread.sleep(2000);

      TimeEntry stoppedTe = jToggl.stopTimeEntry(te);

      Assert.assertEquals(te.getId(), stoppedTe.getId());
      Assert.assertTrue(stoppedTe.toJSONString(), stoppedTe.getDuration() > 1); // stopped

      current = jToggl.getCurrentTimeEntry();
      Assert.assertNull(current);
    } finally {
      jToggl.destroyTimeEntry(te.getId());
    }
  }
Ejemplo n.º 3
0
  @Test
  public void getTimeEntry() {
    TimeEntry te = jToggl.getTimeEntry(timeEntry.getId());

    Assert.assertNotNull(te);
  }