Package org.jboss.forge.addon.scaffold.spi

Examples of org.jboss.forge.addon.scaffold.spi.ScaffoldProvider


   public void testScaffoldGenerateWithSetup() throws Exception
   {
      Project project = projectHelper.createWebProject();

      Imported<ScaffoldProvider> providerInstances = registry.getServices(ScaffoldProvider.class);
      ScaffoldProvider scaffoldProvider = providerInstances.get();
      Assert.assertFalse(scaffoldProvider.isSetup(new ScaffoldSetupContext("", project)));

      try (WizardCommandController c = testHarness.createWizardController(ScaffoldGenerateCommand.class,
               project.getRoot()))
      {
         c.initialize();
         c.setValueFor("provider", "Mock Scaffold Provider");
         c.setValueFor("webRoot", "");
         Assert.assertTrue(c.isValid());
         // Force the resolution of the next step. Without this ScaffoldGenerateCommandImpl.next() is not evaluated.
         Assert.assertFalse(c.canMoveToNextStep());
         Result result = c.execute();

         // Verify successful execution
         Assert.assertNotNull(result);
         Assert.assertFalse(result instanceof Failed);

         // Verify that the scaffold was setup
         Assert.assertTrue(scaffoldProvider.isSetup(new ScaffoldSetupContext("", project)));
         // Verify that the scaffold was generated
         Assert.assertTrue(((MockProvider) scaffoldProvider).isGenerated());
      }
   }
View Full Code Here


   public void testScaffoldSetup() throws Exception
   {
      Project project = projectHelper.createWebProject();

      Imported<ScaffoldProvider> providerInstances = registry.getServices(ScaffoldProvider.class);
      ScaffoldProvider scaffoldProvider = providerInstances.get();
      Assert.assertFalse(scaffoldProvider.isSetup(new ScaffoldSetupContext("", project)));

      try (WizardCommandController c = testHarness.createWizardController(ScaffoldSetupWizard.class, project.getRoot()))
      {
         c.initialize();
         c.setValueFor("provider", "Mock Scaffold Provider");
         c.setValueFor("webRoot", "");
         Assert.assertTrue(c.isValid());
         // Force the resolution of the next step. Without this ScaffoldSetupWizardImpl.next() is not evaluated.
         Assert.assertFalse(c.canMoveToNextStep());
         Result result = c.execute();

         // Verify successful execution
         Assert.assertNotNull(result);
         Assert.assertFalse(result instanceof Failed);

         // Verify that the scaffold was setup
         Assert.assertTrue(scaffoldProvider.isSetup(new ScaffoldSetupContext("", project)));
      }
   }
View Full Code Here

   {
      // Setup

      // Execute
      Imported<ScaffoldProvider> providerInstances = registry.getServices(ScaffoldProvider.class);
      ScaffoldProvider scaffoldProvider = providerInstances.get();

      // Verify
      assertNotNull(scaffoldProvider);
      assertEquals(PROVIDER_NAME, scaffoldProvider.getName());
      assertEquals(PROVIDER_DESCRIPTION, scaffoldProvider.getDescription());
   }
View Full Code Here

   @Test
   public void testCanSetupScaffoldProvider() throws Exception
   {
      // Setup
      ScaffoldProvider scaffoldProvider = getScaffoldProvider();
      Project project = projectHelper.createWebProject();
      ScaffoldSetupContext setupContext = new ScaffoldSetupContext("", project);

      // Execute
      scaffoldProvider.setup(setupContext);

      // Verify
      assertTrue(scaffoldProvider.isSetup(setupContext));
   }
View Full Code Here

   @Test
   public void testCanGenerateScaffold() throws Exception
   {
      // Setup
      ScaffoldProvider scaffoldProvider = getScaffoldProvider();
      Project project = projectHelper.createWebProject();
      ScaffoldSetupContext setupContext = new ScaffoldSetupContext("", project);
      scaffoldProvider.setup(setupContext);

      // Execute
      List<Resource<?>> scaffoldables = new ArrayList<Resource<?>>();
      scaffoldables.add(resourceFactory.create(new Scaffoldable("mock")));
      ScaffoldGenerationContext generationContext = new ScaffoldGenerationContext("", scaffoldables, project);
      List<Resource<?>> generatedResources = scaffoldProvider.generateFrom(generationContext);

      // Verify
      assertTrue(generatedResources.size() > 0);
      assertTrue(generatedResources.get(0) instanceof ScaffoldedResource);
   }
View Full Code Here

   }

   private ScaffoldProvider getScaffoldProvider()
   {
      Imported<ScaffoldProvider> providerInstances = registry.getServices(ScaffoldProvider.class);
      ScaffoldProvider scaffoldProvider = providerInstances.get();
      assertNotNull(scaffoldProvider);
      return scaffoldProvider;
   }
View Full Code Here

   @Override
   public Result execute(UIExecutionContext context) throws Exception
   {
      Map<Object, Object> attributeMap = context.getUIContext().getAttributeMap();

      ScaffoldProvider selectedProvider = (ScaffoldProvider) attributeMap.get(ScaffoldProvider.class);
      ScaffoldSetupContext setupContext = (ScaffoldSetupContext) attributeMap.get(ScaffoldSetupContext.class);
      selectedProvider.setup(getSelectedProject(context), setupContext);
      // No-op. Scaffold setup is done in a separate step.
      return Results.success("Scaffold was setup successfully.");
   }
View Full Code Here

      overwrite.setEnabled(new Callable<Boolean>()
      {
         @Override
         public Boolean call() throws Exception
         {
            ScaffoldProvider selectedProvider = provider.getValue();
            return selectedProvider != null;
         }
      });

      provider.setDefaultValue(scaffoldProviders.get());
View Full Code Here

   }

   @Override
   public NavigationResult next(UINavigationContext context) throws Exception
   {
      ScaffoldProvider selectedProvider = provider.getValue();
      Project project = getSelectedProject(context);
      ((AbstractFacet) selectedProvider).setFaceted(project);
      UIContext uiContext = context.getUIContext();
      Map<Object, Object> attributeMap = uiContext.getAttributeMap();
      attributeMap.put(ScaffoldProvider.class, selectedProvider);
      attributeMap.put(ScaffoldSetupContext.class, createSetupContext());

      // Get the step sequence from the selected scaffold provider
      List<Class<? extends UICommand>> setupFlow = selectedProvider.getSetupFlow();

      // Add the execution logic step in the end so that the scaffold setup step is executed last after all other
      // steps
      setupFlow.add(ScaffoldExecuteSetupStep.class);
View Full Code Here

   @Override
   public Result execute(UIExecutionContext context) throws Exception
   {
      Map<Object, Object> attributeMap = context.getUIContext().getAttributeMap();
      ScaffoldProvider selectedProvider = (ScaffoldProvider) attributeMap.get(ScaffoldProvider.class);
      ResourceCollection resourceCollection = (ResourceCollection) attributeMap.get(ResourceCollection.class);
      selectedProvider.generateFrom(getSelectedProject(context),
               populateGenerationContext(context.getUIContext(), resourceCollection.getResources()));
      return Results.success("Scaffold was generated successfully.");
   }
View Full Code Here

TOP

Related Classes of org.jboss.forge.addon.scaffold.spi.ScaffoldProvider

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.