Search in sources :

Example 1 with MockCommandContext

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

the class ParameterValueResolutionTestCase method testList_NoBrackets.

@Test
public void testList_NoBrackets() throws Exception {
    final CommandContext ctx = new MockCommandContext();
    ctx.setResolveParameterValues(true);
    final ModelNode value = parseList(ctx, "${cli.test.prop1},${cli.test.prop2},${cli.test.prop3}");
    assertNotNull(value);
    assertEquals(ModelType.LIST, value.getType());
    final List<ModelNode> list = value.asList();
    assertEquals(3, list.size());
    assertNotNull(list.get(0));
    assertEquals("one", list.get(0).asString());
    assertNotNull(list.get(1));
    assertEquals("two", list.get(1).asString());
    assertNotNull(list.get(2));
    assertEquals("three", list.get(2).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 2 with MockCommandContext

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

the class ParameterValueResolutionTestCase method testDefaultValueForNotSetProperty.

@Test
public void testDefaultValueForNotSetProperty() throws Exception {
    final CommandContext ctx = new MockCommandContext();
    ctx.setResolveParameterValues(true);
    ModelNode value = parseObject(ctx, "the value is ${cli.test.xxx:not set}");
    assertNotNull(value);
    assertEquals(ModelType.STRING, value.getType());
    assertEquals("the value is not set", 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 3 with MockCommandContext

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

the class ParameterValueResolutionTestCase method testPathSeparator.

@Test
public void testPathSeparator() throws Exception {
    final CommandContext ctx = new MockCommandContext();
    ctx.setResolveParameterValues(true);
    ModelNode value = parseObject(ctx, "the value is ${:}");
    assertNotNull(value);
    assertEquals(ModelType.STRING, value.getType());
    assertEquals("the value is " + File.pathSeparator, 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 4 with MockCommandContext

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

the class ParameterValueResolutionTestCase method testDefault_List.

@Test
public void testDefault_List() throws Exception {
    final CommandContext ctx = new MockCommandContext();
    ctx.setResolveParameterValues(true);
    final ModelNode value = parseObject(ctx, "[\"${cli.test.prop1}\",\"${cli.test.prop2}\"]");
    assertNotNull(value);
    assertEquals(ModelType.LIST, value.getType());
    final List<ModelNode> list = value.asList();
    assertEquals(2, list.size());
    assertEquals("one", list.get(0).asString());
    assertEquals("two", list.get(1).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 5 with MockCommandContext

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

the class ParameterValueResolutionTestCase method testFileSeparator.

@Test
public void testFileSeparator() throws Exception {
    final CommandContext ctx = new MockCommandContext();
    ctx.setResolveParameterValues(true);
    ModelNode value = parseObject(ctx, "the value is ${/}");
    assertNotNull(value);
    assertEquals(ModelType.STRING, value.getType());
    assertEquals("the value is " + File.separator, value.asString());
    value = parseObject(ctx, "the value is \\${/}");
    assertNotNull(value);
    assertEquals(ModelType.STRING, value.getType());
    assertEquals("the value is " + File.separator, value.asString());
    value = parseObject(ctx, "the value is \\${/}.");
    assertNotNull(value);
    assertEquals(ModelType.STRING, value.getType());
    assertEquals("the value is " + File.separator + '.', 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