use of com.synopsys.integration.alert.api.task.ScheduledTask in project hub-alert by blackducksoftware.
the class TaskManagerTest method testGetDifferenceToNextRunTime.
@Test
public void testGetDifferenceToNextRunTime() {
ScheduledTask task = Mockito.mock(ScheduledTask.class);
final String taskName = "a_task";
Mockito.when(task.getTaskName()).thenReturn(taskName);
Mockito.when(task.getMillisecondsToNextRun()).thenReturn(Optional.of(999L));
TaskManager taskManager = new TaskManager();
taskManager.registerTask(task);
taskManager.getDifferenceToNextRun(taskName, TimeUnit.SECONDS);
Mockito.verify(task).getMillisecondsToNextRun();
}
use of com.synopsys.integration.alert.api.task.ScheduledTask in project hub-alert by blackducksoftware.
the class TaskManagerTest method testGetNextRunTimeForUnknownTask.
@Test
public void testGetNextRunTimeForUnknownTask() {
ScheduledTask task = Mockito.mock(ScheduledTask.class);
final String taskName = "a_task";
Mockito.when(task.getTaskName()).thenReturn(taskName);
TaskManager taskManager = new TaskManager();
taskManager.registerTask(task);
taskManager.getNextRunTime("unknown_task");
Mockito.verify(task, Mockito.times(0)).getFormatedNextRunTime();
taskManager.getNextRunTime(null);
Mockito.verify(task, Mockito.times(0)).getFormatedNextRunTime();
}
use of com.synopsys.integration.alert.api.task.ScheduledTask in project hub-alert by blackducksoftware.
the class TaskManagerTest method testUnschedule.
@Test
public void testUnschedule() {
ScheduledTask task = Mockito.mock(ScheduledTask.class);
final String taskName = "a_task";
final String cronExpression = "cron_expression";
Mockito.when(task.getTaskName()).thenReturn(taskName);
TaskManager taskManager = new TaskManager();
taskManager.registerTask(task);
taskManager.scheduleCronTask(cronExpression, taskName);
Mockito.verify(task).scheduleExecution(Mockito.anyString());
assertFalse(taskManager.unScheduleTask("unknown_task"));
assertTrue(taskManager.unScheduleTask(taskName));
}
use of com.synopsys.integration.alert.api.task.ScheduledTask in project hub-alert by blackducksoftware.
the class TaskManagerTest method testGetDifferenceToNextRunTimeForUnknownTask.
@Test
public void testGetDifferenceToNextRunTimeForUnknownTask() {
ScheduledTask task = Mockito.mock(ScheduledTask.class);
final String taskName = "a_task";
Mockito.when(task.getTaskName()).thenReturn(taskName);
Mockito.when(task.getMillisecondsToNextRun()).thenReturn(Optional.of(999L));
TaskManager taskManager = new TaskManager();
taskManager.registerTask(task);
taskManager.getDifferenceToNextRun("unknown_task", TimeUnit.SECONDS);
Mockito.verify(task, Mockito.times(0)).getMillisecondsToNextRun();
taskManager.getDifferenceToNextRun(null, TimeUnit.SECONDS);
Mockito.verify(task, Mockito.times(0)).getMillisecondsToNextRun();
}
use of com.synopsys.integration.alert.api.task.ScheduledTask in project hub-alert by blackducksoftware.
the class TaskManagerTest method testScheduleCron.
@Test
public void testScheduleCron() {
ScheduledTask task = Mockito.mock(ScheduledTask.class);
final String taskName = "a_task";
final String cronExpression = "cron_expression";
Mockito.when(task.getTaskName()).thenReturn(taskName);
TaskManager taskManager = new TaskManager();
taskManager.registerTask(task);
taskManager.scheduleCronTask(cronExpression, taskName);
Mockito.verify(task).scheduleExecution(Mockito.anyString());
}
Aggregations