当前位置: 首页>>代码示例>>Java>>正文


Java CommandController.setValueFor方法代码示例

本文整理汇总了Java中org.jboss.forge.addon.ui.controller.CommandController.setValueFor方法的典型用法代码示例。如果您正苦于以下问题:Java CommandController.setValueFor方法的具体用法?Java CommandController.setValueFor怎么用?Java CommandController.setValueFor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.jboss.forge.addon.ui.controller.CommandController的用法示例。


在下文中一共展示了CommandController.setValueFor方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testSomething

import org.jboss.forge.addon.ui.controller.CommandController; //导入方法依赖的package包/类
@Test
public void testSomething() throws Exception {
    File tempDir = OperatingSystemUtils.createTempDir();
    try {
        Project project = projectFactory.createTempProject();
        Assert.assertNotNull("Should have created a project", project);

        CommandController command = testHarness.createCommandController(CamelSetupCommand.class, project.getRoot());
        command.initialize();
        command.setValueFor("kind", "camel-spring");

        Result result = command.execute();
        Assert.assertFalse("Should setup Camel in the project", result instanceof Failed);

        command = testHarness.createCommandController(CamelGetComponentsCommand.class, project.getRoot());
        command.initialize();

        result = command.execute();
        Assert.assertFalse("Should not fail", result instanceof Failed);

        String message = result.getMessage();
        System.out.println(message);
    } finally {
        tempDir.delete();
    }
}
 
开发者ID:fabric8io,项目名称:fabric8-forge,代码行数:27,代码来源:NewComponentInstanceTest.java

示例2: testDeleteRoute

import org.jboss.forge.addon.ui.controller.CommandController; //导入方法依赖的package包/类
protected void testDeleteRoute(Project project) throws Exception {
    String key = "_camelContext1/cbr-route/_choice1/_when1/_to1";
    CommandController command = testHarness.createCommandController(CamelDeleteNodeXmlCommand.class, project.getRoot());
    command.initialize();
    command.setValueFor("xml", "META-INF/spring/camel-context.xml");

    setNodeValue(key, command);

    assertValidAndExecutes(command);

    List<ContextDto> contexts = getRoutesXml(project);
    assertFalse("Should have loaded a camelContext", contexts.isEmpty());

    assertNoNodeWithKey(contexts, key);
    assertNodeWithKey(contexts, NEW_ROUTE_KEY);
}
 
开发者ID:fabric8io,项目名称:fabric8-forge,代码行数:17,代码来源:NewNodeXmlTest.java

示例3: setNodeValue

import org.jboss.forge.addon.ui.controller.CommandController; //导入方法依赖的package包/类
protected void setNodeValue(String key, CommandController command) {
    Object value = key;
    SelectComponent nodeInput = (SelectComponent) command.getInput("node");
    Iterable<NodeDto> valueChoices = nodeInput.getValueChoices();
    NodeDto found = NodeDtos.findNodeByKey(valueChoices, key);
    if (found != null) {
        value = found;
        System.out.println("Found node " + value);
    } else {
        System.out.println("Failed to find node with key '" + key + "' in the node choices: " + nodeInput.getValueChoices());
    }
    command.setValueFor("node", value);

    System.out.println("Set value of node " + value + " currently has " + nodeInput.getValue());

    if (nodeInput.getValue() == null) {
        command.setValueFor("node", key);
        System.out.println("Set value of node " + value + " currently has " + nodeInput.getValue());
    }
}
 
开发者ID:fabric8io,项目名称:fabric8-forge,代码行数:21,代码来源:NewNodeXmlTest.java

示例4: getRoutesXml

import org.jboss.forge.addon.ui.controller.CommandController; //导入方法依赖的package包/类
protected List<ContextDto> getRoutesXml(Project project) throws Exception {
    CommandController command = testHarness.createCommandController(CamelGetRoutesXmlCommand.class, project.getRoot());
    command.initialize();
    command.setValueFor("format", "JSON");

    Result result = command.execute();
    assertFalse("Should not fail", result instanceof Failed);

    String message = result.getMessage();

    System.out.println();
    System.out.println();
    System.out.println("JSON: " + message);
    System.out.println();

    List<ContextDto> answer = NodeDtos.parseContexts(message);
    System.out.println();
    System.out.println();
    List<NodeDto> nodeList = NodeDtos.toNodeList(answer);
    for (NodeDto node : nodeList) {
        System.out.println(node.getLabel());
    }
    System.out.println();
    return answer;
}
 
开发者ID:fabric8io,项目名称:fabric8-forge,代码行数:26,代码来源:NewNodeXmlTest.java

示例5: setupController

