use of org.jboss.as.cli.completion.mock.MockCommandContext in project wildfly-core by wildfly.
the class ParameterValueResolutionTestCase method testPropertyList_SimpleCommaSeparated.
@Test
public void testPropertyList_SimpleCommaSeparated() throws Exception {
final CommandContext ctx = new MockCommandContext();
ctx.setResolveParameterValues(true);
final ModelNode value = parseProperties(ctx, "${cli.test.prop1}=${cli.test.prop2},${cli.test.prop3}=${cli.test.prop4}");
assertNotNull(value);
assertEquals(ModelType.LIST, value.getType());
final List<Property> list = value.asPropertyList();
assertEquals(2, list.size());
Property prop = list.get(0);
assertNotNull(prop);
assertEquals("one", prop.getName());
assertEquals("two", prop.getValue().asString());
prop = list.get(1);
assertNotNull(prop);
assertEquals("three", prop.getName());
assertEquals("four", prop.getValue().asString());
}
use of org.jboss.as.cli.completion.mock.MockCommandContext in project wildfly-core by wildfly.
the class IfExpressionParsingTestCase method setup.
@BeforeClass
public static void setup() throws Exception {
CTX = new MockCommandContext();
ADDRESS = new DefaultOperationRequestAddress();
LINE = new DefaultCallbackHandler();
final IfHandler ifHandler = new IfHandler();
CONDITION = ifHandler.getConditionArgument();
}
use of org.jboss.as.cli.completion.mock.MockCommandContext in project wildfly-core by wildfly.
the class DefaultOperationCandidatesProviderTestCase method testGetPropertiesFromPropList.
@Test
public void testGetPropertiesFromPropList() throws Exception {
List<Property> propList = new ArrayList<>();
propList.add(new Property("blocking", ModelNode.fromString(list_content)));
propList.add(new Property("blocking-param", ModelNode.fromString(list_content)));
propList.add(new Property("start-mode", ModelNode.fromString(list_content)));
MockCommandContext ctx = new MockCommandContext();
String operationName = "operationName";
ctx.parseCommandLine(":" + operationName + "(!blocking", false);
DefaultOperationRequestAddress address = new DefaultOperationRequestAddress();
DefaultOperationCandidatesProvider candidatesProvider = new DefaultOperationCandidatesProvider();
List<CommandArgument> candidates = candidatesProvider.getPropertiesFromPropList(propList, ctx, operationName, address);
assertEquals(propList.size(), candidates.size());
for (CommandArgument candidate : candidates) {
if (candidate.getFullName().equals("blocking"))
assertFalse("Property blocking can't appear next, since it's completely specified" + " on the commandline as !blocking", candidate.canAppearNext(ctx));
else
assertTrue(candidate.canAppearNext(ctx));
}
}
use of org.jboss.as.cli.completion.mock.MockCommandContext in project wildfly-core by wildfly.
the class AbstractAddressCompleterTest method init.
protected void init() {
ctx = new MockCommandContext();
ctx.setOperationCandidatesProvider(new MockOperationCandidatesProvider(root));
completer = new OperationRequestCompleter();
}
use of org.jboss.as.cli.completion.mock.MockCommandContext in project wildfly-core by wildfly.
the class OperationParsingTestCase method testDMREqualsAsParamEquals.
@Test
public void testDMREqualsAsParamEquals() throws Exception {
DefaultCallbackHandler handler = new DefaultCallbackHandler();
parse(":add(keystore=>{password=1234test,url=/Users/xxx/clientcert.jks})", handler);
assertFalse(handler.hasAddress());
assertTrue(handler.hasOperationName());
assertTrue(handler.hasProperties());
assertFalse(handler.endsOnAddressOperationNameSeparator());
assertFalse(handler.endsOnPropertyListStart());
assertFalse(handler.endsOnPropertySeparator());
assertFalse(handler.endsOnPropertyValueSeparator());
assertFalse(handler.endsOnNodeSeparator());
assertFalse(handler.endsOnNodeTypeNameSeparator());
assertFalse(handler.isRequestComplete());
assertEquals("add", handler.getOperationName());
Set<String> args = handler.getPropertyNames();
assertEquals(1, args.size());
assertTrue(args.contains("keystore"));
assertEquals(">{password=1234test,url=/Users/xxx/clientcert.jks}", handler.getPropertyValue("keystore"));
final ModelNode request = handler.toOperationRequest(new MockCommandContext());
final ModelNode keystoreDmr = request.get("keystore");
assertTrue(keystoreDmr.isDefined());
assertEquals(ModelType.OBJECT, keystoreDmr.getType());
final Set<String> props = keystoreDmr.keys();
assertEquals(2, props.size());
// this name is not alphanumeric but it's still a value of the CLI operation parameter
// and the CLI at the moment does not attempt to validate values
assertTrue(props.contains(">{password"));
assertTrue(props.contains("url"));
assertEquals("1234test", keystoreDmr.get(">{password").asString());
assertEquals("/Users/xxx/clientcert.jks}", keystoreDmr.get("url").asString());
}
Aggregations