-
-
Notifications
You must be signed in to change notification settings - Fork 207
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: ManualSchedulerBuilder uses provided SchedulerListeners #617
base: master
Are you sure you want to change the base?
fix: ManualSchedulerBuilder uses provided SchedulerListeners #617
Conversation
@kagkarlsson hi! Any chance you could look at this? :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for contributing! 🙏
I have a couple of suggestions..
@@ -58,6 +66,7 @@ public void onExecutionStart(CurrentlyExecuting currentlyExecuting) { | |||
}); | |||
} | |||
|
|||
@SuppressWarnings("CodeBlock2Expr") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure about this... I think maybe just drop these.. (or put it on class-level at least.. )
|
||
public SchedulerListeners getSchedulerListeners() { | ||
return this.schedulerListeners; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this necessary?
private final SchedulerListener listener = | ||
new SchedulerListener() { | ||
|
||
@Override | ||
public void onExecutionScheduled(TaskInstanceId taskInstanceId, Instant executionTime) { | ||
LOG.info("onExecutionScheduled()"); | ||
} | ||
|
||
@Override | ||
public void onExecutionStart(CurrentlyExecuting currentlyExecuting) { | ||
LOG.info("onExecutionStart()"); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you can use SchedulerListener.NOOP
instead of defining this one..
public void register_scheduler_listener() { | ||
LOG.info("register_scheduler_listener()"); | ||
|
||
ManualScheduler scheduler = TestHelper.createManualScheduler(postgres.getDataSource()).build(); | ||
|
||
assertDoesNotThrow(() -> scheduler.registerSchedulerListener(listener)); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was the case previously that this method threw an exception?
private final SchedulerListener listener = | ||
new SchedulerListener() { | ||
|
||
@Override |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NOOP listener?
public void manual_scheduler_listener() { | ||
LOG.info("manual_scheduler_add_listener()"); | ||
|
||
ManualScheduler scheduler = | ||
TestHelper.createManualScheduler(postgres.getDataSource()) | ||
.addSchedulerListener(listener) | ||
.build(); | ||
|
||
assertThat(scheduler.getSchedulerListeners().getSchedulerListeners(), hasItem(listener)); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Possibly a "better" test, or at least one not requiring the method scheduler.getSchedulerListeners()
is to attach a listener, run an execution, and verifying that the listener was called (NOOP will not work for that case)
Brief, plain english overview of your changes here
Made ManualSchedulerBuilder use provided SchedulerListeners instead of a hard coded list. Also fixed
ManualScheduler.registerSchedulerListener()
throwing an unsupported operation exception.Fixes
#532
Reminders
mvn spotless:apply
cc @kagkarlsson