<html><body><div>Hi Ivan,<div><br></div><div>You should check if the ServletFacet is installed before adding ServletSetupWizard to the NavigationResultBuilder</div><div><br></div><div>Best Regards,</div><div><br></div><div>George Gastaldi</div><div><br></div><div><br></div><div>-------- Mensagem original --------</div><div>De: "Ivan St. Ivanov" <ivan.st.ivanov@gmail.com> </div><div>Data: 03/07/2015 17:32 (GMT-03:00) </div><div>Para: forge-dev List <forge-dev@lists.jboss.org> </div><div>Assunto: Re: [forge-dev] Interesting behavior of CommandController (bug or feature ; )) </div><div><br></div></div><br><div><div dir="ltr">Hey George,<div><br></div><div>Thanks for your answer! :)</div><div><br></div><div>Well, maybe I am mismatching two concepts. So, my command that implements <span style="font-size:12.8000001907349px">PrerequisiteCommandsProvider does this:</span></div><div><span style="font-size:12.8000001907349px"><br></span></div><div><div style=""><span style="font-size:12.8000001907349px"> @Override</span></div><div style=""><span style="font-size:12.8000001907349px"> public NavigationResult getPrerequisiteCommands(UIContext context) {</span></div><div style=""><span style="font-size:12.8000001907349px"> NavigationResultBuilder builder = NavigationResultBuilder.create();</span></div><div style=""><span style="font-size:12.8000001907349px"><br></span></div><div style=""><span style="font-size:12.8000001907349px"> builder.add(ServletSetupWizard.class);</span></div><div style=""><span style="font-size:12.8000001907349px"><br></span></div><div style=""><span style="font-size:12.8000001907349px"> return builder.build();</span></div><div style=""><span style="font-size:12.8000001907349px"> }</span></div></div><div style=""><span style="font-size:12.8000001907349px"><br></span></div><div style=""><span style="font-size:12.8000001907349px">Then, just before I execute the command controller thing, I install the Servlet facet for the corresponding Servlet version.</span></div><div style=""><span style="font-size:12.8000001907349px"><br></span></div><div style=""><span style="font-size:12.8000001907349px">But most probably installing a facet does not disable the prerequisite command?</span></div><div style=""><span style="font-size:12.8000001907349px"><br></span></div><div style=""><span style="font-size:12.8000001907349px">Cheers,</span></div><div style=""><span style="font-size:12.8000001907349px">Ivan</span></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Jul 3, 2015 at 5:23 PM, George Gastaldi <span dir="ltr"><<a href="mailto:ggastald@redhat.com" target="_blank">ggastald@redhat.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div bgcolor="#FFFFFF" text="#000000">
Hi Ivan,<br>
<br>
Glad you decided to resume your work on the servlet security addon.
<br>
<br>
When your command use a PreRequisiteCommandProvider, the initial
step might not be your command in question, but the commands to be
executed before that. That's why your setValueFor method might fail.
<br>
<br>
What are the inputs returned in your test after you call
initialize() (commandController.getInputs()) ? <br>
<br>
Best Regards,<br>
<br>
George Gastaldi<div><div class="h5"><br>
<br>
<div>On 07/03/2015 09:36 AM, Ivan St. Ivanov
wrote:<br>
</div>
</div></div><blockquote type="cite"><div><div class="h5">
<div dir="ltr">Hi everybody,
<div><br>
</div>
<div>Believe it or not, but I resumed my work on the Servlet
Security addon for Forge (<a href="https://issues.jboss.org/browse/FORGEPLUGINS-152" target="_blank">https://issues.jboss.org/browse/FORGEPLUGINS-152</a>)
:)</div>
<div><br>
</div>
<div>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:</div>
<div><br>
</div>
<div>
<div>try (CommandController commandController = testHarness</div>
<div>
.createCommandController(SecuritySetupCommand.class,
project.getRoot()))</div>
<div> {</div>
<div> commandController.initialize();</div>
<div> commandController.setValueFor("securityRealm",
realm);</div>
<div> commandController.setValueFor("authMethod",
authenticationMethod);</div>
<div> commandController.execute();</div>
<div> }</div>
</div>
<div><br>
</div>
<div>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.</div>
<div><br>
</div>
<div>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.</div>
<div><br>
</div>
<div>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?</div>
<div><br>
</div>
<div>Thanks,</div>
<div>Ivan</div>
</div>
<br>
<fieldset></fieldset>
<br>
</div></div><pre>_______________________________________________
forge-dev mailing list
<a href="mailto:forge-dev@lists.jboss.org" target="_blank">forge-dev@lists.jboss.org</a>
<a href="https://lists.jboss.org/mailman/listinfo/forge-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/forge-dev</a></pre>
</blockquote>
<br>
</div>
<br>_______________________________________________<br>
forge-dev mailing list<br>
<a href="mailto:forge-dev@lists.jboss.org">forge-dev@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/forge-dev" rel="noreferrer" target="_blank">https://lists.jboss.org/mailman/listinfo/forge-dev</a><br></blockquote></div><br></div>
</div></body></html>