Search in sources :

Example 11 with MockCommandContext

use of org.jboss.as.cli.completion.mock.MockCommandContext in project wildfly-core by wildfly.

the class ParameterValueResolutionTestCase method testNestedAndRecursive.

@Test
public void testNestedAndRecursive() throws Exception {
    final CommandContext ctx = new MockCommandContext();
    ctx.setResolveParameterValues(true);
    ModelNode value = parseObject(ctx, "the value is ${${cli.test.ref1}.${cli.test.ref2}}");
    assertNotNull(value);
    assertEquals(ModelType.STRING, value.getType());
    assertEquals("the value is valuable", value.asString());
}
Also used : MockCommandContext(org.jboss.as.cli.completion.mock.MockCommandContext) CommandContext(org.jboss.as.cli.CommandContext) MockCommandContext(org.jboss.as.cli.completion.mock.MockCommandContext) ModelNode(org.jboss.dmr.ModelNode) Test(org.junit.Test)

Example 12 with MockCommandContext

use of org.jboss.as.cli.completion.mock.MockCommandContext in project wildfly-core by wildfly.

the class ParameterValueResolutionTestCase method testDefault_Object.

@Test
public void testDefault_Object() throws Exception {
    final CommandContext ctx = new MockCommandContext();
    ctx.setResolveParameterValues(true);
    final ModelNode value = parseObject(ctx, "{\"${cli.test.prop1}\"=>\"${cli.test.prop2}\",\"${cli.test.prop3}\"=>\"${cli.test.prop4}\"}");
    assertNotNull(value);
    assertEquals(ModelType.OBJECT, value.getType());
    final List<Property> list = value.asPropertyList();
    assertEquals(2, list.size());
    assertEquals("one", list.get(0).getName());
    assertEquals("two", list.get(0).getValue().asString());
    assertEquals("three", list.get(1).getName());
    assertEquals("four", list.get(1).getValue().asString());
}
Also used : MockCommandContext(org.jboss.as.cli.completion.mock.MockCommandContext) CommandContext(org.jboss.as.cli.CommandContext) MockCommandContext(org.jboss.as.cli.completion.mock.MockCommandContext) ModelNode(org.jboss.dmr.ModelNode) Property(org.jboss.dmr.Property) Test(org.junit.Test)

Example 13 with MockCommandContext

use of org.jboss.as.cli.completion.mock.MockCommandContext in project wildfly-core by wildfly.

the class ParameterValueResolutionTestCase method testSimpleText.

@Test
public void testSimpleText() throws Exception {
    final CommandContext ctx = new MockCommandContext();
    ctx.setResolveParameterValues(true);
    ModelNode value = parseObject(ctx, "the value is $\\{cli.test.valuable\\}");
    assertNotNull(value);
    assertEquals(ModelType.STRING, value.getType());
    assertEquals("the value is ${cli.test.valuable}", value.asString());
    value = parseObject(ctx, "the value is ${cli.test.valuable}");
    assertNotNull(value);
    assertEquals(ModelType.STRING, value.getType());
    assertEquals("the value is valuable", value.asString());
}
Also used : MockCommandContext(org.jboss.as.cli.completion.mock.MockCommandContext) CommandContext(org.jboss.as.cli.CommandContext) MockCommandContext(org.jboss.as.cli.completion.mock.MockCommandContext) ModelNode(org.jboss.dmr.ModelNode) Test(org.junit.Test)

Aggregations

MockCommandContext (org.jboss.as.cli.completion.mock.MockCommandContext)13 Test (org.junit.Test)11 ModelNode (org.jboss.dmr.ModelNode)10 CommandContext (org.jboss.as.cli.CommandContext)9 Property (org.jboss.dmr.Property)3 DefaultCallbackHandler (org.jboss.as.cli.operation.impl.DefaultCallbackHandler)2 ArrayList (java.util.ArrayList)1 CommandArgument (org.jboss.as.cli.CommandArgument)1 MockOperationCandidatesProvider (org.jboss.as.cli.completion.mock.MockOperationCandidatesProvider)1 IfHandler (org.jboss.as.cli.handlers.ifelse.IfHandler)1 OperationRequestCompleter (org.jboss.as.cli.operation.OperationRequestCompleter)1 DefaultOperationRequestAddress (org.jboss.as.cli.operation.impl.DefaultOperationRequestAddress)1 BeforeClass (org.junit.BeforeClass)1