Package fm.last.citrine.model

Examples of fm.last.citrine.model.TaskRun


    assertEquals(taskRun1, retrieved);
  }

  @Test
  public void testFindByTaskId_FirstAndMax() {
    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.SUCCESS, new Date(), new Date(), "out", "err", "stack", 1);
    TaskRun taskRun5 = new TaskRun(Status.RUNNING, new Date(), new Date(), "out", "err", "stack", 1);
    TaskRun taskRun6 = new TaskRun(Status.INITIALISING, new Date(), new Date(), "out", "err", "stack", 1);

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


    DateTime tenDaysAgo = now.minusDays(10);
    DateTime twentyDaysAgo = now.minusDays(20);
    DateTime thirtyDaysAgo = now.minusDays(30);

    int taskId = 1;
    TaskRun taskRun1 = new TaskRun(Status.SUCCESS, now.toDate(), now.toDate(), "out", "err", "stack", taskId);
    TaskRun taskRun2 = new TaskRun(Status.SUCCESS, threeDaysAgo.toDate(), now.toDate(), "out", "err", "stack", taskId);
    TaskRun taskRun3 = new TaskRun(Status.SUCCESS, tenDaysAgo.toDate(), threeDaysAgo.toDate(), "out", "err", "stack",
        taskId);
    TaskRun taskRun4 = new TaskRun(Status.SUCCESS, twentyDaysAgo.toDate(), tenDaysAgo.toDate(), "out", "err", "stack",
        taskId);

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

  @Test(expected = JobExecutionException.class)
  public void testDeleteTaskRunsBefore() throws JobExecutionException {
    DateTime runTime = new DateTime().minusDays(5);
    int taskId = 1;
    TaskRun taskRun = new TaskRun(runTime.toDate(), runTime.toDate(), "", "", "", taskId);
    taskRunManager.save(taskRun);
    // delete everything older than 1 day, shouldn't delete anything
    jobDetail.getJobDataMap().put(SchedulerConstants.TASK_COMMAND, "1");
    adminJob.execute(context);
    assertEquals(1, taskRunManager.findByTaskId(taskId));
View Full Code Here

    testTaskId = testTask.getId();
  }

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

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

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

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

  @Test
  public void testFindByTaskId() {
    assertEquals(0, taskRunManager.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);
    taskRunManager.save(taskRun);
    TaskRun taskRun2 = new TaskRun(Status.SUCCESS, new Date(), new Date(), "out", "err", "stack", 1);
    taskRunManager.save(taskRun2);
    // save one taskrun against id 2
    TaskRun taskRun3 = new TaskRun(Status.SUCCESS, new Date(), new Date(), "out", "err", "stack", 2);
    taskRunManager.save(taskRun3);

    assertEquals(2, taskRunManager.findByTaskId(1).size());
  }
View Full Code Here

  @Test
  public void testSetTaskRunStatus() {
    Task task = new Task("name", "group", "");
    task.setNotification(new Notification());
    taskManager.save(task);
    TaskRun taskRun = new TaskRun(new Date(), new Date(), "out", "err", "stack", task.getId());
   
    int mailCount = 0;
    // no mail should be sent for following
    taskRunManager.setStatus(taskRun, Status.INITIALISING);
    assertEquals(mailCount, mailSender.getMessageCount());
    assertEquals(Status.INITIALISING, taskRun.getStatus());
    taskRunManager.setStatus(taskRun, Status.RUNNING);
    assertEquals(mailCount, mailSender.getMessageCount());
    assertEquals(Status.RUNNING, taskRun.getStatus());
    taskRunManager.setStatus(taskRun, Status.CANCELLING);
    assertEquals(mailCount, mailSender.getMessageCount());
    assertEquals(Status.CANCELLING, taskRun.getStatus());

    // mail should be sent for following
    taskRunManager.setStatus(taskRun, Status.SUCCESS);
    assertEquals(++mailCount, mailSender.getMessageCount());
    assertEquals(Status.SUCCESS, taskRun.getStatus());
    taskRunManager.setStatus(taskRun, Status.CANCELLED);
    assertEquals(++mailCount, mailSender.getMessageCount());
    assertEquals(Status.CANCELLED, taskRun.getStatus());
    taskRunManager.setStatus(taskRun, Status.INTERRUPTED);
    assertEquals(++mailCount, mailSender.getMessageCount());
    assertEquals(Status.INTERRUPTED, taskRun.getStatus());
    taskRunManager.setStatus(taskRun, Status.ABORTED);
    assertEquals(++mailCount, mailSender.getMessageCount());
    assertEquals(Status.ABORTED, taskRun.getStatus());
    taskRunManager.setStatus(taskRun, Status.FAILED);
    assertEquals(++mailCount, mailSender.getMessageCount());
    assertEquals(Status.FAILED, taskRun.getStatus());
  }
View Full Code Here

    assertEquals(Status.FAILED, taskRun.getStatus());
  }

  @Test
  public void testShutdown() {
    TaskRun taskRun = new TaskRun(Status.RUNNING, new Date(), new Date(), null, null, null, 1);
    taskRunManager.save(taskRun);
    taskRun = new TaskRun(Status.INITIALISING, new Date(), new Date(), null, null, null, 1);
    taskRunManager.save(taskRun);
    taskRunManager.shutdown();
    List<TaskRun> taskRuns = taskRunManager.findByTaskId(1);
    assertEquals(2, taskRuns.size());
    assertEquals(Status.INTERRUPTED, taskRuns.get(0).getStatus());
View Full Code Here

  @Test
  public void testStartAndFinish_Success() {
    JobExecutionContext context = createJobExecutionContext(testTask);
    taskRunManager.jobToBeExecuted(context);

    TaskRun taskRun = taskRunManager.getMostRecent(testTaskId);
    assertTrue(taskRunManager.isRunning(taskRun.getTaskId()));

    taskRunManager.jobWasExecuted(context, null);
    assertFalse(taskRunManager.isRunning(taskRun.getTaskId()));
    taskRun = taskRunManager.get(taskRun.getId());
    assertEquals(Status.SUCCESS, taskRun.getStatus());
  }
View Full Code Here

  }

  @Test
  public void testGetDisplayLogUrlNoBaseUrl() {
    notifier.setBaseCitrineUrl(null);
    TaskRun taskRun = new TaskRun();
    taskRun.setId(1);
    assertEquals(null, notifier.getDisplayLogUrl(taskRun));
  }
View Full Code Here

  @Test
  public void testStartAndFinish_Failure() {
    JobExecutionContext context = createJobExecutionContext(testTask);
    taskRunManager.jobToBeExecuted(context);

    TaskRun taskRun = taskRunManager.getMostRecent(testTaskId);
    assertTrue(taskRunManager.isRunning(taskRun.getTaskId()));

    taskRunManager.jobWasExecuted(context, new JobExecutionException());
    assertFalse(taskRunManager.isRunning(taskRun.getTaskId()));
    taskRun = taskRunManager.get(taskRun.getId());
    assertEquals(Status.FAILED, taskRun.getStatus());
  }
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.