Package fm.last.citrine.model

Examples of fm.last.citrine.model.Task


    taskFormController.setTaskManager(mockTaskManager);
  }

  @Test
  public void testDelete() {
    Task task = new Task();
    task.setId(345);
    TaskDTO dto = new TaskDTO(task);
    when(mockTaskManager.get(task.getId())).thenReturn(task);
    BindException bindException = new BindException(dto, "bla");
    mockRequest.addParameter(Constants.PARAM_DELETE, "true");
    ModelAndView modelAndView = taskFormController.onSubmit(mockRequest, mockResponse, dto, bindException);
    RedirectView view = (RedirectView) modelAndView.getView();
    assertEquals("tasks.do?selectedGroupName=" + Constants.GROUP_NAME_ALL, view.getUrl());
View Full Code Here


   *
   * @throws InterruptedException
   */
  @Test(timeout = DEFAULT_TEST_TIMEOUT)
  public void testRunNow_InvalidCommand() throws InterruptedException {
    Task task = new Task("name", "groupName", "sysExecJob", false, true, "invalidcommand", defaultTimerSchedule);
    taskManager.save(task);
    schedulerManager.runTaskNow(task);
    waitForTask(task);
    List<TaskRun> taskRuns = taskRunManager.findByTaskId(task.getId());
    assertEquals(1, taskRuns.size());
    TaskRun taskRun = taskRuns.get(0);
    assertEquals(Status.FAILED, taskRun.getStatus());

    // only stack trace should be filled in
View Full Code Here

   *
   * @throws InterruptedException
   */
  @Test(timeout = DEFAULT_TEST_TIMEOUT)
  public void testRunNow_FailureWhileRunning() throws InterruptedException {
    Task task = new Task("name", "groupName", "sysExecJob", false, true, "ls -l23frx", defaultTimerSchedule);
    taskManager.save(task);
    schedulerManager.runTaskNow(task);
    waitForTask(task);
    List<TaskRun> taskRuns = taskRunManager.findByTaskId(task.getId());
    assertEquals(1, taskRuns.size());
    TaskRun taskRun = taskRuns.get(0);
    assertEquals(Status.FAILED, taskRun.getStatus());

    // stack trace and sys err should be filled in
View Full Code Here

  /**
   * Tests that changing a TaskRun's status ends up with the expected number of notifications being sent.
   */
  @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());
View Full Code Here

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

  @Test
  public void testStartAndFinish_SuccessWithDisabledChild() throws InterruptedException {
    Task childTask = new Task("taskRunManagerTestChildTask", "testGroup", "", false, true, "", "");
    taskManager.save(childTask);
    testTask.addChildTask(childTask);
    taskManager.save(testTask);

    JobExecutionContext context = createJobExecutionContext(testTask);
    taskRunManager.jobToBeExecuted(context);
    taskRunManager.jobWasExecuted(context, null);
    Thread.sleep(1000); // give scheduler time to start child

    // child is not enabled so no task run should be created for it when parent finishes
    assertNull(taskRunManager.getMostRecent(childTask.getId()));
  }
View Full Code Here

    assertNull(taskRunManager.getMostRecent(childTask.getId()));
  }

  @Test
  public void testStartAndFinish_SuccessWithEnabledChild() throws InterruptedException {
    Task childTask = new Task("taskRunManagerTestChildTask", "testGroup", "nullJob", true, true, "", "");
    taskManager.save(childTask);
    testTask.addChildTask(childTask);
    taskManager.save(testTask);

    JobExecutionContext context = createJobExecutionContext(testTask);
    taskRunManager.jobToBeExecuted(context);
    taskRunManager.jobWasExecuted(context, null);
    Thread.sleep(1000); // give scheduler time to start child

    assertNotNull(taskRunManager.getMostRecent(childTask.getId())); // child enabled so it should be triggered
  }
View Full Code Here

    assertNotNull(taskRunManager.getMostRecent(childTask.getId())); // child enabled so it should be triggered
  }

  @Test
  public void testStartAndFinish_FailureWithChild() throws InterruptedException {
    Task childTask = new Task("taskRunManagerTestChildTask", "testGroup", "nullJob", true, true, "", "");
    taskManager.save(childTask);
    testTask.addChildTask(childTask);
    taskManager.save(testTask);

    JobExecutionContext context = createJobExecutionContext(testTask);
    taskRunManager.jobToBeExecuted(context);
    taskRunManager.jobWasExecuted(context, new JobExecutionException());
    Thread.sleep(1000); // give scheduler time to start child

    assertNull(taskRunManager.getMostRecent(childTask.getId())); // parent failed so child should not run
  }
View Full Code Here

  @Test
  public void testStartAndFinish_FailureNoStopOnErrorWithChild() throws InterruptedException {
    testTask.setStopOnError(false);
    taskManager.save(testTask);

    Task childTask = new Task("taskRunManagerTestChildTask", "testGroup", "nullJob", true, true, "", "");
    taskManager.save(childTask);
    testTask.addChildTask(childTask);
    taskManager.save(testTask);

    JobExecutionContext context = createJobExecutionContext(testTask);
    taskRunManager.jobToBeExecuted(context);
    taskRunManager.jobWasExecuted(context, new JobExecutionException());
    Thread.sleep(1500); // give scheduler time to start child

    // parent failed but not set to stop on error so child should run
    assertNotNull(taskRunManager.getMostRecent(childTask.getId()));
  }
View Full Code Here

  @Test
  public void testStartAndCancel_WithChild() throws InterruptedException {
    testTask.setStopOnError(false); // ensure there is no other reason for parent stopping child
    taskManager.save(testTask);

    Task childTask = new Task("taskRunManagerTestChildTask", "testGroup", "nullJob", true, true, "", "");
    taskManager.save(childTask);
    testTask.addChildTask(childTask);
    taskManager.save(testTask);

    JobExecutionContext context = createJobExecutionContext(testTask);
    taskRunManager.jobToBeExecuted(context);

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

    taskRunManager.stop(taskRun.getId());
    taskRun = taskRunManager.get(taskRun.getId());
    taskRunManager.jobWasExecuted(context, new JobExecutionException());
    assertFalse(taskRunManager.isRunning(taskRun.getTaskId()));

    Thread.sleep(1000); // give scheduler time to start child

    // parent was cancelled, so no child should run
    assertNull(taskRunManager.getMostRecent(childTask.getId()));
  }
View Full Code Here

  /**
   * Convenience method for creating a set of Task where Task 1 has 2 children - 2 and 3, and 2 and 3 in turn have the
   * same child, 4.
   */
  private void createChildParentTasks() {
    task1 = new Task("TaskDAOTest1", "childTest", "1", false, true, "1", defaultTimerSchedule);
    taskDAO.save(task1);
    task2 = new Task("TaskDAOTest2", "childTest", "2", false, true, "2", defaultTimerSchedule);
    taskDAO.save(task2);
    task3 = new Task("TaskDAOTest3", "childTest", "3", false, true, "3", defaultTimerSchedule);
    taskDAO.save(task3);
    task4 = new Task("TaskDAOTest4", "childTest", "4", false, true, "4", defaultTimerSchedule);
    taskDAO.save(task4);

    task1.addChildTask(task2);
    task1.addChildTask(task3);
    taskDAO.save(task1);
View Full Code Here

TOP

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

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.