AbstractScanner { public void schedule() { if (!isEnabled()) { logger.info(getScannerName() + " is disabled"); return; } if (quartz == null) { logger.warn("No quartz scheduler available to schedule scanner."); return; } logger.info("Schedule " + getScannerName() + " as a cron job ({})", getCronExpression()); try { final CronTrigger trigger = new CronTrigger(); trigger.setCronExpression(getCronExpression()); trigger.setName(getTriggerName()); trigger.setGroup(getTriggerGroupName()); trigger.setJobName(getJobName()); trigger.setJobGroup(getJobGroup()); if (getQuartz().getTriggersOfJob(getJobName(), getJobGroup()).length == 0) { getQuartz().scheduleJob(trigger); } else { getQuartz().rescheduleJob(getTriggerName(), getTriggerGroupName(), trigger); } } catch (ParseException e) { logger.error("Error scheduling " + getScannerName() + ", the cron expression '{}' could not be parsed: {}", getCronExpression(), e.getMessage()); } catch (Exception e) { logger.error("Error scheduling " + getScannerName(), e); } }  abstract String getJobGroup(); abstract String getJobName(); abstract String getTriggerGroupName(); abstract String getTriggerName(); abstract String getScannerName(); abstract void scan(); String getCronExpression(); void setCronExpression(String cronExpression); boolean isEnabled(); void setEnabled(boolean enabled); void schedule(); void unschedule(); OrganizationDirectoryService getOrganizationDirectoryService(); SecurityContext getAdminContextFor(String orgId); ServiceRegistry getServiceRegistry(); String getSystemUserName(); void deactivate(); void shutdown(); void trigger(); static final String JOB_PARAM_PARENT; static final String PARAM_KEY_ENABLED; static final String PARAM_KEY_CRON_EXPR; }
@Test public void scheduleInputDefaultsExpectDisabled() { abstractScanner.schedule(); }