2 Replies Latest reply on May 21, 2016 1:22 AM by n3k0

    Why my wizard with some steps returns the same step?

    n3k0 Newbie

      I have a three steps Wizard, but when i make a test BOOM!! it fails, and fails because when the wizard passes to a second step (don't talk about the third) it looks for a parameter of the first step.

      Now some code:


      My entry point:


      public class StartWizard extends AbstractUICommand implements UIWizard {
          @WithAttributes(label = "XML Config", description = "Have a XML configuration? Set it", required = true, type = "String")
          private UIInput<String> xmlInPath;
          public void initializeUI(UIBuilder uiBuilder) throws Exception {
              LOG.info("StartWizard -> initializeUI");
          public NavigationResult next(UINavigationContext uiNavigationContext) throws Exception {
              uiNavigationContext.getUIContext().getAttributeMap().put("xmlInPath", xmlInPath.getValue());
              return Results.navigateTo(ConfigStep.class);
          public Result execute(UIExecutionContext uiExecutionContext) throws Exception {
              Result result = Results.success("Wizard Execute successful! " + xmlInPath.getValue());
              return result;



      The next step:


      public class ConfigStep extends AbstractUICommand implements UIWizardStep {
          protected UIInput<String> url;
          public void initializeUI(UIBuilder uiBuilder) throws Exception {
              InputComponentFactory inputComponentFactory = uiBuilder.getInputComponentFactory();
              url = inputComponentFactory.createInput("Url", String.class).setLabel("URL").setDescription("Add the URL")
          public NavigationResult next(UINavigationContext uiNavigationContext) throws Exception {
              Map<String, Object> attributes = new HashMap<String , Object>();
              attributes.put("url", url.getValue());
              return Results.navigateTo(XMLStep.class);
          public Result execute(UIExecutionContext context) throws Exception {
              StringBuilder result = new StringBuilder();
              return Results.success("config ENDS with values ".concat(result.toString()));


      (I don't add the third step XMLStep because the test does not reach it   )


      And finally, the test:


      public class AddonTest {
          private UITestHarness uiTestHarness;
          private ResourceFactory resourceFactory;
          public void testStepsHappyPath() {
              WizardCommandController startWizardController;
              WizardCommandController configStepController;
              WizardCommandController xmlController = null;
              try {
                  startWizardController = uiTestHarness.createWizardController(StartWizard.class);
                  startWizardController.setValueFor("xmlInPath", null);
                  configStepController = startWizardController.next();
                  configStepController.setValueFor("url", "The dummy url"); // BOOM!! Here throws an Exception!!
                  xmlController = configStepController.next();
                  xmlController.setValueFor("version", "The dummy version" );
              catch (Exception e) {



      AAAaaand finally, the exception is:


      tartWizard initializeUI
      INFORMACIÓN: StartWizard -> initializeUI
      java.lang.IllegalArgumentException: Input named 'url' does not exist. Valid values: [xmlInPath]
      .... (other exceptions ...)...


      Any ideas?

      Thanks in advance.