import org.jboss.forge.addon.ui.controller.CommandController; //导入方法依赖的package包/类
private void setupController(CommandController controller, File inputFile, File outputFile) throws Exception
{
    controller.initialize();
    Assert.assertTrue(controller.isEnabled());
    controller.setValueFor(InputPathOption.NAME, Collections.singletonList(inputFile)); // FORGE-2524
    final Object value = controller.getValueFor(InputPathOption.NAME);
    Assume.assumeTrue(value instanceof Collection);
    Assume.assumeTrue(((Collection) value).iterator().hasNext());
    Assume.assumeTrue(((Collection) value).iterator().next() instanceof File);
    Assume.assumeTrue(((Collection) value).iterator().next().equals(inputFile));

    if (outputFile != null)
    {
        controller.setValueFor(OutputPathOption.NAME, outputFile);
    }
    controller.setValueFor(TargetOption.NAME, Collections.singletonList("eap"));

    Assert.assertTrue(controller.canExecute());
    controller.setValueFor("packages", "org.jboss");
    Assert.assertTrue(controller.canExecute());
}
 
开发者ID:windup,项目名称:windup,代码行数:22,代码来源:WindupCommandTest.java

示例6: populateController

import org.jboss.forge.addon.ui.controller.CommandController; //导入方法依赖的package包/类
public static void populateController(Map<String, Object> requestedInputs, CommandController controller, ConverterFactory converterFactory) {
    if (requestedInputs != null) {
        Map<String, InputComponent<?, ?>> inputs = controller.getInputs();
        Set<String> inputKeys = new HashSet<>(inputs.keySet());
        inputKeys.retainAll(requestedInputs.keySet());
        Set<Map.Entry<String, InputComponent<?, ?>>> entries = inputs.entrySet();
        for (Map.Entry<String, InputComponent<?, ?>> entry : entries) {
            String key = entry.getKey();
            Object value = requestedInputs.get(key);
            controller.setValueFor(key, Proxies.unwrap(value));
        }
    }
}
 
开发者ID:fabric8io,项目名称:fabric8-forge,代码行数:14,代码来源:UICommands.java

示例7: testNewJobXml

import org.jboss.forge.addon.ui.controller.CommandController; //导入方法依赖的package包/类
@Test
public void testNewJobXml() throws Exception {
	Project project = factory.createTempProject(Arrays.asList(ResourcesFacet.class, JavaSourceFacet.class));
	JavaClassSource reader = Roaster.parse(JavaClassSource.class, getClass().getClassLoader().getResource("templates/MyItemReader.jv"));
	JavaClassSource processor = Roaster.parse(JavaClassSource.class, getClass().getClassLoader().getResource("templates/MyItemProcessor.jv"));
	JavaClassSource writer = Roaster.parse(JavaClassSource.class, getClass().getClassLoader().getResource("templates/MyItemWriter.jv"));
	JavaSourceFacet java = project.getFacet(JavaSourceFacet.class);
	JavaResource readerResource = java.saveJavaSource(reader);
	JavaResource processorResource = java.saveJavaSource(processor);
	JavaResource writerResource = java.saveJavaSource(writer);
	
	CommandController commandController = harness.createCommandController(BatchNewJobXmlCommand.class, project.getRoot());
	commandController.initialize();
	
	// set values
	commandController.setValueFor("reader", readerResource.getJavaType().getQualifiedName());
	commandController.setValueFor("processor", processorResource.getJavaType().getQualifiedName());
	commandController.setValueFor("writer", writerResource.getJavaType().getQualifiedName());
	commandController.setValueFor("jobXML", "myJob.xml");
	
	// validate
	List<UIMessage> validate = commandController.validate();
	Assert.assertEquals(0,  validate.size());
	
	// execute
	Result result = commandController.execute();
	
	// verify results
	Assert.assertFalse(result instanceof Failed);
}
 
开发者ID:javaee-samples,项目名称:forge-addons,代码行数:31,代码来源:BatchNewJobXmlCommandTest.java

示例8: testNewJobXmlOptionalProcessor

