use of com.synopsys.integration.alert.api.task.TaskManager in project hub-alert by blackducksoftware.
the class TaskManagerTest method testGetNextRunTime.
@Test
public void testGetNextRunTime() {
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(taskName);
Mockito.verify(task).getFormatedNextRunTime();
}
use of com.synopsys.integration.alert.api.task.TaskManager in project hub-alert by blackducksoftware.
the class TaskManagerTest method testScheduleCronForUnknownTask.
@Test
public void testScheduleCronForUnknownTask() {
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, "unknown_task");
Mockito.verify(task, Mockito.times(0)).scheduleExecution(Mockito.anyString());
taskManager.scheduleCronTask(cronExpression, null);
Mockito.verify(task, Mockito.times(0)).scheduleExecution(Mockito.anyString());
}
use of com.synopsys.integration.alert.api.task.TaskManager in project hub-alert by blackducksoftware.
the class TaskManagerTest method testScheduleFixedRate.
@Test
public void testScheduleFixedRate() {
ScheduledTask task = Mockito.mock(ScheduledTask.class);
final String taskName = "a_task";
final long period = 999;
Mockito.when(task.getTaskName()).thenReturn(taskName);
TaskManager taskManager = new TaskManager();
taskManager.registerTask(task);
taskManager.scheduleExecutionAtFixedRate(period, taskName);
Mockito.verify(task).scheduleExecutionAtFixedRate(Mockito.anyLong());
}
use of com.synopsys.integration.alert.api.task.TaskManager in project hub-alert by blackducksoftware.
the class TaskManagerTest method testScheduleFixedRateForUnknownTask.
@Test
public void testScheduleFixedRateForUnknownTask() {
ScheduledTask task = Mockito.mock(ScheduledTask.class);
final String taskName = "a_task";
final long period = 999;
Mockito.when(task.getTaskName()).thenReturn(taskName);
TaskManager taskManager = new TaskManager();
taskManager.registerTask(task);
taskManager.scheduleExecutionAtFixedRate(period, "unknown_task");
Mockito.verify(task, Mockito.times(0)).scheduleExecutionAtFixedRate(Mockito.anyLong());
taskManager.scheduleExecutionAtFixedRate(period, null);
Mockito.verify(task, Mockito.times(0)).scheduleExecutionAtFixedRate(Mockito.anyLong());
}
use of com.synopsys.integration.alert.api.task.TaskManager in project hub-alert by blackducksoftware.
the class ProcessingTaskTest method testJobCountZero.
@Test
void testJobCountZero() {
TaskManager taskManager = Mockito.mock(TaskManager.class);
TaskScheduler taskScheduler = Mockito.mock(TaskScheduler.class);
NotificationAccessor notificationManager = new MockProcessingNotificationAccessor(List.of());
StaticJobAccessor jobAccessor = Mockito.mock(StaticJobAccessor.class);
Mockito.when(jobAccessor.hasJobsByFrequency(Mockito.any())).thenReturn(false);
NotificationDetailExtractionDelegator extractionDelegator = new NotificationDetailExtractionDelegator(blackDuckResponseResolver, List.of());
NotificationProcessor notificationProcessor = new NotificationProcessor(extractionDelegator, null, null, null, null, null);
ProcessingTask task = createTask(taskScheduler, notificationManager, notificationProcessor, taskManager, jobAccessor);
DateRange dateRange = task.getDateRange();
ProcessingTask processingTask = Mockito.spy(task);
processingTask.runTask();
Mockito.verify(processingTask, Mockito.times(0)).getDateRange();
}
Aggregations