Package fm.last.citrine.model

Examples of fm.last.citrine.model.TaskRun


  @Test
  public void testFormatterSingularForm() {
    DateTime startDate = new DateTime();
    startDate = startDate.minusYears(1).minusMonths(1).minusDays(1).minusHours(1).minusMinutes(1);
    TaskRun mostRecentTaskRun = new TaskRun(startDate.toDate(), startDate.plusHours(8).toDate(), "", "", "", 1);
    String printLastRun = formatter.printLastRun(mostRecentTaskRun);
    assertEquals("1 year, 1 month, 1 day, 1 hour and 1 minute ago", printLastRun);
  }
View Full Code Here


  @Test
  public void testNoAndSeparator() {
    DateTime startDate = new DateTime();
    startDate = startDate.minusHours(2);
    TaskRun mostRecentTaskRun = new TaskRun(startDate.toDate(), startDate.plusHours(8).toDate(), "", "", "", 1);
    String printLastRun = formatter.printLastRun(mostRecentTaskRun);
    assertEquals("2 hours ago", printLastRun);

    startDate = new DateTime();
    startDate = startDate.minusMinutes(1);
    mostRecentTaskRun = new TaskRun(startDate.toDate(), startDate.plusSeconds(8).toDate(), "", "", "", 1);
    printLastRun = formatter.printLastRun(mostRecentTaskRun);
    assertEquals("1 minute ago", printLastRun);
  }
View Full Code Here

  }

  @Test
  public void testTimeWithinOneMinute() {
    DateTime startDate = new DateTime();
    TaskRun mostRecentTaskRun = new TaskRun(startDate.minusSeconds(5).toDate(), startDate.toDate(), "", "", "", 1);
    String printLastRun = formatter.printLastRun(mostRecentTaskRun);
    assertEquals("0 minutes ago", printLastRun);
  }
View Full Code Here

    deleteFromTables(TableConstants.TABLE_TASK_RUNS);
  }

  @Test
  public void testSaveGetAndUpdate() {
    TaskRun taskRun = new TaskRun(Status.SUCCESS, new Date(), new Date(), "out", "err", "stack", 1);
    taskRunDAO.save(taskRun);
    assertTrue(taskRun.getId() > 0);
    assertEquals(0, taskRun.getVersion());

    TaskRun retrieved = taskRunDAO.get(taskRun.getId());
    assertEquals(taskRun, retrieved);

    taskRun.setSysErr("err2");
    taskRunDAO.save(taskRun);

    retrieved = taskRunDAO.get(taskRun.getId());
    assertEquals("err2", retrieved.getSysErr());
  }
View Full Code Here

  @Test
  public void testFindByTaskId() {
    assertEquals(0, taskRunDAO.findByTaskId(1).size()); // initially should be none in db

    // save two task runs against id 1
    TaskRun taskRun = new TaskRun(Status.SUCCESS, new Date(), new Date(), "out", "err", "stack", 1);
    taskRunDAO.save(taskRun);
    TaskRun taskRun2 = new TaskRun(Status.SUCCESS, new Date(), new Date(), "out", "err", "stack", 1);
    taskRunDAO.save(taskRun2);
    // save one task run against id 2
    TaskRun taskRun3 = new TaskRun(Status.SUCCESS, new Date(), new Date(), "out", "err", "stack", 2);
    taskRunDAO.save(taskRun3);

    List<TaskRun> task1Tasks = taskRunDAO.findByTaskId(1);
    assertEquals(2, task1Tasks.size());
    // test ordering
View Full Code Here

    taskRunDAO.setMaxTaskRunResults(currentMaxResults); // reset back to original value
  }

  @Test
  public void testDelete() {
    TaskRun taskRun = new TaskRun(Status.SUCCESS, new Date(), new Date(), "out", "err", "stack", 1);
    taskRunDAO.save(taskRun);
    assertEquals(1, taskRunDAO.findByTaskId(1).size());
    taskRunDAO.delete(taskRun.getId());
    assertEquals(0, taskRunDAO.findByTaskId(1).size());
  }