import org.jboss.forge.addon.ui.controller.CommandController; //导入方法依赖的package包/类
@Test
public void testNewJobXmlOptionalProcessor() throws Exception {
	Project project = factory.createTempProject(Arrays.asList(ResourcesFacet.class, JavaSourceFacet.class));
	
	JavaClassSource reader = Roaster.parse(JavaClassSource.class, getClass().getClassLoader().getResource("templates/MyItemReader.jv"));
	JavaClassSource writer = Roaster.parse(JavaClassSource.class, getClass().getClassLoader().getResource("templates/MyItemWriter.jv"));
	JavaSourceFacet java = project.getFacet(JavaSourceFacet.class);
	JavaResource readerResource = java.saveJavaSource(reader);
	JavaResource writerResource = java.saveJavaSource(writer);
	
	CommandController commandController = harness.createCommandController(BatchNewJobXmlCommand.class, project.getRoot());
	commandController.initialize();
	
	// set values
	commandController.setValueFor("reader", readerResource.getJavaType().getQualifiedName());
	commandController.setValueFor("writer", writerResource.getJavaType().getQualifiedName());
	commandController.setValueFor("jobXML", "myJob.xml");
	
	// validate
	List<UIMessage> validate = commandController.validate();
	Assert.assertEquals(0,  validate.size());
	
	// execute
	Result result = commandController.execute();
	
	// verify results
	Assert.assertFalse(result instanceof Failed);
}
 
开发者ID:javaee-samples,项目名称:forge-addons,代码行数:29,代码来源:BatchNewJobXmlCommandTest.java

示例9: checkParametersPassed

import org.jboss.forge.addon.ui.controller.CommandController; //导入方法依赖的package包/类
@Test
public void checkParametersPassed() throws Exception {
	CommandController controller = uiTestHarness
				.createCommandController(SetupProjectCommand.class, project.getRoot());
	controller.initialize();
	// Checks the command metadata
	assertTrue(controller.getCommand() instanceof SetupProjectCommand);

	SpringBootDependencyDTO securityDTO = new SpringBootDependencyDTO("Core","security","Security","Secure your application via spring-security");
	SpringBootDependencyDTO actuatorDTO = new SpringBootDependencyDTO("Ops","actuator","Actuator","Production ready features to help you monitor and manage your application");
	Iterable<SpringBootDependencyDTO> deps = Arrays.asList(securityDTO, actuatorDTO);
	controller.setValueFor("dependencies", deps);
     final String askedVersion = "2.0.0.M1";

     controller.setValueFor("springBootVersion", askedVersion);
     assertEquals(askedVersion, controller.getValueFor("springBootVersion"));

	Result result = controller.execute();
	MavenFacet mavenFacet = project.getFacet(MavenFacet.class);
	MavenModelResource modelResource = mavenFacet.getModelResource();
	Model model = modelResource.getCurrentModel();
	assertEquals("empty-project",model.getArtifactId());
	assertEquals("unknown",model.getGroupId());
	assertEquals("0",model.getVersion());

	// Check if the parent contains the Spring Boot Artifact & version specified
	Parent parent = model.getParent();
	assertEquals("org.springframework.boot",parent.getGroupId());
	assertEquals("spring-boot-starter-parent",parent.getArtifactId());
     assertEquals(askedVersion, parent.getVersion());

	Node contents = modelResource.getXmlSource();
	List<Node> dependenciesNodes = contents.get("dependencies").get(0).getChildren();

	// Check Spring Boot Actuator Dependency
	List<Node> dependencyActuator = dependenciesNodes.get(0).getChildren();
	assertEquals("org.springframework.boot",dependencyActuator.get(0).getText());
	assertEquals("spring-boot-starter-actuator",dependencyActuator.get(1).getText());

	// Check Spring Boot Security Dependency
	List<Node> dependencySecurity = dependenciesNodes.get(1).getChildren();
	assertEquals("org.springframework.boot",dependencySecurity.get(0).getText());
	assertEquals("spring-boot-starter-security",dependencySecurity.get(1).getText());

	assertTrue("Created new Spring Boot", result.getMessage().contains("Created new Spring Boot"));
}
 
开发者ID:forge,项目名称:springboot-addon,代码行数:47,代码来源:SetupCommandTest.java

示例10: createNewSpringBootProject

import org.jboss.forge.addon.ui.controller.CommandController; //导入方法依赖的package包/类
public void createNewSpringBootProject() throws Exception {

        LOG.info("Creating new project");

        String name = "my-project";

        RestUIContext context = new RestUIContext();
        UICommand projectNewCommand = commandFactory.getCommandByName(context, "project-new");

        File outputDir = projectsOutputFolder;
        outputDir.mkdirs();

        CommandController controller = commandControllerFactory.createController(context, runtime, projectNewCommand);
        controller.initialize();

        controller.setValueFor("named", name);
        controller.setValueFor("topLevelPackage", "org.example");
        controller.setValueFor("version", "1.0.0-SNAPSHOT");
        controller.setValueFor("targetLocation", outputDir.getAbsolutePath());
        controller.setValueFor("buildSystem", "Maven");
        controller.setValueFor("type", "Spring Boot");

        WizardCommandController wizardCommandController = assertWizardController(controller);
        validate(wizardCommandController);
        wizardCommandController = wizardCommandController.next();
        LOG.info("Next result: " + wizardCommandController);

        wizardCommandController.setValueFor("springBootVersion", "1.3.7");

        // due to furnace/forge classloading we need to find the dto from the existing choices
        // and then select the dependencies we want to use
        SpringBootDependencyDTO web = null;
        UISelectMany many = (UISelectMany) wizardCommandController.getInput("dependencies");
        for (Object c : many.getValueChoices()) {
            SpringBootDependencyDTO dto = (SpringBootDependencyDTO) c;
            if ("web".equals(dto.getId())) {
                web = dto;
                break;
            }
        }

        wizardCommandController.setValueFor("dependencies", web);

        validate(wizardCommandController);
        try {

            Result result = wizardCommandController.execute();
            printResult(result);

            useNewProject(outputDir, name);
        } catch (Exception e) {
            LOG.error("Failed to create project " + name + " " + e, e);
        }
    }
 
