@Test
 public void testCreateUISelectMany() throws Exception {
   UISelectMany<String> input = factory.createSelectMany("foo", String.class);
   Assert.assertNotNull(input);
   Assert.assertTrue(input.hasFacet(HintsFacet.class));
   Assert.assertEquals(InputComponents.DEFAULT_SHORT_NAME, input.getShortName());
 }
 @Test
 public void testCreateUISelectManyWithShortName() throws Exception {
   UISelectMany<String> input = factory.createSelectMany("foo", 'f', String.class);
   Assert.assertNotNull(input);
   Assert.assertTrue(input.hasFacet(HintsFacet.class));
   Assert.assertEquals('f', input.getShortName());
 }
 @Test
 public void testCreateUISelectManyDefaultValue() throws Exception {
   UISelectMany<String> input = factory.createSelectMany("foo", 'f', String.class);
   Assert.assertNotNull(input);
   input.setDefaultValue((Iterable<String>) null);
   Assert.assertFalse(input.hasDefaultValue());
 }
 /*
  * (non-Javadoc)
  *
  * @see
  * org.jboss.forge.addon.deltaspike.commands.AbstractDeltaSpikeCommand#prepareModulesList(org.jboss.forge.addon.deltaspike
  * .facets.DeltaSpikeFacet, org.jboss.forge.addon.ui.input.UISelectMany)
  */
 @Override
 public void prepareModulesList(
     DeltaSpikeFacet deltaSpikeFacet, UISelectMany<DeltaSpikeModule> dsModules) {
   dsModules.setRequired(false);
   dsModules.setValueChoices(Arrays.<DeltaSpikeModule>asList(DeltaSpikeModules.values()));
   dsModules.setValue(deltaSpikeFacet.getInstalledModules());
 }
 @Override
 public void initializeUI(UIBuilder builder) throws Exception {
   setupTargetClass(builder.getUIContext());
   properties.setValueChoices(
       new Callable<Iterable<String>>() {
         @Override
         public Iterable<String> call() throws Exception {
           List<String> strings = new ArrayList<>();
           JavaResource javaResource = targetClass.getValue();
           JavaClassSource targetClass = javaResource.getJavaType();
           List<PropertySource<JavaClassSource>> properties = targetClass.getProperties();
           for (PropertySource<JavaClassSource> property : properties) {
             strings.add(property.getName());
           }
           return strings;
         }
       });
   properties.setEnabled(
       new Callable<Boolean>() {
         @Override
         public Boolean call() {
           return (targetClass.getValue() != null);
         }
       });
   builder.add(targetClass).add(builderPattern).add(properties);
 }
  @Override
  public Result execute(UIExecutionContext context) throws Exception {
    JavaResource javaResource = targetClass.getValue();
    JavaClassSource targetClass = javaResource.getJavaType();
    GetSetMethodGenerator generator;
    if (builderPattern.getValue()) {
      generator = new BuilderGetSetMethodGenerator();
    } else {
      generator = new DefaultGetSetMethodGenerator();
    }
    List<PropertySource<JavaClassSource>> selectedProperties = new ArrayList<>();
    if (properties == null || properties.getValue() == null) {
      return Results.fail("No properties were selected");
    }
    for (String selectedProperty : properties.getValue()) {
      selectedProperties.add(targetClass.getProperty(selectedProperty));
    }

    for (PropertySource<JavaClassSource> property : selectedProperties) {
      MethodSource<JavaClassSource> accessor =
          targetClass.getMethod("get" + Strings.capitalize(property.getName()));
      if (accessor == null) {
        generator.createAccessor(property);
      } else {
        if (!generator.isCorrectAccessor(accessor, property)) {
          if (promptToFixMethod(context, accessor.getName(), property.getName())) {
            targetClass.removeMethod(accessor);
            generator.createMutator(property);
          }
        }
      }
      String mutatorMethodName = "set" + Strings.capitalize(property.getName());
      String mutatorMethodParameter = property.getType().getName();
      MethodSource<JavaClassSource> mutator =
          targetClass.getMethod(mutatorMethodName, mutatorMethodParameter);
      if (mutator == null) {
        generator.createMutator(property);
      } else {
        if (!generator.isCorrectMutator(mutator, property)) {
          if (promptToFixMethod(context, mutator.getName(), property.getName())) {
            targetClass.removeMethod(mutator);
            generator.createMutator(property);
          }
        }
      }
    }
    setCurrentWorkingResource(context, targetClass);
    return Results.success("Mutators and accessors were generated successfully");
  }
 @Override
 public void initializeUI(UIBuilder builder) throws Exception {
   Set<AddonId> choices = new TreeSet<>();
   for (AddonRepository repository : furnace.getRepositories()) {
     // Avoid immutable repositories
     if (repository instanceof MutableAddonRepository) {
       for (AddonId id : repository.listEnabled()) {
         if (id.getName().contains(":")) choices.add(id);
       }
     }
   }
   addonDependencies.setValueChoices(choices);
   addonDependencies.setDefaultValue(new ArrayList<AddonId>());
   builder.add(addonDependencies);
 }
  @Override
  public Result execute(UIExecutionContext context) throws Exception {
    UIContext uiContext = context.getUIContext();
    Project project = getSelectedProject(uiContext);

    facetFactory.install(project, FurnaceVersionFacet.class);
    project.getFacet(FurnaceVersionFacet.class).setVersion(furnace.getVersion().toString());

    facetFactory.install(project, AddonTestFacet.class);
    for (AddonId addonId : addonDependencies.getValue()) {
      DependencyBuilder dependency =
          DependencyBuilder.create(addonId.getName())
              .setVersion(addonId.getVersion().toString())
              .setScopeType("test");
      if (!dependencyInstaller.isInstalled(project, dependency)) {
        dependencyInstaller.install(project, dependency);
      }
    }
    return Results.success(
        "Project "
            + project.getFacet(MetadataFacet.class).getProjectName()
            + " is now configured for testing");
  }