View Full Code Here

    assertEquals(0, taskRunDAO.findByTaskId(1).size());
  }

  @Test
  public void testDeleteByTaskId() {
    TaskRun taskRun1 = new TaskRun(Status.SUCCESS, new Date(), new Date(), "out", "err", "stack", 1);
    TaskRun taskRun2 = new TaskRun(Status.SUCCESS, new Date(), new Date(), "out", "err", "stack", 1);
    TaskRun taskRun3 = new TaskRun(Status.SUCCESS, new Date(), new Date(), "out", "err", "stack", 2);
    taskRunDAO.save(taskRun1);
    taskRunDAO.save(taskRun2);
    taskRunDAO.save(taskRun3);
    taskRunDAO.deleteByTaskId(1);
    assertEquals(0, taskRunDAO.findByTaskId(1).size());
View Full Code Here

  }

  @Test
  public void testIsRunning() {
    // for task id 1, put all finished status
    TaskRun taskRun1 = new TaskRun(Status.SUCCESS, new Date(), new Date(), "out", "err", "stack", 1);
    TaskRun taskRun2 = new TaskRun(Status.CANCELLED, new Date(), new Date(), "out", "err", "stack", 1);
    TaskRun taskRun3 = new TaskRun(Status.FAILED, new Date(), new Date(), "out", "err", "stack", 1);

    // for task id 2, put 1 run with status running
    TaskRun taskRun4 = new TaskRun(Status.SUCCESS, new Date(), new Date(), "out", "err", "stack", 2);
    TaskRun taskRun5 = new TaskRun(Status.RUNNING, new Date(), new Date(), "out", "err", "stack", 2);

    // for task id 2, put 1 run with status initialising
    TaskRun taskRun6 = new TaskRun(Status.INITIALISING, new Date(), new Date(), "out", "err", "stack", 3);

    taskRunDAO.save(taskRun1);
    taskRunDAO.save(taskRun2);
    taskRunDAO.save(taskRun3);
    taskRunDAO.save(taskRun4);
View Full Code Here

    assertTrue(taskRunDAO.isRunning(3));
  }

  @Test
  public void testInterruptRunningTasks() {
    TaskRun taskRun1 = new TaskRun(Status.SUCCESS, new Date(), new Date(), "out", "err", "stack", 1);
    TaskRun taskRun2 = new TaskRun(Status.CANCELLED, new Date(), new Date(), "out", "err", "stack", 1);
    TaskRun taskRun3 = new TaskRun(Status.FAILED, new Date(), new Date(), "out", "err", "stack", 1);
    TaskRun taskRun4 = new TaskRun(Status.INTERRUPTED, new Date(), new Date(), "out", "err", "stack", 2);
    TaskRun taskRun5 = new TaskRun(Status.RUNNING, new Date(), new Date(), "out", "err", "stack", 2);
    TaskRun taskRun6 = new TaskRun(Status.INITIALISING, new Date(), new Date(), "out", "err", "stack", 3);
    TaskRun taskRun7 = new TaskRun(Status.CANCELLING, new Date(), new Date(), "out", "err", "stack", 3);
    taskRunDAO.save(taskRun1);
    taskRunDAO.save(taskRun2);
    taskRunDAO.save(taskRun3);
    taskRunDAO.save(taskRun4);
    taskRunDAO.save(taskRun5);
    taskRunDAO.save(taskRun6);
    taskRunDAO.save(taskRun7);
    taskRunDAO.setInterruptedStatus();
    assertEquals(Status.SUCCESS, taskRunDAO.get(taskRun1.getId()).getStatus());
    assertEquals(Status.CANCELLED, taskRunDAO.get(taskRun2.getId()).getStatus());
    assertEquals(Status.FAILED, taskRunDAO.get(taskRun3.getId()).getStatus());
    assertEquals(Status.INTERRUPTED, taskRunDAO.get(taskRun4.getId()).getStatus());
    assertEquals(Status.INTERRUPTED, taskRunDAO.get(taskRun5.getId()).getStatus());
    assertEquals(Status.INTERRUPTED, taskRunDAO.get(taskRun6.getId()).getStatus());
    assertEquals(Status.INTERRUPTED, taskRunDAO.get(taskRun7.getId()).getStatus());
  }
View Full Code Here

   */
  @Test
  public void testGetMostRecentTaskRun() {
    Calendar calendar = Calendar.getInstance();
    Date now = new Date();
    TaskRun taskRun1 = new TaskRun(Status.RUNNING, now, null, null, null, null, 1);
    calendar.set(2005, 11, 27);
    TaskRun taskRun2 = new TaskRun(Status.SUCCESS, calendar.getTime(), calendar.getTime(), "out", "err", "stack", 1);
    calendar.set(2006, 11, 27);
    TaskRun taskRun3 = new TaskRun(Status.FAILED, calendar.getTime(), calendar.getTime(), "out", "err", "stack", 1);
    // same start date but different task id
    TaskRun taskRun4 = new TaskRun(Status.RUNNING, now, null, "out", "err", "stack", 2);
    taskRunDAO.save(taskRun2);
    taskRunDAO.save(taskRun1); // put save in middle so it's id is not necessarily first/last
    taskRunDAO.save(taskRun3);
    taskRunDAO.save(taskRun4);
    TaskRun retrieved = taskRunDAO.getMostRecentTaskRun(1);
    assertEquals(taskRun1, retrieved);
  }
View Full Code Here

TOP

Related Classes of fm.last.citrine.model.TaskRun

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.