mirror of
https://github.com/nosqlbench/nosqlbench.git
synced 2025-02-25 18:55:28 -06:00
require typed construction of CommandTemplate
This commit is contained in:
@@ -60,14 +60,14 @@ public class CommandTemplate {
|
||||
* is non-null, then it taken as a line-oriented value and parsed according to default {@link ParamsParser} behavior.
|
||||
* However, the provided parsers (if any) are used first in order to match alternate forms of syntax.
|
||||
*
|
||||
* See {@link CommandTemplate#CommandTemplate(String, Object, Map, Map, List)} for full details on the provided
|
||||
* See {@link CommandTemplate#CommandTemplate(String, String, Map, Map, List)} for full details on the provided
|
||||
* parsers.
|
||||
*
|
||||
* @param optpl An OpTemplate
|
||||
* @param parsers A list of parser functions
|
||||
*/
|
||||
public CommandTemplate(OpTemplate optpl, List<Function<String, Map<String, String>>> parsers) {
|
||||
this(optpl.getName(), optpl.getOp(), optpl.getParamsAsValueType(String.class), optpl.getBindings(), parsers);
|
||||
this(optpl.getName(), optpl.getStmt().orElseThrow(), optpl.getParamsAsValueType(String.class), optpl.getBindings(), parsers);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -94,7 +94,7 @@ public class CommandTemplate {
|
||||
*/
|
||||
public CommandTemplate(
|
||||
String name,
|
||||
Object op,
|
||||
String op,
|
||||
Map<String, String> params,
|
||||
Map<String, String> bindings,
|
||||
List<Function<String, Map<String, String>>> optionalParsers
|
||||
@@ -108,8 +108,9 @@ public class CommandTemplate {
|
||||
// If none of the supplemental parsers work, the default params parser is used
|
||||
|
||||
String oneline;
|
||||
|
||||
if (op instanceof CharSequence) {
|
||||
oneline = op.toString();
|
||||
oneline = op;
|
||||
} else {
|
||||
throw new BasicError("Unable to create a oneline version of the CommandTemplate with op type of " + op.getClass().getSimpleName());
|
||||
}
|
||||
|
||||
@@ -16,8 +16,8 @@ public class CommandTemplateTest {
|
||||
StmtsDocList stmtsDocs = StatementsLoader.loadString("" +
|
||||
"statements:\n" +
|
||||
" - s1: test1=foo test2=bar");
|
||||
OpTemplate stmtDef = stmtsDocs.getStmts().get(0);
|
||||
CommandTemplate ct = new CommandTemplate(stmtDef);
|
||||
OpTemplate optpl = stmtsDocs.getStmts().get(0);
|
||||
CommandTemplate ct = new CommandTemplate(optpl);
|
||||
assertThat(ct.isStatic()).isTrue();
|
||||
}
|
||||
|
||||
@@ -29,8 +29,8 @@ public class CommandTemplateTest {
|
||||
" - s1: test1=foo test2={bar}\n" +
|
||||
" bindings:\n" +
|
||||
" bar: NumberNameToString();\n");
|
||||
OpTemplate stmtDef = stmtsDocs.getStmts().get(0);
|
||||
CommandTemplate ct = new CommandTemplate(stmtDef);
|
||||
OpTemplate optpl = stmtsDocs.getStmts().get(0);
|
||||
CommandTemplate ct = new CommandTemplate(optpl);
|
||||
String format = gson.toJson(ct);
|
||||
System.out.println(format);
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ public class VirtData {
|
||||
}
|
||||
List<BindPoint> bindPoints = new ArrayList<>();
|
||||
for (int i = 0; i < namesAndSpecs.length; i += 2) {
|
||||
bindPoints.add(new BindPoint(namesAndSpecs[i],namesAndSpecs[i+1]));
|
||||
bindPoints.add(new BindPoint(namesAndSpecs[i],namesAndSpecs[i+1], BindPoint.Type.definition));
|
||||
}
|
||||
return getTemplate(config, bindPoints);
|
||||
}
|
||||
@@ -169,7 +169,7 @@ public class VirtData {
|
||||
T actualTestValue = mapper.get().get(1L);
|
||||
if (!ClassUtils.isAssignable(actualTestValue.getClass(),clazz,true)) {
|
||||
throw new RuntimeException("The flow specifier '" + flowSpec + "' successfully created a function, but the test value" +
|
||||
"(" + String.valueOf(actualTestValue) + ") of type [" + actualTestValue.getClass() + "] produced by it was not " +
|
||||
"(" + actualTestValue + ") of type [" + actualTestValue.getClass() + "] produced by it was not " +
|
||||
"assignable to the type '" + clazz.getCanonicalName() + "' which was explicitly set" +
|
||||
" at the API level.");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user