开发者ID:fabric8io,项目名称:fabric8-forge,代码行数:55,代码来源:ProjectGenerator.java

示例11: createProjectFromArchetype

import org.jboss.forge.addon.ui.controller.CommandController; //导入方法依赖的package包/类
public void createProjectFromArchetype(String archetype) throws Exception {
        String archetypeUri = "io.fabric8.archetypes:" + archetype + ":" + FABRIC8_ARCHETYPE_VERSION;

        LOG.info("Creating archetype: " + archetypeUri);

        RestUIContext context = new RestUIContext();
        UICommand projectNewCommand = commandFactory.getCommandByName(context, "project-new");

        File outputDir = new File(projectsOutputFolder, archetype);
        outputDir.mkdirs();

        CommandController controller = commandControllerFactory.createController(context, runtime, projectNewCommand);
        controller.initialize();

        String name = Strings.stripSuffix("my-" + archetype, "-archetype");
        controller.setValueFor("named", name);
        controller.setValueFor("topLevelPackage", "org.example");
        controller.setValueFor("version", "1.0.0-SNAPSHOT");
        controller.setValueFor("targetLocation", outputDir.getAbsolutePath());
        controller.setValueFor("buildSystem", "Maven");
        controller.setValueFor("type", "From Archetype Catalog");

        WizardCommandController wizardCommandController = assertWizardController(controller);
        validate(wizardCommandController);
        wizardCommandController = wizardCommandController.next();
        LOG.info("Next result: " + wizardCommandController);

/*
        InputComponent<?, ?> archetypeInput = wizardCommandController.getInputs().get("archetype");
        archetypeInput.get
*/

        wizardCommandController.setValueFor("catalog", "fabric8");
        wizardCommandController.setValueFor("archetype", archetypeUri);

        validate(wizardCommandController);
        try {

            Result result = wizardCommandController.execute();
            printResult(result);

            useProjectFromArchetype(archetype, outputDir, name);
        } catch (Exception e) {
            LOG.error("Failed to create project " + archetypeUri + " " + e, e);
        }
    }
 
开发者ID:fabric8io,项目名称:fabric8-forge,代码行数:47,代码来源:ProjectGenerator.java

示例12: executeCommand

import org.jboss.forge.addon.ui.controller.CommandController; //导入方法依赖的package包/类
@POST
@Path("/execute/{command}")
@Consumes("application/json")
@Produces(MediaType.APPLICATION_JSON)
public ResultMetadata executeCommand(@PathParam("command") String command, Map<String,Object> parameters)
    throws Exception
{
   IDEUIContext context = new IDEUIContext();
   UICommand cmd = commandFactory.get().getCommandByName(context, command);

   CommandController controller = controllerFactory.get().createSingleController(
            context, new UIRuntimeImpl(), cmd);
   controller.initialize();

   for (String key : parameters.keySet()) {
      controller.setValueFor(key, parameters.get(key));
   }

   //controller.setValueFor("targetLocation", new ResourcePath());

   ResultMetadata rm = new ResultMetadata();
   try
   {
      Result result = controller.execute();
      if (result instanceof Failed) {
         rm.setPassed(false);
         rm.setMessage(result.getMessage());
         if (((Failed) result).getException() != null) 
         {
            rm.setException(((Failed) result).getException().getMessage());
         }
      }
      else
      {
         rm.setPassed(true);
         rm.setMessage(result.getMessage());
      }
   }
   catch (Exception ex)
   {
      rm.setPassed(false);
      rm.setException(ex.getMessage());
   }

   return rm;
}
 
开发者ID:forgeide,项目名称:forgeide,代码行数:47,代码来源:CommandServices.java


注:本文中的org.jboss.forge.addon.ui.controller.CommandController.setValueFor方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。