Search in sources :

Example 1 with Bindings

use of io.nosqlbench.virtdata.core.bindings.Bindings in project nosqlbench by nosqlbench.

the class IntegratedBindingsTest method testSetNamedFieldsIterated.

@Test
public void testSetNamedFieldsIterated() {
    Bindings bindings = VirtData.getTemplate("mod5", "Mod(5)", "mod7", "Mod(7)").resolveBindings();
    final StringBuilder sb = new StringBuilder();
    Bindings.FieldSetter fs = new Bindings.FieldSetter() {

        @Override
        public void setField(String name, Object value) {
            sb.append(name).append("=").append(value).append(";");
        }
    };
    bindings.setNamedFieldsIterated(fs, 12, 2, "mod5");
    assertThat(sb.toString()).isEqualTo("mod50=2;mod51=3;");
    bindings.setNamedFieldsIterated(fs, 12, 2, "mod7");
    assertThat(sb.toString()).isEqualTo("mod50=2;mod51=3;mod70=5;mod71=6;");
}
Also used : Bindings(io.nosqlbench.virtdata.core.bindings.Bindings) Test(org.junit.jupiter.api.Test)

Example 2 with Bindings

use of io.nosqlbench.virtdata.core.bindings.Bindings in project nosqlbench by nosqlbench.

the class IntegratedBindingsTest method testIteratedMaps.

@Test
public void testIteratedMaps() {
    Bindings bindings = VirtData.getTemplate("mod5", "Mod(5)", "mod7", "Mod(7)").resolveBindings();
    List<Map<String, Object>> maps = bindings.getIteratedMaps(11, 2);
    assertThat(maps).hasSize(2);
    assertThat(maps.get(0)).hasSize(2);
    assertThat(maps.get(1)).hasSize(2);
    assertThat(maps.get(0).get("mod5")).isEqualTo(1L);
    assertThat(maps.get(0).get("mod7")).isEqualTo(4L);
    assertThat(maps.get(1).get("mod5")).isEqualTo(2L);
    assertThat(maps.get(1).get("mod7")).isEqualTo(5L);
}
Also used : Bindings(io.nosqlbench.virtdata.core.bindings.Bindings) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) Test(org.junit.jupiter.api.Test)

Example 3 with Bindings

use of io.nosqlbench.virtdata.core.bindings.Bindings in project nosqlbench by nosqlbench.

the class IntegratedBindingsTest method testSetNamedFields.

@Test
public void testSetNamedFields() {
    Bindings bindings = VirtData.getTemplate("mod5", "Mod(5)", "mod7", "Mod(7)", "mod13", "Mod(13)").resolveBindings();
    final StringBuilder sb = new StringBuilder();
    Bindings.FieldSetter fs = new Bindings.FieldSetter() {

        @Override
        public void setField(String name, Object value) {
            sb.append(name).append("=").append(value).append(";");
        }
    };
    bindings.setNamedFields(fs, 12, "mod5", "mod7");
    assertThat(sb.toString()).isEqualTo("mod5=2;mod7=5;");
}
Also used : Bindings(io.nosqlbench.virtdata.core.bindings.Bindings) Test(org.junit.jupiter.api.Test)

Example 4 with Bindings

use of io.nosqlbench.virtdata.core.bindings.Bindings in project nosqlbench by nosqlbench.

the class IntegratedComposerLibraryTest method testChainedTypeResolutionForWithInternalLong.

@Test
public void testChainedTypeResolutionForWithInternalLong() {
    BindingsTemplate bt = new BindingsTemplate();
    bt.addFieldBinding("longchain", "compose HashRange(1234,6789) -> long; Mod(3) -> int;");
    Bindings bindings = bt.resolveBindings();
    Object n1 = bindings.getAll(123)[0];
    assertThat(n1).isOfAnyClassIn(Integer.class);
}
Also used : Bindings(io.nosqlbench.virtdata.core.bindings.Bindings) BindingsTemplate(io.nosqlbench.virtdata.core.bindings.BindingsTemplate) Test(org.junit.jupiter.api.Test)

Example 5 with Bindings

use of io.nosqlbench.virtdata.core.bindings.Bindings in project nosqlbench by nosqlbench.

the class IntegratedComposerLibraryTest method testStringConversion.

@Test
public void testStringConversion() {
    BindingsTemplate bt = new BindingsTemplate();
    bt.addFieldBinding("phone", "compose HashRange(1000000000,9999999999L); ToString() -> String");
    Bindings bindings = bt.resolveBindings();
}
Also used : Bindings(io.nosqlbench.virtdata.core.bindings.Bindings) BindingsTemplate(io.nosqlbench.virtdata.core.bindings.BindingsTemplate) Test(org.junit.jupiter.api.Test)

Aggregations

Bindings (io.nosqlbench.virtdata.core.bindings.Bindings)19 Test (org.junit.jupiter.api.Test)18 BindingsTemplate (io.nosqlbench.virtdata.core.bindings.BindingsTemplate)8 LinkedHashMap (java.util.LinkedHashMap)3 Disabled (org.junit.jupiter.api.Disabled)2 Binding (groovy.lang.Binding)1 GroovyShell (groovy.lang.GroovyShell)1 Script (groovy.lang.Script)1 Cqld4FluentGraphOpDispenser (io.nosqlbench.adapter.cqld4.opdispensers.Cqld4FluentGraphOpDispenser)1 OpConfigError (io.nosqlbench.nb.api.errors.OpConfigError)1 ParsedTemplate (io.nosqlbench.virtdata.core.templates.ParsedTemplate)1 Map (java.util.Map)1 GraphTraversalSource (org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource)1 CompilerConfiguration (org.codehaus.groovy.control.CompilerConfiguration)1 ImportCustomizer (org.codehaus.groovy.control.customizers.ImportCustomizer)1