mirror of
https://github.com/nosqlbench/nosqlbench.git
synced 2025-02-25 18:55:28 -06:00
generalize op field functions to cover maps
This commit is contained in:
@@ -28,17 +28,49 @@ public class ParsedOpTest {
|
||||
)
|
||||
),
|
||||
ConfigModel.of(ParsedOpTest.class)
|
||||
.add(Param.defaultTo("testcfg","testval"))
|
||||
.add(Param.defaultTo("testcfg", "testval"))
|
||||
.asReadOnly()
|
||||
.apply(Map.of())
|
||||
);
|
||||
|
||||
@Test
|
||||
public void testSubMapTemplates() {
|
||||
ParsedOp pop = new ParsedOp(
|
||||
new OpData().applyFields(Map.of(
|
||||
"op", Map.of(
|
||||
"field1-literal", "literalvalue1",
|
||||
"field2-object", "{{NumberNameToString()}}",
|
||||
"field3-template", "pre-{dyna1}-post",
|
||||
"field4-map-template", Map.of(
|
||||
"subfield1-object", "{{Identity(); ToString()}}"
|
||||
),"field5-map-literal", Map.of(
|
||||
"subfield2-literal", "LiteralValue"
|
||||
)
|
||||
),
|
||||
"bindings", Map.of(
|
||||
"dyna1", "NumberNameToString()"
|
||||
))
|
||||
),
|
||||
ConfigModel.of(ParsedOpTest.class)
|
||||
.add(Param.defaultTo("testcfg", "testval"))
|
||||
.asReadOnly()
|
||||
.apply(Map.of())
|
||||
);
|
||||
LongFunction<? extends String> f1 = pop.getAsRequiredFunction("field1-literal");
|
||||
LongFunction<? extends String> f2 = pop.getAsRequiredFunction("field2-object");
|
||||
LongFunction<? extends String> f3 = pop.getAsRequiredFunction("field3-template");
|
||||
LongFunction<? extends Map> f4 = pop.getAsRequiredFunction("field4-map-template",Map.class);
|
||||
LongFunction<? extends Map> f5 = pop.getAsRequiredFunction("field5-map-literal",Map.class);
|
||||
System.out.println("woo");
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testParsedOp() {
|
||||
Map<String, Object> m1 = pc.apply(0);
|
||||
assertThat(m1).containsEntry("stmt", "test");
|
||||
assertThat(m1).containsEntry("dyna1","zero");
|
||||
assertThat(m1).containsEntry("dyna2","zero");
|
||||
assertThat(m1).containsEntry("dyna1", "zero");
|
||||
assertThat(m1).containsEntry("dyna2", "zero");
|
||||
assertThat(m1).containsEntry("identity", 0L);
|
||||
}
|
||||
|
||||
@@ -46,20 +78,22 @@ public class ParsedOpTest {
|
||||
public void testNewListBinder() {
|
||||
LongFunction<List<Object>> lb = pc.newListBinder("dyna1", "identity", "dyna2", "identity");
|
||||
List<Object> objects = lb.apply(1);
|
||||
assertThat(objects).isEqualTo(List.of("one",1L,"one",1L));
|
||||
assertThat(objects).isEqualTo(List.of("one", 1L, "one", 1L));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNewMapBinder() {
|
||||
LongFunction<Map<String, Object>> mb = pc.newOrderedMapBinder("dyna1", "identity", "dyna2");
|
||||
Map<String, Object> objects = mb.apply(2);
|
||||
assertThat(objects).isEqualTo(Map.<String,Object>of("dyna1","two","identity",2L,"dyna2","two"));
|
||||
assertThat(objects).isEqualTo(Map.<String, Object>of("dyna1", "two", "identity", 2L, "dyna2", "two"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNewAryBinder() {
|
||||
LongFunction<Object[]> ab = pc.newArrayBinder("dyna1", "dyna1", "identity", "identity");
|
||||
Object[] objects = ab.apply(3);
|
||||
assertThat(objects).isEqualTo(new Object[]{"three","three",3L,3L});
|
||||
assertThat(objects).isEqualTo(new Object[]{"three", "three", 3L, 3L});
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user