use of org.neo4j.shell.state.ParamValue in project neo4j by neo4j.
the class ParamsTest method runCommandWithArg.
@Test
public void runCommandWithArg() throws CommandException {
// given
vars.put("var", new ParamValue(String.valueOf(9), 9));
vars.put("param", new ParamValue(String.valueOf(9999), 9999));
// when
cmd.execute("var");
// then
verify(logger).printOut(":param var => 9");
verifyNoMoreInteractions(logger);
}
use of org.neo4j.shell.state.ParamValue in project neo4j by neo4j.
the class ParamsTest method runCommandWithUnknownArg.
@Test
public void runCommandWithUnknownArg() throws CommandException {
// then
thrown.expect(CommandException.class);
thrown.expectMessage(containsString("Unknown parameter: bob"));
// given
vars.put("var", new ParamValue(String.valueOf(9), 9));
// when
cmd.execute("bob");
}
use of org.neo4j.shell.state.ParamValue in project neo4j by neo4j.
the class ShellParameterMap method setParameter.
@Override
public Object setParameter(@Nonnull String name, @Nonnull String valueString) throws ParameterException {
String parameterName = CypherVariablesFormatter.unescapedCypherVariable(name);
try {
Object value = new Cypher(interpreter, ParameterException.FACTORY, new CypherCharStream(valueString)).Expression();
queryParams.put(parameterName, new ParamValue(valueString, toJavaObject(value)));
return value;
} catch (ParseException | UnsupportedOperationException e) {
try {
Object value = evaluator.evaluate(valueString, Object.class);
queryParams.put(parameterName, new ParamValue(valueString, toJavaObject(value)));
return value;
} catch (EvaluationException e1) {
throw new ParameterException(e1.getMessage());
}
}
}
use of org.neo4j.shell.state.ParamValue in project neo4j by neo4j.
the class ShellParameterMapTest method getUserInput.
@Test
public void getUserInput() throws ParameterException {
parameterMap.setParameter("`bob`", "99");
assertEquals(new ParamValue("99", 99L), parameterMap.getAllAsUserInput().get("bob"));
}
use of org.neo4j.shell.state.ParamValue in project neo4j by neo4j.
the class ParamsTest method runCommandWithSpecialCharacters.
@Test
public void runCommandWithSpecialCharacters() throws CommandException {
// given
vars.put("var `", new ParamValue(String.valueOf(9), 9));
vars.put("param", new ParamValue(String.valueOf(9999), 9999));
// when
cmd.execute("`var ```");
// then
verify(logger).printOut(":param `var ``` => 9");
verifyNoMoreInteractions(logger);
}
Aggregations