The OptionManager interface serves two purposes:
- Create and modify options
- Access option values
The implementations of this class are integrated with the rest of Drill, making it difficult to use the classes in isolation in unit testing. Further, since operators are given the full interface, the operator has the ability to modify options, and so each unit test should either verify that no modification is, in fact, done, or must track down modifications and test them.
For operator and sub-operator unit tests we need a simpler interface. As it turns out, most low-level uses of OptionManager are all read-only. This allows a simple refactoring to enhance unit testability: create a new super-interface OptionSet, which provides only the read-only methods.
Then, refactor low-level classes (code generation, compilers, and so on) to use the restricted OptionSet interface.
Finally, for unit tests, create a trivial, map-based implementation that can be populated as needed for each specific test.