Package org.jboss.forge.addon.ui.controller

Examples of org.jboss.forge.addon.ui.controller.WizardCommandController


   @Test
   public void testSetup() throws Exception
   {
      Project project = projectFactory.createTempProject();
      WizardCommandController tester = testHarness.createWizardController(JPASetupWizard.class,
               project.getRoot());

      tester.initialize();

      Assert.assertFalse(tester.canMoveToPreviousStep());
      // Setting UI values
      tester.setValueFor("jpaVersion", "2.1");
      tester.setValueFor("provider", defaultProvider);
      tester.setValueFor("container", customJTAProvider);
      Assert.assertTrue(tester.canMoveToNextStep());

      tester.next().initialize();

      Assert.assertFalse(tester.isValid());
      tester.setValueFor("dataSourceName", "java:jboss:jta-ds");
      Assert.assertTrue(tester.isValid());
      final AtomicInteger counter = new AtomicInteger();
      tester.getContext().addCommandExecutionListener(new AbstractCommandExecutionListener()
      {
         @Override
         public void postCommandExecuted(UICommand command, UIExecutionContext context, Result result)
         {
            counter.incrementAndGet();
         }
      });
      tester.execute();

      UISelection<Object> selection = tester.getContext().getSelection();
      Assert.assertFalse(selection.isEmpty());
      Assert.assertTrue(selection.get() instanceof FileResource);
      Assert.assertEquals("persistence.xml", ((FileResource) selection.get()).getName());

      // Ensure that the two pages were invoked
View Full Code Here


   @Test
   public void testSetupDuplicateUnitName() throws Exception
   {
      // Execute SUT
      final Project project = projectFactory.createTempProject();
      WizardCommandController tester = testHarness.createWizardController(JPASetupWizard.class,
               project.getRoot());

      tester.initialize();

      Assert.assertFalse(tester.canMoveToPreviousStep());
      // Setting UI values
      tester.setValueFor("provider", defaultProvider);
      tester.setValueFor("container", eap6Container);
      Assert.assertTrue(tester.canMoveToNextStep());

      tester.next().initialize();

      Result result = tester.execute();
      Assert.assertFalse(result instanceof Failed);

      // Check SUT values
      PersistenceCommonDescriptor config = (PersistenceCommonDescriptor) project.getFacet(JPAFacet.class).getConfig();
      List<PersistenceUnitCommon> allUnits = config.getAllPersistenceUnit();
      Assert.assertEquals(project.getFacet(MetadataFacet.class).getProjectName()
               + PersistenceOperations.DEFAULT_UNIT_SUFFIX, allUnits.get(0).getName());
      Assert.assertEquals(1, allUnits.size());

      WizardCommandController tester2 = testHarness.createWizardController(JPASetupWizard.class,
               project.getRoot());

      // Launch
      tester2.initialize();

      Assert.assertFalse(tester2.canMoveToPreviousStep());
      // Setting UI values
      tester2.setValueFor("provider", defaultProvider);
      tester2.setValueFor("container", eap6Container);
      Assert.assertTrue(tester2.canMoveToNextStep());

      tester2.next().initialize();

      result = tester2.execute();
      Assert.assertFalse(result instanceof Failed);

      config = (PersistenceCommonDescriptor) project.getFacet(JPAFacet.class).getConfig();
      allUnits = config.getAllPersistenceUnit();
      Assert.assertEquals(project.getFacet(MetadataFacet.class).getProjectName()
               + PersistenceOperations.DEFAULT_UNIT_SUFFIX, allUnits.get(0).getName());
      Assert.assertEquals(project.getFacet(MetadataFacet.class).getProjectName()
               + PersistenceOperations.DEFAULT_UNIT_SUFFIX + "-1", allUnits.get(1).getName());
      Assert.assertEquals(2, allUnits.size());

      // testing the overwriting of the first persistence unit
      WizardCommandController tester3 = testHarness.createWizardController(JPASetupWizard.class,
               project.getRoot());
      // Launch
      tester3.initialize();
      Assert.assertFalse(tester3.canMoveToPreviousStep());
      // Setting UI values
      tester3.setValueFor("provider", defaultProvider);
      tester3.setValueFor("container", eap6Container);

      Assert.assertTrue(tester3.canMoveToNextStep());
      tester3.next().initialize();
      tester3.setValueFor("persistenceUnitName", project.getFacet(MetadataFacet.class).getProjectName()
               + PersistenceOperations.DEFAULT_UNIT_SUFFIX);
      tester3.setValueFor("overwritePersistenceUnit", true);

      result = tester3.execute();
      Assert.assertFalse(result instanceof Failed);

      // Check SUT values
      config = (PersistenceCommonDescriptor) project.getFacet(JPAFacet.class).getConfig();
      allUnits = config.getAllPersistenceUnit();
View Full Code Here

   @Test
   public void testSetupMetadata() throws Exception
   {
      // Execute SUT
      Project project = projectFactory.createTempProject();
      WizardCommandController tester = testHarness.createWizardController(JPASetupWizard.class,
               project.getRoot());

      tester.initialize();

      Assert.assertFalse(tester.canMoveToPreviousStep());
      // Setting UI values
      tester.setValueFor("provider", defaultProvider);
      tester.setValueFor("container", customJTAProvider);
      tester.setValueFor("configureMetadata", Boolean.TRUE);
      Assert.assertTrue(tester.canMoveToNextStep());

      tester.next().initialize();

      tester.setValueFor("dataSourceName", "java:jboss:jta-ds");
      final AtomicInteger counter = new AtomicInteger();
      tester.getContext().addCommandExecutionListener(new AbstractCommandExecutionListener()
      {
         @Override
         public void postCommandExecuted(UICommand command, UIExecutionContext context, Result result)
         {
            counter.incrementAndGet();
         }
      });
      tester.execute();
      // Ensure that the two pages were invoked
      Assert.assertEquals(2, counter.get());

      // Reload to refresh facets.
      project = projectFactory.findProject(project.getRoot());
View Full Code Here

   private UITestHarness testHarness;

   @Test
   public void testExecution() throws Exception
   {
      WizardCommandController wizard = testHarness.createWizardController(FileWizard.class);
      wizard.initialize();
      InputComponent<?, ?> inputComponent = wizard.getInputs().get("file");
      Assert.assertNotNull(inputComponent);
      String name = inputComponent.getName();
      Assert.assertEquals("file", name);
      wizard.setValueFor(name, OperatingSystemUtils.getUserHomePath());
      Assert.assertNotNull(wizard.getValueFor(name));
      wizard.setValueFor(name, "");
      Assert.assertNull(wizard.getValueFor(name));
      Assert.assertNotNull(wizard);
   }
View Full Code Here

   private UITestHarness testHarness;

   @Test
   public void testCommandScope() throws Exception
   {
      WizardCommandController tester = testHarness.createWizardController(WizardWithScopedObject.class);
      tester.initialize();
      Assert.assertTrue(tester.isValid());
      CommandScopedModel model = modelInstance.get();
      Assert.assertNull(model.getName());
      tester.setValueFor("firstName", "Forge");
      Assert.assertNotNull(model);
      Assert.assertFalse(tester.canMoveToNextStep());
      Assert.assertEquals("Forge", model.getName());
      tester.execute();
   }
View Full Code Here

   @Test
   @org.junit.Ignore("FORGE-1209")
   public void testImportedWithCustomScope() throws Exception
   {
      WizardCommandController tester = testHarness.createWizardController(WizardWithScopedObject.class);
      tester.initialize();
      Assert.assertTrue("Should not be satisfied since there is no Context in scope", modelInstance.isUnsatisfied());
      Assert.assertTrue(tester.isValid());
      Assert.assertFalse("Should be satisfied since there command context was initialized",
               modelInstance.isUnsatisfied());
      tester.execute();
      Assert.assertTrue("Should not be satisfied since there is no Context in scope after finish is called",
               modelInstance.isUnsatisfied());
   }
View Full Code Here

      return createWizardController(name, (Resource<?>) null);
   }

   public WizardCommandController createWizardController(String name, Resource<?>... initialSelection) throws Exception
   {
      WizardCommandController result = null;
      Iterable<UICommand> commands = commandFactory.getCommands();
      UIContextImpl context = getUIContextInstance(initialSelection);
      for (UICommand command : commands)
      {
         if (command instanceof UIWizard)
View Full Code Here

      Project project = projectHelper.createWebProject();
      projectHelper.installJPA_2_0(project);
      projectHelper.installValidation(project);
      JavaResource jpaEntity = projectHelper.createJPAEntity(project, "Customer");

      WizardCommandController wizard = testHarness.createWizardController(ValidationAddConstraintWizard.class,
               project.getRoot());
      wizard.initialize();
      // Page 1
      {
         wizard.setValueFor("javaClass", jpaEntity);
         Assert.assertTrue(wizard.canMoveToNextStep());
      }
      wizard.next().initialize();
      // Page 2
      {
         wizard.setValueFor("onProperty", "id");
         wizard.setValueFor("constraint", CoreConstraints.PATTERN);
         Assert.assertTrue(wizard.canMoveToNextStep());
      }
      wizard.next().initialize();
      // Page 3
      {
         Assert.assertFalse(wizard.isValid());
         wizard.setValueFor("regexp", "[0-9]");
         Assert.assertTrue(wizard.isValid());
      }
      wizard.execute();
      JavaClassSource javaClass = jpaEntity.getJavaType();
      FieldSource<JavaClassSource> field = javaClass.getField("id");
      AnnotationSource<JavaClassSource> pattern = field.getAnnotation(Pattern.class);
      Assert.assertNotNull(pattern);
      Assert.assertEquals("[0-9]", pattern.getStringValue("regexp"));
View Full Code Here

      Project project = projectHelper.createWebProject();
      projectHelper.installJPA_2_0(project);
      projectHelper.installValidation(project);
      JavaResource jpaEntity = projectHelper.createJPAEntity(project, "Customer");

      WizardCommandController wizard = testHarness.createWizardController(ValidationAddConstraintWizard.class,
               project.getRoot());
      wizard.initialize();
      // Page 1
      {
         wizard.setValueFor("javaClass", jpaEntity);
         Assert.assertTrue(wizard.canMoveToNextStep());
      }
      wizard.next().initialize();
      // Page 2
      {
         wizard.setValueFor("onProperty", "id");
         wizard.setValueFor("constraint", CoreConstraints.PATTERN);
         Assert.assertTrue(wizard.canMoveToNextStep());
      }
      wizard.next().initialize();
      // Page 3
      {
         Assert.assertFalse(wizard.isValid());
         wizard.setValueFor("regexp", "^\\d{9}[\\d|X]$");
         Assert.assertTrue(wizard.isValid());
      }
      wizard.execute();
      JavaClassSource javaClass = jpaEntity.getJavaType();
      FieldSource<JavaClassSource> field = javaClass.getField("id");
      AnnotationSource<JavaClassSource> pattern = field.getAnnotation(Pattern.class);
      Assert.assertNotNull(pattern);
      Assert.assertEquals("^\\d{9}[\\d|X]$", pattern.getStringValue("regexp"));
View Full Code Here

   @Test
   public void testArchetypeWizard() throws Exception
   {
      try
      {
         WizardCommandController controller = testHarness.createWizardController("Project: New");
         controller.initialize();
         controller.setValueFor("named", "example");
         Assert.assertFalse(controller.canMoveToNextStep());
         controller.setValueFor("type", "From Archetype");
         Assert.assertTrue(controller.canMoveToNextStep());
         controller.next().initialize();
         Assert.assertFalse(controller.canMoveToNextStep());
         Assert.assertFalse(controller.canExecute());
         controller.setValueFor("archetypeGroupId", "org.jboss.tools.archetypes");
         controller.setValueFor("archetypeArtifactId", "jboss-forge-html5");
         controller.setValueFor("archetypeVersion", "1.0.0-SNAPSHOT");
         Assert.assertTrue(controller.canExecute());
      }
      finally
      {

      }
View Full Code Here

TOP

Related Classes of org.jboss.forge.addon.ui.controller.WizardCommandController

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.