mirror of
https://github.com/nosqlbench/nosqlbench.git
synced 2025-02-25 18:55:28 -06:00
scaffolding for namedscenario service example
This commit is contained in:
parent
15447300ad
commit
34ab6832c9
@ -20,18 +20,20 @@ package io.nosqlbench.engine.api.util;
|
||||
import io.nosqlbench.engine.api.activityimpl.ActivityDef;
|
||||
import org.apache.commons.text.StrLookup;
|
||||
import org.apache.commons.text.StrSubstitutor;
|
||||
import org.apache.commons.text.StringSubstitutor;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
|
||||
public class StrInterpolator implements Function<String, String> {
|
||||
|
||||
private MultiMap multimap = new MultiMap();
|
||||
private StrSubstitutor substitutor= new StrSubstitutor(multimap,"<<",">>",'\\');
|
||||
private StrSubstitutor substitutor2 = new StrSubstitutor(multimap, "TEMPLATE(", ")", '\\');
|
||||
private StringSubstitutor substitutor=
|
||||
new StringSubstitutor(multimap,"<<",">>",'\\')
|
||||
.setEnableSubstitutionInVariables(true);
|
||||
private StringSubstitutor substitutor2 =
|
||||
new StringSubstitutor(multimap, "TEMPLATE(", ")", '\\')
|
||||
.setEnableSubstitutionInVariables(true);
|
||||
|
||||
public StrInterpolator(ActivityDef... activityDefs) {
|
||||
Arrays.stream(activityDefs)
|
||||
@ -57,6 +59,12 @@ public class StrInterpolator implements Function<String, String> {
|
||||
return after;
|
||||
}
|
||||
|
||||
public LinkedHashMap<String,String> getTemplateDetails(String input) {
|
||||
LinkedHashMap<String,String> details = new LinkedHashMap<>();
|
||||
|
||||
return details;
|
||||
}
|
||||
|
||||
public static class MultiMap extends StrLookup<String> {
|
||||
|
||||
private List<Map<String, String>> maps = new ArrayList<>();
|
||||
@ -87,4 +95,5 @@ public class StrInterpolator implements Function<String, String> {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -19,10 +19,7 @@ package io.nosqlbench.engine.api.util;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@ -119,12 +116,20 @@ public class StrInterpolatorTest {
|
||||
assertThat(a).isEqualTo("'Key': 'Value'.'Stuff'");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldExpandNestedTemplates() {
|
||||
String a = interp.apply("-TEMPLATE(akey,TEMPLATE(dkey,whee)-");
|
||||
assertThat(a).isEqualTo("-aval1-");
|
||||
String b = interp.apply("-TEMPLATE(unknown,TEMPLATE(bkey,whee))-");
|
||||
assertThat(b).isEqualTo("-bval1-");
|
||||
}
|
||||
|
||||
// @Test
|
||||
// public void shouldExpandNestedTemplates() {
|
||||
// String a = interp.apply("-TEMPLATE(akey,TEMPLATE(dkey,whee)-");
|
||||
// assertThat(a).isEqualTo("-aval1-");
|
||||
// String b = interp.apply("-TEMPLATE(unknown,TEMPLATE(bkey,whee))-");
|
||||
// assertThat(b).isEqualTo("-bval1-");
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// public void shouldGetBasicDetails() {
|
||||
// LinkedHashMap<String, String> details = interp.getTemplateDetails("-TEMPLATE(akey,TEMPLATE(dkey,whee)-");
|
||||
// assertThat(details).containsOnlyKeys("akey","dkey");
|
||||
// assertThat(details).containsValues("test1");
|
||||
//
|
||||
// }
|
||||
//
|
||||
}
|
||||
|
@ -141,13 +141,13 @@ public class NBCLIScenarioParser {
|
||||
}
|
||||
|
||||
public boolean isReassignable() {
|
||||
return "=".equals(operator);
|
||||
return UNLOCKED.equals(operator);
|
||||
}
|
||||
public boolean isFinalSilent() {
|
||||
return "==".equals(operator);
|
||||
return SILENT_LOCKED.equals(operator);
|
||||
}
|
||||
public boolean isFinalVerbose() {
|
||||
return "===".equals(operator);
|
||||
return VERBOSE_LOCKED.equals(operator);
|
||||
}
|
||||
|
||||
|
||||
|
@ -0,0 +1,25 @@
|
||||
package io.nosqlbench.engine.services;
|
||||
|
||||
import com.fasterxml.jackson.jaxrs.annotation.JacksonFeatures;
|
||||
import io.nosqlbench.docsys.api.WebServiceObject;
|
||||
import io.nosqlbench.nb.api.annotations.Service;
|
||||
|
||||
import javax.inject.Singleton;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.Path;
|
||||
|
||||
@Service(WebServiceObject.class)
|
||||
@Singleton
|
||||
@Path("/services/namedscenarios/")
|
||||
public class ScenarioTemplateService implements WebServiceObject {
|
||||
|
||||
public ScenarioTemplateService() {
|
||||
super();
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("service-status")
|
||||
public String status() {
|
||||
return "Here at " + System.nanoTime();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user