Skip to content
This repository has been archived by the owner on Mar 31, 2023. It is now read-only.

Make TaskScheduler.Builder be non-final #85

Closed
EronWright opened this issue Jun 29, 2016 · 3 comments
Closed

Make TaskScheduler.Builder be non-final #85

EronWright opened this issue Jun 29, 2016 · 3 comments

Comments

@EronWright
Copy link

For mocking purposes (w/ Mockito) it would be handy if the builder weren't final.

@spodila
Copy link
Contributor

spodila commented Jun 30, 2016

Our preference for Builder being final is to prevent incompatibilities across newer versions of Fenzo any Builders users create by extending it, Migrating such users to new versions of Fenzo will be painful if we allowed such extensibility. We also see similar pattern used in other places. For example, Protobuf generated Builders are final.
My understanding of this stackoverflow link is that you should be able to mock it.

@EronWright
Copy link
Author

The link suggests using PowerMock, which adds complexity (for example, I was unable to use it in a certain scalatest scenario).

My scenario is that a certain class is provided an instance of TaskScheduler.Builder in its constructor. That class sets some of the callbacks (withLeaseRejectAction) on the builder, then builds and uses the scheduler. In the unit test for this class, I'd like to provide a mock builder, so that I can provide a mock scheduler to the class while also capturing the lease reject callback to test it. Despite your objections, a non-final builder would really help with this scenario. Go ahead and close if you still object, otherwise I'll send a patch.

@spodila
Copy link
Contributor

spodila commented Sep 19, 2016

Our preference hasn't changed, so closing this. Thank you for the input.

@spodila spodila closed this as completed Sep 19, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants