Hi everybody,
And I found something that I don't know whether is a bug or
a feature. If my Command class implements
the PrerequisiteCommandsProvider and if I try to use
the CommandController in my integration test, then I have a
problem. Here is a sample code:
try (CommandController commandController = testHarness
.createCommandController(SecuritySetupCommand.class,
project.getRoot()))
{
commandController.initialize();
commandController.setValueFor("securityRealm",
realm);
commandController.setValueFor("authMethod",
authenticationMethod);
commandController.execute();
}
This code fails at the setValueFor method simply because
the UI was not initialized in the initialize method above it
and there are no such inputs like securityRealm and
authMethod.
I did some debugging and found that if SecuritySetupCommand
implements the PrerequisiteCommandsProvider interface, the
commandController.initialize() method does not
call PrerequisiteCommandsProvider#initializeUI method. Instead
it
triggeres PrerequisiteCommandTransformer.DelegateWizard#initializeUI.
Which is empty and does nothing. And that's the reason why
there are no securityRealm and authMethod controls.
I guess that it is caused by some CDI "magic"? So I wonder
is it a bug or a feature? Can I use CommandController to test
commands that implement PrerequisiteCommandsProvider?
Thanks,
Ivan