@Test public void shouldAutoRegisterReturnsTrueWhenClassNotAnnotated() { var job = new NonAnnotatedJob(); var actualShouldAutoRegister = scheduledJobExecutor.shouldAutoRegister(job); assertThat(actualShouldAutoRegister).isTrue(); }
boolean shouldAutoRegister(ScheduledJob scheduledJob) { var autoRegisteredAnnotation = scheduledJob.getClass().getAnnotation(AutoRegistered.class); if(Objects.isNull(autoRegisteredAnnotation)) { return true; } else { return autoRegisteredAnnotation.value(); } }
ScheduledJobExecutor implements ApplicationContextAware { boolean shouldAutoRegister(ScheduledJob scheduledJob) { var autoRegisteredAnnotation = scheduledJob.getClass().getAnnotation(AutoRegistered.class); if(Objects.isNull(autoRegisteredAnnotation)) { return true; } else { return autoRegisteredAnnotation.value(); } } }
ScheduledJobExecutor implements ApplicationContextAware { boolean shouldAutoRegister(ScheduledJob scheduledJob) { var autoRegisteredAnnotation = scheduledJob.getClass().getAnnotation(AutoRegistered.class); if(Objects.isNull(autoRegisteredAnnotation)) { return true; } else { return autoRegisteredAnnotation.value(); } } @Autowired  ScheduledJobExecutor(ScheduledJobLogRepository jobLogRepo, Clock clock); }
ScheduledJobExecutor implements ApplicationContextAware { boolean shouldAutoRegister(ScheduledJob scheduledJob) { var autoRegisteredAnnotation = scheduledJob.getClass().getAnnotation(AutoRegistered.class); if(Objects.isNull(autoRegisteredAnnotation)) { return true; } else { return autoRegisteredAnnotation.value(); } } @Autowired  ScheduledJobExecutor(ScheduledJobLogRepository jobLogRepo, Clock clock); @Scheduled( initialDelay = 0L, fixedDelay = 120_000L ) void executeJobs(); void registerScheduledJob(@NonNull ScheduledJob scheduledJob); @Override void setApplicationContext(ApplicationContext applicationContext); }
ScheduledJobExecutor implements ApplicationContextAware { boolean shouldAutoRegister(ScheduledJob scheduledJob) { var autoRegisteredAnnotation = scheduledJob.getClass().getAnnotation(AutoRegistered.class); if(Objects.isNull(autoRegisteredAnnotation)) { return true; } else { return autoRegisteredAnnotation.value(); } } @Autowired  ScheduledJobExecutor(ScheduledJobLogRepository jobLogRepo, Clock clock); @Scheduled( initialDelay = 0L, fixedDelay = 120_000L ) void executeJobs(); void registerScheduledJob(@NonNull ScheduledJob scheduledJob); @Override void setApplicationContext(ApplicationContext applicationContext);  }