repo_name
stringlengths
7
104
file_path
stringlengths
13
198
context
stringlengths
67
7.15k
import_statement
stringlengths
16
4.43k
code
stringlengths
40
6.98k
prompt
stringlengths
227
8.27k
next_line
stringlengths
8
795
presidentio/test-data-generator
src/main/java/com/presidentio/testdatagenerator/OneTimeGenerator.java
// Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java // public class Context { // // private Parent parent; // // private Map<String, Template> templates; // // private Map<String, Object> variables; // // private Sink sink; // // public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) { // this.templates = templates; // this.variables = variables; // this.sink = sink; // } // // public Context(Context parentContext, Map<String, Object> entity) { // parent = new Parent(entity, parentContext.getParent()); // templates = parentContext.getTemplates(); // variables = parentContext.getVariables(); // sink = parentContext.getSink(); // } // // public Parent getParent() { // return parent; // } // // public Map<String, Object> getVariables() { // return variables; // } // // public Sink getSink() { // return sink; // } // // public Map<String, Template> getTemplates() { // return templates; // } // // } // // Path: src/main/java/com/presidentio/testdatagenerator/model/Schema.java // public class Schema { // // private List<Template> templates = new ArrayList<>(); // // private List<String> root = new ArrayList<>(); // // private List<Variable> variables = new ArrayList<>(); // // private Output output; // // public List<Template> getTemplates() { // return templates; // } // // public void setTemplates(List<Template> templates) { // this.templates = templates; // } // // public List<String> getRoot() { // return root; // } // // public void setRoot(List<String> root) { // this.root = root; // } // // public List<Variable> getVariables() { // return variables; // } // // public void setVariables(List<Variable> variables) { // this.variables = variables; // } // // public Output getOutput() { // return output; // } // // public void setOutput(Output output) { // this.output = output; // } // }
import com.presidentio.testdatagenerator.model.Schema; import java.util.concurrent.ForkJoinPool; import com.presidentio.testdatagenerator.context.Context;
/** * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * <p> * http://www.apache.org/licenses/LICENSE-2.0 * <p> * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.presidentio.testdatagenerator; public class OneTimeGenerator extends AbstractGenerator { private boolean async = false; private Integer threadCount = Runtime.getRuntime().availableProcessors(); @Override
// Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java // public class Context { // // private Parent parent; // // private Map<String, Template> templates; // // private Map<String, Object> variables; // // private Sink sink; // // public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) { // this.templates = templates; // this.variables = variables; // this.sink = sink; // } // // public Context(Context parentContext, Map<String, Object> entity) { // parent = new Parent(entity, parentContext.getParent()); // templates = parentContext.getTemplates(); // variables = parentContext.getVariables(); // sink = parentContext.getSink(); // } // // public Parent getParent() { // return parent; // } // // public Map<String, Object> getVariables() { // return variables; // } // // public Sink getSink() { // return sink; // } // // public Map<String, Template> getTemplates() { // return templates; // } // // } // // Path: src/main/java/com/presidentio/testdatagenerator/model/Schema.java // public class Schema { // // private List<Template> templates = new ArrayList<>(); // // private List<String> root = new ArrayList<>(); // // private List<Variable> variables = new ArrayList<>(); // // private Output output; // // public List<Template> getTemplates() { // return templates; // } // // public void setTemplates(List<Template> templates) { // this.templates = templates; // } // // public List<String> getRoot() { // return root; // } // // public void setRoot(List<String> root) { // this.root = root; // } // // public List<Variable> getVariables() { // return variables; // } // // public void setVariables(List<Variable> variables) { // this.variables = variables; // } // // public Output getOutput() { // return output; // } // // public void setOutput(Output output) { // this.output = output; // } // } // Path: src/main/java/com/presidentio/testdatagenerator/OneTimeGenerator.java import com.presidentio.testdatagenerator.model.Schema; import java.util.concurrent.ForkJoinPool; import com.presidentio.testdatagenerator.context.Context; /** * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * <p> * http://www.apache.org/licenses/LICENSE-2.0 * <p> * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.presidentio.testdatagenerator; public class OneTimeGenerator extends AbstractGenerator { private boolean async = false; private Integer threadCount = Runtime.getRuntime().availableProcessors(); @Override
public void generate(Context context, Schema schema) {
presidentio/test-data-generator
src/main/java/com/presidentio/testdatagenerator/parser/StringDeserializer.java
// Path: src/main/java/com/presidentio/testdatagenerator/cons/StringPlaceholderConst.java // public class StringPlaceholderConst { // // public static final String TMP = "tmp"; // // }
import com.presidentio.testdatagenerator.cons.StringPlaceholderConst; import org.codehaus.jackson.JsonParser; import org.codehaus.jackson.map.DeserializationContext; import org.codehaus.jackson.map.JsonDeserializer; import java.io.IOException; import java.util.regex.Matcher; import java.util.regex.Pattern;
package com.presidentio.testdatagenerator.parser; public class StringDeserializer extends JsonDeserializer<String> { private static final Pattern REGEX = Pattern.compile("\\$\\{(\\w+)}"); @Override public String deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException { String str = jsonParser.getText(); return formatString(str); } public String formatString(String s) { Matcher matcher = REGEX.matcher(s); StringBuilder result = new StringBuilder(); int curIndex = 0; while (matcher.find()) { String group = matcher.group(1); result.append(s.substring(curIndex, matcher.start())); result.append(evaluate(group)); curIndex = matcher.end(); } result.append(s.substring(curIndex, s.length())); return result.toString(); } private String evaluate(String s) { switch (s) {
// Path: src/main/java/com/presidentio/testdatagenerator/cons/StringPlaceholderConst.java // public class StringPlaceholderConst { // // public static final String TMP = "tmp"; // // } // Path: src/main/java/com/presidentio/testdatagenerator/parser/StringDeserializer.java import com.presidentio.testdatagenerator.cons.StringPlaceholderConst; import org.codehaus.jackson.JsonParser; import org.codehaus.jackson.map.DeserializationContext; import org.codehaus.jackson.map.JsonDeserializer; import java.io.IOException; import java.util.regex.Matcher; import java.util.regex.Pattern; package com.presidentio.testdatagenerator.parser; public class StringDeserializer extends JsonDeserializer<String> { private static final Pattern REGEX = Pattern.compile("\\$\\{(\\w+)}"); @Override public String deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException { String str = jsonParser.getText(); return formatString(str); } public String formatString(String s) { Matcher matcher = REGEX.matcher(s); StringBuilder result = new StringBuilder(); int curIndex = 0; while (matcher.find()) { String group = matcher.group(1); result.append(s.substring(curIndex, matcher.start())); result.append(evaluate(group)); curIndex = matcher.end(); } result.append(s.substring(curIndex, s.length())); return result.toString(); } private String evaluate(String s) { switch (s) {
case StringPlaceholderConst.TMP:
presidentio/test-data-generator
src/test/java/com/presidentio/testdatagenerator/provider/ConstValueProviderTest.java
// Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java // public class PropConst { // // public static final String TYPE = "type"; // public static final String VALUE = "value"; // public static final String SIZE = "size"; // public static final String DOMAIN = "domain"; // public static final String EXPR = "expr"; // public static final String FILE = "file"; // public static final String DELIMITER = "delimiter"; // public static final String ITEMS = "items"; // public static final String INDEX = "index"; // public static final String HOST = "host"; // public static final String PORT = "port"; // public static final String CLUSTER_NAME = "clusterName"; // public static final String CONNECTION_URL = "connectionUrl"; // public static final String JDBC_DRIVER = "jdbcDriver"; // public static final String DEPTH = "depth"; // public static final String FIELD = "field"; // public static final String VAR = "var"; // public static final String OP = "op"; // public static final String FORMAT = "format"; // public static final String HEADER = "header"; // public static final String SUFFIX = "suffix"; // public static final String PREFIX = "prefix"; // public static final String PATH_PROVIDER = "pathProvider"; // public static final String BROKER_LIST = "brokerList"; // public static final String GENDER = "gender"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/cons/TypeConst.java // public class TypeConst { // // public static final String STRING = "string"; // public static final String LONG = "long"; // public static final String INT = "int"; // public static final String BOOLEAN = "boolean"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java // public class Context { // // private Parent parent; // // private Map<String, Template> templates; // // private Map<String, Object> variables; // // private Sink sink; // // public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) { // this.templates = templates; // this.variables = variables; // this.sink = sink; // } // // public Context(Context parentContext, Map<String, Object> entity) { // parent = new Parent(entity, parentContext.getParent()); // templates = parentContext.getTemplates(); // variables = parentContext.getVariables(); // sink = parentContext.getSink(); // } // // public Parent getParent() { // return parent; // } // // public Map<String, Object> getVariables() { // return variables; // } // // public Sink getSink() { // return sink; // } // // public Map<String, Template> getTemplates() { // return templates; // } // // } // // Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java // public class Field { // // private String name; // // private String type; // // private Provider provider; // // public Field() { // } // // public Field(String name, String type, Provider provider) { // this.name = name; // this.type = type; // this.provider = provider; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // public Provider getProvider() { // return provider; // } // // public void setProvider(Provider provider) { // this.provider = provider; // } // }
import com.presidentio.testdatagenerator.cons.PropConst; import com.presidentio.testdatagenerator.cons.TypeConst; import com.presidentio.testdatagenerator.context.Context; import com.presidentio.testdatagenerator.model.Field; import org.junit.Assert; import org.junit.Test; import java.util.Collections; import java.util.HashMap; import java.util.Map;
/** * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.presidentio.testdatagenerator.provider; public class ConstValueProviderTest { @Test(expected = IllegalArgumentException.class) public void testRequiredProp() throws Exception { new ConstValueProvider().init(Collections.<String, String>emptyMap()); } @Test public void testNextValue() throws Exception { Map<String, String> props = new HashMap<>(); String propValue = "123";
// Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java // public class PropConst { // // public static final String TYPE = "type"; // public static final String VALUE = "value"; // public static final String SIZE = "size"; // public static final String DOMAIN = "domain"; // public static final String EXPR = "expr"; // public static final String FILE = "file"; // public static final String DELIMITER = "delimiter"; // public static final String ITEMS = "items"; // public static final String INDEX = "index"; // public static final String HOST = "host"; // public static final String PORT = "port"; // public static final String CLUSTER_NAME = "clusterName"; // public static final String CONNECTION_URL = "connectionUrl"; // public static final String JDBC_DRIVER = "jdbcDriver"; // public static final String DEPTH = "depth"; // public static final String FIELD = "field"; // public static final String VAR = "var"; // public static final String OP = "op"; // public static final String FORMAT = "format"; // public static final String HEADER = "header"; // public static final String SUFFIX = "suffix"; // public static final String PREFIX = "prefix"; // public static final String PATH_PROVIDER = "pathProvider"; // public static final String BROKER_LIST = "brokerList"; // public static final String GENDER = "gender"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/cons/TypeConst.java // public class TypeConst { // // public static final String STRING = "string"; // public static final String LONG = "long"; // public static final String INT = "int"; // public static final String BOOLEAN = "boolean"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java // public class Context { // // private Parent parent; // // private Map<String, Template> templates; // // private Map<String, Object> variables; // // private Sink sink; // // public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) { // this.templates = templates; // this.variables = variables; // this.sink = sink; // } // // public Context(Context parentContext, Map<String, Object> entity) { // parent = new Parent(entity, parentContext.getParent()); // templates = parentContext.getTemplates(); // variables = parentContext.getVariables(); // sink = parentContext.getSink(); // } // // public Parent getParent() { // return parent; // } // // public Map<String, Object> getVariables() { // return variables; // } // // public Sink getSink() { // return sink; // } // // public Map<String, Template> getTemplates() { // return templates; // } // // } // // Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java // public class Field { // // private String name; // // private String type; // // private Provider provider; // // public Field() { // } // // public Field(String name, String type, Provider provider) { // this.name = name; // this.type = type; // this.provider = provider; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // public Provider getProvider() { // return provider; // } // // public void setProvider(Provider provider) { // this.provider = provider; // } // } // Path: src/test/java/com/presidentio/testdatagenerator/provider/ConstValueProviderTest.java import com.presidentio.testdatagenerator.cons.PropConst; import com.presidentio.testdatagenerator.cons.TypeConst; import com.presidentio.testdatagenerator.context.Context; import com.presidentio.testdatagenerator.model.Field; import org.junit.Assert; import org.junit.Test; import java.util.Collections; import java.util.HashMap; import java.util.Map; /** * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.presidentio.testdatagenerator.provider; public class ConstValueProviderTest { @Test(expected = IllegalArgumentException.class) public void testRequiredProp() throws Exception { new ConstValueProvider().init(Collections.<String, String>emptyMap()); } @Test public void testNextValue() throws Exception { Map<String, String> props = new HashMap<>(); String propValue = "123";
props.put(PropConst.VALUE, propValue);
presidentio/test-data-generator
src/test/java/com/presidentio/testdatagenerator/provider/ConstValueProviderTest.java
// Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java // public class PropConst { // // public static final String TYPE = "type"; // public static final String VALUE = "value"; // public static final String SIZE = "size"; // public static final String DOMAIN = "domain"; // public static final String EXPR = "expr"; // public static final String FILE = "file"; // public static final String DELIMITER = "delimiter"; // public static final String ITEMS = "items"; // public static final String INDEX = "index"; // public static final String HOST = "host"; // public static final String PORT = "port"; // public static final String CLUSTER_NAME = "clusterName"; // public static final String CONNECTION_URL = "connectionUrl"; // public static final String JDBC_DRIVER = "jdbcDriver"; // public static final String DEPTH = "depth"; // public static final String FIELD = "field"; // public static final String VAR = "var"; // public static final String OP = "op"; // public static final String FORMAT = "format"; // public static final String HEADER = "header"; // public static final String SUFFIX = "suffix"; // public static final String PREFIX = "prefix"; // public static final String PATH_PROVIDER = "pathProvider"; // public static final String BROKER_LIST = "brokerList"; // public static final String GENDER = "gender"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/cons/TypeConst.java // public class TypeConst { // // public static final String STRING = "string"; // public static final String LONG = "long"; // public static final String INT = "int"; // public static final String BOOLEAN = "boolean"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java // public class Context { // // private Parent parent; // // private Map<String, Template> templates; // // private Map<String, Object> variables; // // private Sink sink; // // public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) { // this.templates = templates; // this.variables = variables; // this.sink = sink; // } // // public Context(Context parentContext, Map<String, Object> entity) { // parent = new Parent(entity, parentContext.getParent()); // templates = parentContext.getTemplates(); // variables = parentContext.getVariables(); // sink = parentContext.getSink(); // } // // public Parent getParent() { // return parent; // } // // public Map<String, Object> getVariables() { // return variables; // } // // public Sink getSink() { // return sink; // } // // public Map<String, Template> getTemplates() { // return templates; // } // // } // // Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java // public class Field { // // private String name; // // private String type; // // private Provider provider; // // public Field() { // } // // public Field(String name, String type, Provider provider) { // this.name = name; // this.type = type; // this.provider = provider; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // public Provider getProvider() { // return provider; // } // // public void setProvider(Provider provider) { // this.provider = provider; // } // }
import com.presidentio.testdatagenerator.cons.PropConst; import com.presidentio.testdatagenerator.cons.TypeConst; import com.presidentio.testdatagenerator.context.Context; import com.presidentio.testdatagenerator.model.Field; import org.junit.Assert; import org.junit.Test; import java.util.Collections; import java.util.HashMap; import java.util.Map;
/** * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.presidentio.testdatagenerator.provider; public class ConstValueProviderTest { @Test(expected = IllegalArgumentException.class) public void testRequiredProp() throws Exception { new ConstValueProvider().init(Collections.<String, String>emptyMap()); } @Test public void testNextValue() throws Exception { Map<String, String> props = new HashMap<>(); String propValue = "123"; props.put(PropConst.VALUE, propValue); ConstValueProvider constValueProvider = new ConstValueProvider(); constValueProvider.init(props);
// Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java // public class PropConst { // // public static final String TYPE = "type"; // public static final String VALUE = "value"; // public static final String SIZE = "size"; // public static final String DOMAIN = "domain"; // public static final String EXPR = "expr"; // public static final String FILE = "file"; // public static final String DELIMITER = "delimiter"; // public static final String ITEMS = "items"; // public static final String INDEX = "index"; // public static final String HOST = "host"; // public static final String PORT = "port"; // public static final String CLUSTER_NAME = "clusterName"; // public static final String CONNECTION_URL = "connectionUrl"; // public static final String JDBC_DRIVER = "jdbcDriver"; // public static final String DEPTH = "depth"; // public static final String FIELD = "field"; // public static final String VAR = "var"; // public static final String OP = "op"; // public static final String FORMAT = "format"; // public static final String HEADER = "header"; // public static final String SUFFIX = "suffix"; // public static final String PREFIX = "prefix"; // public static final String PATH_PROVIDER = "pathProvider"; // public static final String BROKER_LIST = "brokerList"; // public static final String GENDER = "gender"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/cons/TypeConst.java // public class TypeConst { // // public static final String STRING = "string"; // public static final String LONG = "long"; // public static final String INT = "int"; // public static final String BOOLEAN = "boolean"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java // public class Context { // // private Parent parent; // // private Map<String, Template> templates; // // private Map<String, Object> variables; // // private Sink sink; // // public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) { // this.templates = templates; // this.variables = variables; // this.sink = sink; // } // // public Context(Context parentContext, Map<String, Object> entity) { // parent = new Parent(entity, parentContext.getParent()); // templates = parentContext.getTemplates(); // variables = parentContext.getVariables(); // sink = parentContext.getSink(); // } // // public Parent getParent() { // return parent; // } // // public Map<String, Object> getVariables() { // return variables; // } // // public Sink getSink() { // return sink; // } // // public Map<String, Template> getTemplates() { // return templates; // } // // } // // Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java // public class Field { // // private String name; // // private String type; // // private Provider provider; // // public Field() { // } // // public Field(String name, String type, Provider provider) { // this.name = name; // this.type = type; // this.provider = provider; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // public Provider getProvider() { // return provider; // } // // public void setProvider(Provider provider) { // this.provider = provider; // } // } // Path: src/test/java/com/presidentio/testdatagenerator/provider/ConstValueProviderTest.java import com.presidentio.testdatagenerator.cons.PropConst; import com.presidentio.testdatagenerator.cons.TypeConst; import com.presidentio.testdatagenerator.context.Context; import com.presidentio.testdatagenerator.model.Field; import org.junit.Assert; import org.junit.Test; import java.util.Collections; import java.util.HashMap; import java.util.Map; /** * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.presidentio.testdatagenerator.provider; public class ConstValueProviderTest { @Test(expected = IllegalArgumentException.class) public void testRequiredProp() throws Exception { new ConstValueProvider().init(Collections.<String, String>emptyMap()); } @Test public void testNextValue() throws Exception { Map<String, String> props = new HashMap<>(); String propValue = "123"; props.put(PropConst.VALUE, propValue); ConstValueProvider constValueProvider = new ConstValueProvider(); constValueProvider.init(props);
Object result = constValueProvider.nextValue(new Context(null, null, null), new Field("testField", TypeConst.STRING, null));
presidentio/test-data-generator
src/test/java/com/presidentio/testdatagenerator/provider/ConstValueProviderTest.java
// Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java // public class PropConst { // // public static final String TYPE = "type"; // public static final String VALUE = "value"; // public static final String SIZE = "size"; // public static final String DOMAIN = "domain"; // public static final String EXPR = "expr"; // public static final String FILE = "file"; // public static final String DELIMITER = "delimiter"; // public static final String ITEMS = "items"; // public static final String INDEX = "index"; // public static final String HOST = "host"; // public static final String PORT = "port"; // public static final String CLUSTER_NAME = "clusterName"; // public static final String CONNECTION_URL = "connectionUrl"; // public static final String JDBC_DRIVER = "jdbcDriver"; // public static final String DEPTH = "depth"; // public static final String FIELD = "field"; // public static final String VAR = "var"; // public static final String OP = "op"; // public static final String FORMAT = "format"; // public static final String HEADER = "header"; // public static final String SUFFIX = "suffix"; // public static final String PREFIX = "prefix"; // public static final String PATH_PROVIDER = "pathProvider"; // public static final String BROKER_LIST = "brokerList"; // public static final String GENDER = "gender"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/cons/TypeConst.java // public class TypeConst { // // public static final String STRING = "string"; // public static final String LONG = "long"; // public static final String INT = "int"; // public static final String BOOLEAN = "boolean"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java // public class Context { // // private Parent parent; // // private Map<String, Template> templates; // // private Map<String, Object> variables; // // private Sink sink; // // public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) { // this.templates = templates; // this.variables = variables; // this.sink = sink; // } // // public Context(Context parentContext, Map<String, Object> entity) { // parent = new Parent(entity, parentContext.getParent()); // templates = parentContext.getTemplates(); // variables = parentContext.getVariables(); // sink = parentContext.getSink(); // } // // public Parent getParent() { // return parent; // } // // public Map<String, Object> getVariables() { // return variables; // } // // public Sink getSink() { // return sink; // } // // public Map<String, Template> getTemplates() { // return templates; // } // // } // // Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java // public class Field { // // private String name; // // private String type; // // private Provider provider; // // public Field() { // } // // public Field(String name, String type, Provider provider) { // this.name = name; // this.type = type; // this.provider = provider; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // public Provider getProvider() { // return provider; // } // // public void setProvider(Provider provider) { // this.provider = provider; // } // }
import com.presidentio.testdatagenerator.cons.PropConst; import com.presidentio.testdatagenerator.cons.TypeConst; import com.presidentio.testdatagenerator.context.Context; import com.presidentio.testdatagenerator.model.Field; import org.junit.Assert; import org.junit.Test; import java.util.Collections; import java.util.HashMap; import java.util.Map;
/** * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.presidentio.testdatagenerator.provider; public class ConstValueProviderTest { @Test(expected = IllegalArgumentException.class) public void testRequiredProp() throws Exception { new ConstValueProvider().init(Collections.<String, String>emptyMap()); } @Test public void testNextValue() throws Exception { Map<String, String> props = new HashMap<>(); String propValue = "123"; props.put(PropConst.VALUE, propValue); ConstValueProvider constValueProvider = new ConstValueProvider(); constValueProvider.init(props);
// Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java // public class PropConst { // // public static final String TYPE = "type"; // public static final String VALUE = "value"; // public static final String SIZE = "size"; // public static final String DOMAIN = "domain"; // public static final String EXPR = "expr"; // public static final String FILE = "file"; // public static final String DELIMITER = "delimiter"; // public static final String ITEMS = "items"; // public static final String INDEX = "index"; // public static final String HOST = "host"; // public static final String PORT = "port"; // public static final String CLUSTER_NAME = "clusterName"; // public static final String CONNECTION_URL = "connectionUrl"; // public static final String JDBC_DRIVER = "jdbcDriver"; // public static final String DEPTH = "depth"; // public static final String FIELD = "field"; // public static final String VAR = "var"; // public static final String OP = "op"; // public static final String FORMAT = "format"; // public static final String HEADER = "header"; // public static final String SUFFIX = "suffix"; // public static final String PREFIX = "prefix"; // public static final String PATH_PROVIDER = "pathProvider"; // public static final String BROKER_LIST = "brokerList"; // public static final String GENDER = "gender"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/cons/TypeConst.java // public class TypeConst { // // public static final String STRING = "string"; // public static final String LONG = "long"; // public static final String INT = "int"; // public static final String BOOLEAN = "boolean"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java // public class Context { // // private Parent parent; // // private Map<String, Template> templates; // // private Map<String, Object> variables; // // private Sink sink; // // public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) { // this.templates = templates; // this.variables = variables; // this.sink = sink; // } // // public Context(Context parentContext, Map<String, Object> entity) { // parent = new Parent(entity, parentContext.getParent()); // templates = parentContext.getTemplates(); // variables = parentContext.getVariables(); // sink = parentContext.getSink(); // } // // public Parent getParent() { // return parent; // } // // public Map<String, Object> getVariables() { // return variables; // } // // public Sink getSink() { // return sink; // } // // public Map<String, Template> getTemplates() { // return templates; // } // // } // // Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java // public class Field { // // private String name; // // private String type; // // private Provider provider; // // public Field() { // } // // public Field(String name, String type, Provider provider) { // this.name = name; // this.type = type; // this.provider = provider; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // public Provider getProvider() { // return provider; // } // // public void setProvider(Provider provider) { // this.provider = provider; // } // } // Path: src/test/java/com/presidentio/testdatagenerator/provider/ConstValueProviderTest.java import com.presidentio.testdatagenerator.cons.PropConst; import com.presidentio.testdatagenerator.cons.TypeConst; import com.presidentio.testdatagenerator.context.Context; import com.presidentio.testdatagenerator.model.Field; import org.junit.Assert; import org.junit.Test; import java.util.Collections; import java.util.HashMap; import java.util.Map; /** * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.presidentio.testdatagenerator.provider; public class ConstValueProviderTest { @Test(expected = IllegalArgumentException.class) public void testRequiredProp() throws Exception { new ConstValueProvider().init(Collections.<String, String>emptyMap()); } @Test public void testNextValue() throws Exception { Map<String, String> props = new HashMap<>(); String propValue = "123"; props.put(PropConst.VALUE, propValue); ConstValueProvider constValueProvider = new ConstValueProvider(); constValueProvider.init(props);
Object result = constValueProvider.nextValue(new Context(null, null, null), new Field("testField", TypeConst.STRING, null));
presidentio/test-data-generator
src/test/java/com/presidentio/testdatagenerator/provider/ConstValueProviderTest.java
// Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java // public class PropConst { // // public static final String TYPE = "type"; // public static final String VALUE = "value"; // public static final String SIZE = "size"; // public static final String DOMAIN = "domain"; // public static final String EXPR = "expr"; // public static final String FILE = "file"; // public static final String DELIMITER = "delimiter"; // public static final String ITEMS = "items"; // public static final String INDEX = "index"; // public static final String HOST = "host"; // public static final String PORT = "port"; // public static final String CLUSTER_NAME = "clusterName"; // public static final String CONNECTION_URL = "connectionUrl"; // public static final String JDBC_DRIVER = "jdbcDriver"; // public static final String DEPTH = "depth"; // public static final String FIELD = "field"; // public static final String VAR = "var"; // public static final String OP = "op"; // public static final String FORMAT = "format"; // public static final String HEADER = "header"; // public static final String SUFFIX = "suffix"; // public static final String PREFIX = "prefix"; // public static final String PATH_PROVIDER = "pathProvider"; // public static final String BROKER_LIST = "brokerList"; // public static final String GENDER = "gender"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/cons/TypeConst.java // public class TypeConst { // // public static final String STRING = "string"; // public static final String LONG = "long"; // public static final String INT = "int"; // public static final String BOOLEAN = "boolean"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java // public class Context { // // private Parent parent; // // private Map<String, Template> templates; // // private Map<String, Object> variables; // // private Sink sink; // // public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) { // this.templates = templates; // this.variables = variables; // this.sink = sink; // } // // public Context(Context parentContext, Map<String, Object> entity) { // parent = new Parent(entity, parentContext.getParent()); // templates = parentContext.getTemplates(); // variables = parentContext.getVariables(); // sink = parentContext.getSink(); // } // // public Parent getParent() { // return parent; // } // // public Map<String, Object> getVariables() { // return variables; // } // // public Sink getSink() { // return sink; // } // // public Map<String, Template> getTemplates() { // return templates; // } // // } // // Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java // public class Field { // // private String name; // // private String type; // // private Provider provider; // // public Field() { // } // // public Field(String name, String type, Provider provider) { // this.name = name; // this.type = type; // this.provider = provider; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // public Provider getProvider() { // return provider; // } // // public void setProvider(Provider provider) { // this.provider = provider; // } // }
import com.presidentio.testdatagenerator.cons.PropConst; import com.presidentio.testdatagenerator.cons.TypeConst; import com.presidentio.testdatagenerator.context.Context; import com.presidentio.testdatagenerator.model.Field; import org.junit.Assert; import org.junit.Test; import java.util.Collections; import java.util.HashMap; import java.util.Map;
/** * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.presidentio.testdatagenerator.provider; public class ConstValueProviderTest { @Test(expected = IllegalArgumentException.class) public void testRequiredProp() throws Exception { new ConstValueProvider().init(Collections.<String, String>emptyMap()); } @Test public void testNextValue() throws Exception { Map<String, String> props = new HashMap<>(); String propValue = "123"; props.put(PropConst.VALUE, propValue); ConstValueProvider constValueProvider = new ConstValueProvider(); constValueProvider.init(props);
// Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java // public class PropConst { // // public static final String TYPE = "type"; // public static final String VALUE = "value"; // public static final String SIZE = "size"; // public static final String DOMAIN = "domain"; // public static final String EXPR = "expr"; // public static final String FILE = "file"; // public static final String DELIMITER = "delimiter"; // public static final String ITEMS = "items"; // public static final String INDEX = "index"; // public static final String HOST = "host"; // public static final String PORT = "port"; // public static final String CLUSTER_NAME = "clusterName"; // public static final String CONNECTION_URL = "connectionUrl"; // public static final String JDBC_DRIVER = "jdbcDriver"; // public static final String DEPTH = "depth"; // public static final String FIELD = "field"; // public static final String VAR = "var"; // public static final String OP = "op"; // public static final String FORMAT = "format"; // public static final String HEADER = "header"; // public static final String SUFFIX = "suffix"; // public static final String PREFIX = "prefix"; // public static final String PATH_PROVIDER = "pathProvider"; // public static final String BROKER_LIST = "brokerList"; // public static final String GENDER = "gender"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/cons/TypeConst.java // public class TypeConst { // // public static final String STRING = "string"; // public static final String LONG = "long"; // public static final String INT = "int"; // public static final String BOOLEAN = "boolean"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java // public class Context { // // private Parent parent; // // private Map<String, Template> templates; // // private Map<String, Object> variables; // // private Sink sink; // // public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) { // this.templates = templates; // this.variables = variables; // this.sink = sink; // } // // public Context(Context parentContext, Map<String, Object> entity) { // parent = new Parent(entity, parentContext.getParent()); // templates = parentContext.getTemplates(); // variables = parentContext.getVariables(); // sink = parentContext.getSink(); // } // // public Parent getParent() { // return parent; // } // // public Map<String, Object> getVariables() { // return variables; // } // // public Sink getSink() { // return sink; // } // // public Map<String, Template> getTemplates() { // return templates; // } // // } // // Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java // public class Field { // // private String name; // // private String type; // // private Provider provider; // // public Field() { // } // // public Field(String name, String type, Provider provider) { // this.name = name; // this.type = type; // this.provider = provider; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // public Provider getProvider() { // return provider; // } // // public void setProvider(Provider provider) { // this.provider = provider; // } // } // Path: src/test/java/com/presidentio/testdatagenerator/provider/ConstValueProviderTest.java import com.presidentio.testdatagenerator.cons.PropConst; import com.presidentio.testdatagenerator.cons.TypeConst; import com.presidentio.testdatagenerator.context.Context; import com.presidentio.testdatagenerator.model.Field; import org.junit.Assert; import org.junit.Test; import java.util.Collections; import java.util.HashMap; import java.util.Map; /** * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.presidentio.testdatagenerator.provider; public class ConstValueProviderTest { @Test(expected = IllegalArgumentException.class) public void testRequiredProp() throws Exception { new ConstValueProvider().init(Collections.<String, String>emptyMap()); } @Test public void testNextValue() throws Exception { Map<String, String> props = new HashMap<>(); String propValue = "123"; props.put(PropConst.VALUE, propValue); ConstValueProvider constValueProvider = new ConstValueProvider(); constValueProvider.init(props);
Object result = constValueProvider.nextValue(new Context(null, null, null), new Field("testField", TypeConst.STRING, null));
presidentio/test-data-generator
src/test/java/com/presidentio/testdatagenerator/EsDirectTest.java
// Path: src/main/java/com/presidentio/testdatagenerator/model/Output.java // public class Output { // // private String type; // // @JsonDeserialize(contentUsing = StringDeserializer.class) // private Map<String, String> props; // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // public Map<String, String> getProps() { // return props; // } // // public void setProps(Map<String, String> props) { // this.props = props; // } // }
import com.presidentio.testdatagenerator.model.Output; import org.elasticsearch.action.count.CountResponse; import org.elasticsearch.client.Client; import org.elasticsearch.index.query.QueryBuilders; import org.junit.Assert; import java.util.Arrays; import java.util.List;
/** * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.presidentio.testdatagenerator; public class EsDirectTest extends AbstractEsTest { private String indexName = "test_data_generator"; @Override protected List<String> getSchemaResource() { return Arrays.asList("test-es-direct-schema.json"); } @Override
// Path: src/main/java/com/presidentio/testdatagenerator/model/Output.java // public class Output { // // private String type; // // @JsonDeserialize(contentUsing = StringDeserializer.class) // private Map<String, String> props; // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // public Map<String, String> getProps() { // return props; // } // // public void setProps(Map<String, String> props) { // this.props = props; // } // } // Path: src/test/java/com/presidentio/testdatagenerator/EsDirectTest.java import com.presidentio.testdatagenerator.model.Output; import org.elasticsearch.action.count.CountResponse; import org.elasticsearch.client.Client; import org.elasticsearch.index.query.QueryBuilders; import org.junit.Assert; import java.util.Arrays; import java.util.List; /** * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.presidentio.testdatagenerator; public class EsDirectTest extends AbstractEsTest { private String indexName = "test_data_generator"; @Override protected List<String> getSchemaResource() { return Arrays.asList("test-es-direct-schema.json"); } @Override
protected void testResult(Output output) {
presidentio/test-data-generator
src/test/java/com/presidentio/testdatagenerator/provider/RandomProviderTest.java
// Path: src/main/java/com/presidentio/testdatagenerator/cons/TypeConst.java // public class TypeConst { // // public static final String STRING = "string"; // public static final String LONG = "long"; // public static final String INT = "int"; // public static final String BOOLEAN = "boolean"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java // public class Context { // // private Parent parent; // // private Map<String, Template> templates; // // private Map<String, Object> variables; // // private Sink sink; // // public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) { // this.templates = templates; // this.variables = variables; // this.sink = sink; // } // // public Context(Context parentContext, Map<String, Object> entity) { // parent = new Parent(entity, parentContext.getParent()); // templates = parentContext.getTemplates(); // variables = parentContext.getVariables(); // sink = parentContext.getSink(); // } // // public Parent getParent() { // return parent; // } // // public Map<String, Object> getVariables() { // return variables; // } // // public Sink getSink() { // return sink; // } // // public Map<String, Template> getTemplates() { // return templates; // } // // } // // Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java // public class Field { // // private String name; // // private String type; // // private Provider provider; // // public Field() { // } // // public Field(String name, String type, Provider provider) { // this.name = name; // this.type = type; // this.provider = provider; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // public Provider getProvider() { // return provider; // } // // public void setProvider(Provider provider) { // this.provider = provider; // } // }
import com.presidentio.testdatagenerator.cons.TypeConst; import com.presidentio.testdatagenerator.context.Context; import com.presidentio.testdatagenerator.model.Field; import org.junit.Assert; import org.junit.Test; import java.util.Collections;
/** * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.presidentio.testdatagenerator.provider; public class RandomProviderTest { @Test public void testNextValue() throws Exception { RandomProvider randomProvider = new RandomProvider(); randomProvider.init(Collections.<String, String>emptyMap());
// Path: src/main/java/com/presidentio/testdatagenerator/cons/TypeConst.java // public class TypeConst { // // public static final String STRING = "string"; // public static final String LONG = "long"; // public static final String INT = "int"; // public static final String BOOLEAN = "boolean"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java // public class Context { // // private Parent parent; // // private Map<String, Template> templates; // // private Map<String, Object> variables; // // private Sink sink; // // public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) { // this.templates = templates; // this.variables = variables; // this.sink = sink; // } // // public Context(Context parentContext, Map<String, Object> entity) { // parent = new Parent(entity, parentContext.getParent()); // templates = parentContext.getTemplates(); // variables = parentContext.getVariables(); // sink = parentContext.getSink(); // } // // public Parent getParent() { // return parent; // } // // public Map<String, Object> getVariables() { // return variables; // } // // public Sink getSink() { // return sink; // } // // public Map<String, Template> getTemplates() { // return templates; // } // // } // // Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java // public class Field { // // private String name; // // private String type; // // private Provider provider; // // public Field() { // } // // public Field(String name, String type, Provider provider) { // this.name = name; // this.type = type; // this.provider = provider; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // public Provider getProvider() { // return provider; // } // // public void setProvider(Provider provider) { // this.provider = provider; // } // } // Path: src/test/java/com/presidentio/testdatagenerator/provider/RandomProviderTest.java import com.presidentio.testdatagenerator.cons.TypeConst; import com.presidentio.testdatagenerator.context.Context; import com.presidentio.testdatagenerator.model.Field; import org.junit.Assert; import org.junit.Test; import java.util.Collections; /** * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.presidentio.testdatagenerator.provider; public class RandomProviderTest { @Test public void testNextValue() throws Exception { RandomProvider randomProvider = new RandomProvider(); randomProvider.init(Collections.<String, String>emptyMap());
Assert.assertNotNull(randomProvider.nextValue(new Context(null, null, null), new Field(null, TypeConst.BOOLEAN, null)));
presidentio/test-data-generator
src/test/java/com/presidentio/testdatagenerator/provider/RandomProviderTest.java
// Path: src/main/java/com/presidentio/testdatagenerator/cons/TypeConst.java // public class TypeConst { // // public static final String STRING = "string"; // public static final String LONG = "long"; // public static final String INT = "int"; // public static final String BOOLEAN = "boolean"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java // public class Context { // // private Parent parent; // // private Map<String, Template> templates; // // private Map<String, Object> variables; // // private Sink sink; // // public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) { // this.templates = templates; // this.variables = variables; // this.sink = sink; // } // // public Context(Context parentContext, Map<String, Object> entity) { // parent = new Parent(entity, parentContext.getParent()); // templates = parentContext.getTemplates(); // variables = parentContext.getVariables(); // sink = parentContext.getSink(); // } // // public Parent getParent() { // return parent; // } // // public Map<String, Object> getVariables() { // return variables; // } // // public Sink getSink() { // return sink; // } // // public Map<String, Template> getTemplates() { // return templates; // } // // } // // Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java // public class Field { // // private String name; // // private String type; // // private Provider provider; // // public Field() { // } // // public Field(String name, String type, Provider provider) { // this.name = name; // this.type = type; // this.provider = provider; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // public Provider getProvider() { // return provider; // } // // public void setProvider(Provider provider) { // this.provider = provider; // } // }
import com.presidentio.testdatagenerator.cons.TypeConst; import com.presidentio.testdatagenerator.context.Context; import com.presidentio.testdatagenerator.model.Field; import org.junit.Assert; import org.junit.Test; import java.util.Collections;
/** * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.presidentio.testdatagenerator.provider; public class RandomProviderTest { @Test public void testNextValue() throws Exception { RandomProvider randomProvider = new RandomProvider(); randomProvider.init(Collections.<String, String>emptyMap());
// Path: src/main/java/com/presidentio/testdatagenerator/cons/TypeConst.java // public class TypeConst { // // public static final String STRING = "string"; // public static final String LONG = "long"; // public static final String INT = "int"; // public static final String BOOLEAN = "boolean"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java // public class Context { // // private Parent parent; // // private Map<String, Template> templates; // // private Map<String, Object> variables; // // private Sink sink; // // public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) { // this.templates = templates; // this.variables = variables; // this.sink = sink; // } // // public Context(Context parentContext, Map<String, Object> entity) { // parent = new Parent(entity, parentContext.getParent()); // templates = parentContext.getTemplates(); // variables = parentContext.getVariables(); // sink = parentContext.getSink(); // } // // public Parent getParent() { // return parent; // } // // public Map<String, Object> getVariables() { // return variables; // } // // public Sink getSink() { // return sink; // } // // public Map<String, Template> getTemplates() { // return templates; // } // // } // // Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java // public class Field { // // private String name; // // private String type; // // private Provider provider; // // public Field() { // } // // public Field(String name, String type, Provider provider) { // this.name = name; // this.type = type; // this.provider = provider; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // public Provider getProvider() { // return provider; // } // // public void setProvider(Provider provider) { // this.provider = provider; // } // } // Path: src/test/java/com/presidentio/testdatagenerator/provider/RandomProviderTest.java import com.presidentio.testdatagenerator.cons.TypeConst; import com.presidentio.testdatagenerator.context.Context; import com.presidentio.testdatagenerator.model.Field; import org.junit.Assert; import org.junit.Test; import java.util.Collections; /** * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.presidentio.testdatagenerator.provider; public class RandomProviderTest { @Test public void testNextValue() throws Exception { RandomProvider randomProvider = new RandomProvider(); randomProvider.init(Collections.<String, String>emptyMap());
Assert.assertNotNull(randomProvider.nextValue(new Context(null, null, null), new Field(null, TypeConst.BOOLEAN, null)));
presidentio/test-data-generator
src/test/java/com/presidentio/testdatagenerator/provider/RandomProviderTest.java
// Path: src/main/java/com/presidentio/testdatagenerator/cons/TypeConst.java // public class TypeConst { // // public static final String STRING = "string"; // public static final String LONG = "long"; // public static final String INT = "int"; // public static final String BOOLEAN = "boolean"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java // public class Context { // // private Parent parent; // // private Map<String, Template> templates; // // private Map<String, Object> variables; // // private Sink sink; // // public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) { // this.templates = templates; // this.variables = variables; // this.sink = sink; // } // // public Context(Context parentContext, Map<String, Object> entity) { // parent = new Parent(entity, parentContext.getParent()); // templates = parentContext.getTemplates(); // variables = parentContext.getVariables(); // sink = parentContext.getSink(); // } // // public Parent getParent() { // return parent; // } // // public Map<String, Object> getVariables() { // return variables; // } // // public Sink getSink() { // return sink; // } // // public Map<String, Template> getTemplates() { // return templates; // } // // } // // Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java // public class Field { // // private String name; // // private String type; // // private Provider provider; // // public Field() { // } // // public Field(String name, String type, Provider provider) { // this.name = name; // this.type = type; // this.provider = provider; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // public Provider getProvider() { // return provider; // } // // public void setProvider(Provider provider) { // this.provider = provider; // } // }
import com.presidentio.testdatagenerator.cons.TypeConst; import com.presidentio.testdatagenerator.context.Context; import com.presidentio.testdatagenerator.model.Field; import org.junit.Assert; import org.junit.Test; import java.util.Collections;
/** * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.presidentio.testdatagenerator.provider; public class RandomProviderTest { @Test public void testNextValue() throws Exception { RandomProvider randomProvider = new RandomProvider(); randomProvider.init(Collections.<String, String>emptyMap());
// Path: src/main/java/com/presidentio/testdatagenerator/cons/TypeConst.java // public class TypeConst { // // public static final String STRING = "string"; // public static final String LONG = "long"; // public static final String INT = "int"; // public static final String BOOLEAN = "boolean"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java // public class Context { // // private Parent parent; // // private Map<String, Template> templates; // // private Map<String, Object> variables; // // private Sink sink; // // public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) { // this.templates = templates; // this.variables = variables; // this.sink = sink; // } // // public Context(Context parentContext, Map<String, Object> entity) { // parent = new Parent(entity, parentContext.getParent()); // templates = parentContext.getTemplates(); // variables = parentContext.getVariables(); // sink = parentContext.getSink(); // } // // public Parent getParent() { // return parent; // } // // public Map<String, Object> getVariables() { // return variables; // } // // public Sink getSink() { // return sink; // } // // public Map<String, Template> getTemplates() { // return templates; // } // // } // // Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java // public class Field { // // private String name; // // private String type; // // private Provider provider; // // public Field() { // } // // public Field(String name, String type, Provider provider) { // this.name = name; // this.type = type; // this.provider = provider; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // public Provider getProvider() { // return provider; // } // // public void setProvider(Provider provider) { // this.provider = provider; // } // } // Path: src/test/java/com/presidentio/testdatagenerator/provider/RandomProviderTest.java import com.presidentio.testdatagenerator.cons.TypeConst; import com.presidentio.testdatagenerator.context.Context; import com.presidentio.testdatagenerator.model.Field; import org.junit.Assert; import org.junit.Test; import java.util.Collections; /** * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.presidentio.testdatagenerator.provider; public class RandomProviderTest { @Test public void testNextValue() throws Exception { RandomProvider randomProvider = new RandomProvider(); randomProvider.init(Collections.<String, String>emptyMap());
Assert.assertNotNull(randomProvider.nextValue(new Context(null, null, null), new Field(null, TypeConst.BOOLEAN, null)));
presidentio/test-data-generator
src/main/java/com/presidentio/testdatagenerator/provider/ConstValueProvider.java
// Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java // public class PropConst { // // public static final String TYPE = "type"; // public static final String VALUE = "value"; // public static final String SIZE = "size"; // public static final String DOMAIN = "domain"; // public static final String EXPR = "expr"; // public static final String FILE = "file"; // public static final String DELIMITER = "delimiter"; // public static final String ITEMS = "items"; // public static final String INDEX = "index"; // public static final String HOST = "host"; // public static final String PORT = "port"; // public static final String CLUSTER_NAME = "clusterName"; // public static final String CONNECTION_URL = "connectionUrl"; // public static final String JDBC_DRIVER = "jdbcDriver"; // public static final String DEPTH = "depth"; // public static final String FIELD = "field"; // public static final String VAR = "var"; // public static final String OP = "op"; // public static final String FORMAT = "format"; // public static final String HEADER = "header"; // public static final String SUFFIX = "suffix"; // public static final String PREFIX = "prefix"; // public static final String PATH_PROVIDER = "pathProvider"; // public static final String BROKER_LIST = "brokerList"; // public static final String GENDER = "gender"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/cons/TypeConst.java // public class TypeConst { // // public static final String STRING = "string"; // public static final String LONG = "long"; // public static final String INT = "int"; // public static final String BOOLEAN = "boolean"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java // public class Context { // // private Parent parent; // // private Map<String, Template> templates; // // private Map<String, Object> variables; // // private Sink sink; // // public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) { // this.templates = templates; // this.variables = variables; // this.sink = sink; // } // // public Context(Context parentContext, Map<String, Object> entity) { // parent = new Parent(entity, parentContext.getParent()); // templates = parentContext.getTemplates(); // variables = parentContext.getVariables(); // sink = parentContext.getSink(); // } // // public Parent getParent() { // return parent; // } // // public Map<String, Object> getVariables() { // return variables; // } // // public Sink getSink() { // return sink; // } // // public Map<String, Template> getTemplates() { // return templates; // } // // } // // Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java // public class Field { // // private String name; // // private String type; // // private Provider provider; // // public Field() { // } // // public Field(String name, String type, Provider provider) { // this.name = name; // this.type = type; // this.provider = provider; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // public Provider getProvider() { // return provider; // } // // public void setProvider(Provider provider) { // this.provider = provider; // } // }
import com.presidentio.testdatagenerator.cons.PropConst; import com.presidentio.testdatagenerator.cons.TypeConst; import com.presidentio.testdatagenerator.context.Context; import com.presidentio.testdatagenerator.model.Field; import java.util.HashMap; import java.util.Map;
/** * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.presidentio.testdatagenerator.provider; public class ConstValueProvider implements ValueProvider { private String value; @Override public void init(Map<String, String> props) { Map<String, String> propsCopy = new HashMap<>(props);
// Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java // public class PropConst { // // public static final String TYPE = "type"; // public static final String VALUE = "value"; // public static final String SIZE = "size"; // public static final String DOMAIN = "domain"; // public static final String EXPR = "expr"; // public static final String FILE = "file"; // public static final String DELIMITER = "delimiter"; // public static final String ITEMS = "items"; // public static final String INDEX = "index"; // public static final String HOST = "host"; // public static final String PORT = "port"; // public static final String CLUSTER_NAME = "clusterName"; // public static final String CONNECTION_URL = "connectionUrl"; // public static final String JDBC_DRIVER = "jdbcDriver"; // public static final String DEPTH = "depth"; // public static final String FIELD = "field"; // public static final String VAR = "var"; // public static final String OP = "op"; // public static final String FORMAT = "format"; // public static final String HEADER = "header"; // public static final String SUFFIX = "suffix"; // public static final String PREFIX = "prefix"; // public static final String PATH_PROVIDER = "pathProvider"; // public static final String BROKER_LIST = "brokerList"; // public static final String GENDER = "gender"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/cons/TypeConst.java // public class TypeConst { // // public static final String STRING = "string"; // public static final String LONG = "long"; // public static final String INT = "int"; // public static final String BOOLEAN = "boolean"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java // public class Context { // // private Parent parent; // // private Map<String, Template> templates; // // private Map<String, Object> variables; // // private Sink sink; // // public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) { // this.templates = templates; // this.variables = variables; // this.sink = sink; // } // // public Context(Context parentContext, Map<String, Object> entity) { // parent = new Parent(entity, parentContext.getParent()); // templates = parentContext.getTemplates(); // variables = parentContext.getVariables(); // sink = parentContext.getSink(); // } // // public Parent getParent() { // return parent; // } // // public Map<String, Object> getVariables() { // return variables; // } // // public Sink getSink() { // return sink; // } // // public Map<String, Template> getTemplates() { // return templates; // } // // } // // Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java // public class Field { // // private String name; // // private String type; // // private Provider provider; // // public Field() { // } // // public Field(String name, String type, Provider provider) { // this.name = name; // this.type = type; // this.provider = provider; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // public Provider getProvider() { // return provider; // } // // public void setProvider(Provider provider) { // this.provider = provider; // } // } // Path: src/main/java/com/presidentio/testdatagenerator/provider/ConstValueProvider.java import com.presidentio.testdatagenerator.cons.PropConst; import com.presidentio.testdatagenerator.cons.TypeConst; import com.presidentio.testdatagenerator.context.Context; import com.presidentio.testdatagenerator.model.Field; import java.util.HashMap; import java.util.Map; /** * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.presidentio.testdatagenerator.provider; public class ConstValueProvider implements ValueProvider { private String value; @Override public void init(Map<String, String> props) { Map<String, String> propsCopy = new HashMap<>(props);
value = propsCopy.remove(PropConst.VALUE);
presidentio/test-data-generator
src/main/java/com/presidentio/testdatagenerator/provider/ConstValueProvider.java
// Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java // public class PropConst { // // public static final String TYPE = "type"; // public static final String VALUE = "value"; // public static final String SIZE = "size"; // public static final String DOMAIN = "domain"; // public static final String EXPR = "expr"; // public static final String FILE = "file"; // public static final String DELIMITER = "delimiter"; // public static final String ITEMS = "items"; // public static final String INDEX = "index"; // public static final String HOST = "host"; // public static final String PORT = "port"; // public static final String CLUSTER_NAME = "clusterName"; // public static final String CONNECTION_URL = "connectionUrl"; // public static final String JDBC_DRIVER = "jdbcDriver"; // public static final String DEPTH = "depth"; // public static final String FIELD = "field"; // public static final String VAR = "var"; // public static final String OP = "op"; // public static final String FORMAT = "format"; // public static final String HEADER = "header"; // public static final String SUFFIX = "suffix"; // public static final String PREFIX = "prefix"; // public static final String PATH_PROVIDER = "pathProvider"; // public static final String BROKER_LIST = "brokerList"; // public static final String GENDER = "gender"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/cons/TypeConst.java // public class TypeConst { // // public static final String STRING = "string"; // public static final String LONG = "long"; // public static final String INT = "int"; // public static final String BOOLEAN = "boolean"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java // public class Context { // // private Parent parent; // // private Map<String, Template> templates; // // private Map<String, Object> variables; // // private Sink sink; // // public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) { // this.templates = templates; // this.variables = variables; // this.sink = sink; // } // // public Context(Context parentContext, Map<String, Object> entity) { // parent = new Parent(entity, parentContext.getParent()); // templates = parentContext.getTemplates(); // variables = parentContext.getVariables(); // sink = parentContext.getSink(); // } // // public Parent getParent() { // return parent; // } // // public Map<String, Object> getVariables() { // return variables; // } // // public Sink getSink() { // return sink; // } // // public Map<String, Template> getTemplates() { // return templates; // } // // } // // Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java // public class Field { // // private String name; // // private String type; // // private Provider provider; // // public Field() { // } // // public Field(String name, String type, Provider provider) { // this.name = name; // this.type = type; // this.provider = provider; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // public Provider getProvider() { // return provider; // } // // public void setProvider(Provider provider) { // this.provider = provider; // } // }
import com.presidentio.testdatagenerator.cons.PropConst; import com.presidentio.testdatagenerator.cons.TypeConst; import com.presidentio.testdatagenerator.context.Context; import com.presidentio.testdatagenerator.model.Field; import java.util.HashMap; import java.util.Map;
/** * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.presidentio.testdatagenerator.provider; public class ConstValueProvider implements ValueProvider { private String value; @Override public void init(Map<String, String> props) { Map<String, String> propsCopy = new HashMap<>(props); value = propsCopy.remove(PropConst.VALUE); if (value == null) { throw new IllegalArgumentException("Value does not specified or null"); } if (!propsCopy.isEmpty()) { throw new IllegalArgumentException("Redundant props for ConstValueProvider: " + propsCopy); } } @Override
// Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java // public class PropConst { // // public static final String TYPE = "type"; // public static final String VALUE = "value"; // public static final String SIZE = "size"; // public static final String DOMAIN = "domain"; // public static final String EXPR = "expr"; // public static final String FILE = "file"; // public static final String DELIMITER = "delimiter"; // public static final String ITEMS = "items"; // public static final String INDEX = "index"; // public static final String HOST = "host"; // public static final String PORT = "port"; // public static final String CLUSTER_NAME = "clusterName"; // public static final String CONNECTION_URL = "connectionUrl"; // public static final String JDBC_DRIVER = "jdbcDriver"; // public static final String DEPTH = "depth"; // public static final String FIELD = "field"; // public static final String VAR = "var"; // public static final String OP = "op"; // public static final String FORMAT = "format"; // public static final String HEADER = "header"; // public static final String SUFFIX = "suffix"; // public static final String PREFIX = "prefix"; // public static final String PATH_PROVIDER = "pathProvider"; // public static final String BROKER_LIST = "brokerList"; // public static final String GENDER = "gender"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/cons/TypeConst.java // public class TypeConst { // // public static final String STRING = "string"; // public static final String LONG = "long"; // public static final String INT = "int"; // public static final String BOOLEAN = "boolean"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java // public class Context { // // private Parent parent; // // private Map<String, Template> templates; // // private Map<String, Object> variables; // // private Sink sink; // // public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) { // this.templates = templates; // this.variables = variables; // this.sink = sink; // } // // public Context(Context parentContext, Map<String, Object> entity) { // parent = new Parent(entity, parentContext.getParent()); // templates = parentContext.getTemplates(); // variables = parentContext.getVariables(); // sink = parentContext.getSink(); // } // // public Parent getParent() { // return parent; // } // // public Map<String, Object> getVariables() { // return variables; // } // // public Sink getSink() { // return sink; // } // // public Map<String, Template> getTemplates() { // return templates; // } // // } // // Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java // public class Field { // // private String name; // // private String type; // // private Provider provider; // // public Field() { // } // // public Field(String name, String type, Provider provider) { // this.name = name; // this.type = type; // this.provider = provider; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // public Provider getProvider() { // return provider; // } // // public void setProvider(Provider provider) { // this.provider = provider; // } // } // Path: src/main/java/com/presidentio/testdatagenerator/provider/ConstValueProvider.java import com.presidentio.testdatagenerator.cons.PropConst; import com.presidentio.testdatagenerator.cons.TypeConst; import com.presidentio.testdatagenerator.context.Context; import com.presidentio.testdatagenerator.model.Field; import java.util.HashMap; import java.util.Map; /** * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.presidentio.testdatagenerator.provider; public class ConstValueProvider implements ValueProvider { private String value; @Override public void init(Map<String, String> props) { Map<String, String> propsCopy = new HashMap<>(props); value = propsCopy.remove(PropConst.VALUE); if (value == null) { throw new IllegalArgumentException("Value does not specified or null"); } if (!propsCopy.isEmpty()) { throw new IllegalArgumentException("Redundant props for ConstValueProvider: " + propsCopy); } } @Override
public Object nextValue(Context context, Field field) {
presidentio/test-data-generator
src/main/java/com/presidentio/testdatagenerator/provider/ConstValueProvider.java
// Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java // public class PropConst { // // public static final String TYPE = "type"; // public static final String VALUE = "value"; // public static final String SIZE = "size"; // public static final String DOMAIN = "domain"; // public static final String EXPR = "expr"; // public static final String FILE = "file"; // public static final String DELIMITER = "delimiter"; // public static final String ITEMS = "items"; // public static final String INDEX = "index"; // public static final String HOST = "host"; // public static final String PORT = "port"; // public static final String CLUSTER_NAME = "clusterName"; // public static final String CONNECTION_URL = "connectionUrl"; // public static final String JDBC_DRIVER = "jdbcDriver"; // public static final String DEPTH = "depth"; // public static final String FIELD = "field"; // public static final String VAR = "var"; // public static final String OP = "op"; // public static final String FORMAT = "format"; // public static final String HEADER = "header"; // public static final String SUFFIX = "suffix"; // public static final String PREFIX = "prefix"; // public static final String PATH_PROVIDER = "pathProvider"; // public static final String BROKER_LIST = "brokerList"; // public static final String GENDER = "gender"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/cons/TypeConst.java // public class TypeConst { // // public static final String STRING = "string"; // public static final String LONG = "long"; // public static final String INT = "int"; // public static final String BOOLEAN = "boolean"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java // public class Context { // // private Parent parent; // // private Map<String, Template> templates; // // private Map<String, Object> variables; // // private Sink sink; // // public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) { // this.templates = templates; // this.variables = variables; // this.sink = sink; // } // // public Context(Context parentContext, Map<String, Object> entity) { // parent = new Parent(entity, parentContext.getParent()); // templates = parentContext.getTemplates(); // variables = parentContext.getVariables(); // sink = parentContext.getSink(); // } // // public Parent getParent() { // return parent; // } // // public Map<String, Object> getVariables() { // return variables; // } // // public Sink getSink() { // return sink; // } // // public Map<String, Template> getTemplates() { // return templates; // } // // } // // Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java // public class Field { // // private String name; // // private String type; // // private Provider provider; // // public Field() { // } // // public Field(String name, String type, Provider provider) { // this.name = name; // this.type = type; // this.provider = provider; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // public Provider getProvider() { // return provider; // } // // public void setProvider(Provider provider) { // this.provider = provider; // } // }
import com.presidentio.testdatagenerator.cons.PropConst; import com.presidentio.testdatagenerator.cons.TypeConst; import com.presidentio.testdatagenerator.context.Context; import com.presidentio.testdatagenerator.model.Field; import java.util.HashMap; import java.util.Map;
/** * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.presidentio.testdatagenerator.provider; public class ConstValueProvider implements ValueProvider { private String value; @Override public void init(Map<String, String> props) { Map<String, String> propsCopy = new HashMap<>(props); value = propsCopy.remove(PropConst.VALUE); if (value == null) { throw new IllegalArgumentException("Value does not specified or null"); } if (!propsCopy.isEmpty()) { throw new IllegalArgumentException("Redundant props for ConstValueProvider: " + propsCopy); } } @Override
// Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java // public class PropConst { // // public static final String TYPE = "type"; // public static final String VALUE = "value"; // public static final String SIZE = "size"; // public static final String DOMAIN = "domain"; // public static final String EXPR = "expr"; // public static final String FILE = "file"; // public static final String DELIMITER = "delimiter"; // public static final String ITEMS = "items"; // public static final String INDEX = "index"; // public static final String HOST = "host"; // public static final String PORT = "port"; // public static final String CLUSTER_NAME = "clusterName"; // public static final String CONNECTION_URL = "connectionUrl"; // public static final String JDBC_DRIVER = "jdbcDriver"; // public static final String DEPTH = "depth"; // public static final String FIELD = "field"; // public static final String VAR = "var"; // public static final String OP = "op"; // public static final String FORMAT = "format"; // public static final String HEADER = "header"; // public static final String SUFFIX = "suffix"; // public static final String PREFIX = "prefix"; // public static final String PATH_PROVIDER = "pathProvider"; // public static final String BROKER_LIST = "brokerList"; // public static final String GENDER = "gender"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/cons/TypeConst.java // public class TypeConst { // // public static final String STRING = "string"; // public static final String LONG = "long"; // public static final String INT = "int"; // public static final String BOOLEAN = "boolean"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java // public class Context { // // private Parent parent; // // private Map<String, Template> templates; // // private Map<String, Object> variables; // // private Sink sink; // // public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) { // this.templates = templates; // this.variables = variables; // this.sink = sink; // } // // public Context(Context parentContext, Map<String, Object> entity) { // parent = new Parent(entity, parentContext.getParent()); // templates = parentContext.getTemplates(); // variables = parentContext.getVariables(); // sink = parentContext.getSink(); // } // // public Parent getParent() { // return parent; // } // // public Map<String, Object> getVariables() { // return variables; // } // // public Sink getSink() { // return sink; // } // // public Map<String, Template> getTemplates() { // return templates; // } // // } // // Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java // public class Field { // // private String name; // // private String type; // // private Provider provider; // // public Field() { // } // // public Field(String name, String type, Provider provider) { // this.name = name; // this.type = type; // this.provider = provider; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // public Provider getProvider() { // return provider; // } // // public void setProvider(Provider provider) { // this.provider = provider; // } // } // Path: src/main/java/com/presidentio/testdatagenerator/provider/ConstValueProvider.java import com.presidentio.testdatagenerator.cons.PropConst; import com.presidentio.testdatagenerator.cons.TypeConst; import com.presidentio.testdatagenerator.context.Context; import com.presidentio.testdatagenerator.model.Field; import java.util.HashMap; import java.util.Map; /** * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.presidentio.testdatagenerator.provider; public class ConstValueProvider implements ValueProvider { private String value; @Override public void init(Map<String, String> props) { Map<String, String> propsCopy = new HashMap<>(props); value = propsCopy.remove(PropConst.VALUE); if (value == null) { throw new IllegalArgumentException("Value does not specified or null"); } if (!propsCopy.isEmpty()) { throw new IllegalArgumentException("Redundant props for ConstValueProvider: " + propsCopy); } } @Override
public Object nextValue(Context context, Field field) {
presidentio/test-data-generator
src/main/java/com/presidentio/testdatagenerator/provider/ConstValueProvider.java
// Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java // public class PropConst { // // public static final String TYPE = "type"; // public static final String VALUE = "value"; // public static final String SIZE = "size"; // public static final String DOMAIN = "domain"; // public static final String EXPR = "expr"; // public static final String FILE = "file"; // public static final String DELIMITER = "delimiter"; // public static final String ITEMS = "items"; // public static final String INDEX = "index"; // public static final String HOST = "host"; // public static final String PORT = "port"; // public static final String CLUSTER_NAME = "clusterName"; // public static final String CONNECTION_URL = "connectionUrl"; // public static final String JDBC_DRIVER = "jdbcDriver"; // public static final String DEPTH = "depth"; // public static final String FIELD = "field"; // public static final String VAR = "var"; // public static final String OP = "op"; // public static final String FORMAT = "format"; // public static final String HEADER = "header"; // public static final String SUFFIX = "suffix"; // public static final String PREFIX = "prefix"; // public static final String PATH_PROVIDER = "pathProvider"; // public static final String BROKER_LIST = "brokerList"; // public static final String GENDER = "gender"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/cons/TypeConst.java // public class TypeConst { // // public static final String STRING = "string"; // public static final String LONG = "long"; // public static final String INT = "int"; // public static final String BOOLEAN = "boolean"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java // public class Context { // // private Parent parent; // // private Map<String, Template> templates; // // private Map<String, Object> variables; // // private Sink sink; // // public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) { // this.templates = templates; // this.variables = variables; // this.sink = sink; // } // // public Context(Context parentContext, Map<String, Object> entity) { // parent = new Parent(entity, parentContext.getParent()); // templates = parentContext.getTemplates(); // variables = parentContext.getVariables(); // sink = parentContext.getSink(); // } // // public Parent getParent() { // return parent; // } // // public Map<String, Object> getVariables() { // return variables; // } // // public Sink getSink() { // return sink; // } // // public Map<String, Template> getTemplates() { // return templates; // } // // } // // Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java // public class Field { // // private String name; // // private String type; // // private Provider provider; // // public Field() { // } // // public Field(String name, String type, Provider provider) { // this.name = name; // this.type = type; // this.provider = provider; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // public Provider getProvider() { // return provider; // } // // public void setProvider(Provider provider) { // this.provider = provider; // } // }
import com.presidentio.testdatagenerator.cons.PropConst; import com.presidentio.testdatagenerator.cons.TypeConst; import com.presidentio.testdatagenerator.context.Context; import com.presidentio.testdatagenerator.model.Field; import java.util.HashMap; import java.util.Map;
/** * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.presidentio.testdatagenerator.provider; public class ConstValueProvider implements ValueProvider { private String value; @Override public void init(Map<String, String> props) { Map<String, String> propsCopy = new HashMap<>(props); value = propsCopy.remove(PropConst.VALUE); if (value == null) { throw new IllegalArgumentException("Value does not specified or null"); } if (!propsCopy.isEmpty()) { throw new IllegalArgumentException("Redundant props for ConstValueProvider: " + propsCopy); } } @Override public Object nextValue(Context context, Field field) { String type = field.getType(); switch (type) {
// Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java // public class PropConst { // // public static final String TYPE = "type"; // public static final String VALUE = "value"; // public static final String SIZE = "size"; // public static final String DOMAIN = "domain"; // public static final String EXPR = "expr"; // public static final String FILE = "file"; // public static final String DELIMITER = "delimiter"; // public static final String ITEMS = "items"; // public static final String INDEX = "index"; // public static final String HOST = "host"; // public static final String PORT = "port"; // public static final String CLUSTER_NAME = "clusterName"; // public static final String CONNECTION_URL = "connectionUrl"; // public static final String JDBC_DRIVER = "jdbcDriver"; // public static final String DEPTH = "depth"; // public static final String FIELD = "field"; // public static final String VAR = "var"; // public static final String OP = "op"; // public static final String FORMAT = "format"; // public static final String HEADER = "header"; // public static final String SUFFIX = "suffix"; // public static final String PREFIX = "prefix"; // public static final String PATH_PROVIDER = "pathProvider"; // public static final String BROKER_LIST = "brokerList"; // public static final String GENDER = "gender"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/cons/TypeConst.java // public class TypeConst { // // public static final String STRING = "string"; // public static final String LONG = "long"; // public static final String INT = "int"; // public static final String BOOLEAN = "boolean"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java // public class Context { // // private Parent parent; // // private Map<String, Template> templates; // // private Map<String, Object> variables; // // private Sink sink; // // public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) { // this.templates = templates; // this.variables = variables; // this.sink = sink; // } // // public Context(Context parentContext, Map<String, Object> entity) { // parent = new Parent(entity, parentContext.getParent()); // templates = parentContext.getTemplates(); // variables = parentContext.getVariables(); // sink = parentContext.getSink(); // } // // public Parent getParent() { // return parent; // } // // public Map<String, Object> getVariables() { // return variables; // } // // public Sink getSink() { // return sink; // } // // public Map<String, Template> getTemplates() { // return templates; // } // // } // // Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java // public class Field { // // private String name; // // private String type; // // private Provider provider; // // public Field() { // } // // public Field(String name, String type, Provider provider) { // this.name = name; // this.type = type; // this.provider = provider; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // public Provider getProvider() { // return provider; // } // // public void setProvider(Provider provider) { // this.provider = provider; // } // } // Path: src/main/java/com/presidentio/testdatagenerator/provider/ConstValueProvider.java import com.presidentio.testdatagenerator.cons.PropConst; import com.presidentio.testdatagenerator.cons.TypeConst; import com.presidentio.testdatagenerator.context.Context; import com.presidentio.testdatagenerator.model.Field; import java.util.HashMap; import java.util.Map; /** * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.presidentio.testdatagenerator.provider; public class ConstValueProvider implements ValueProvider { private String value; @Override public void init(Map<String, String> props) { Map<String, String> propsCopy = new HashMap<>(props); value = propsCopy.remove(PropConst.VALUE); if (value == null) { throw new IllegalArgumentException("Value does not specified or null"); } if (!propsCopy.isEmpty()) { throw new IllegalArgumentException("Redundant props for ConstValueProvider: " + propsCopy); } } @Override public Object nextValue(Context context, Field field) { String type = field.getType(); switch (type) {
case TypeConst.STRING:
presidentio/test-data-generator
src/main/java/com/presidentio/testdatagenerator/provider/ExpressionProvider.java
// Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java // public class PropConst { // // public static final String TYPE = "type"; // public static final String VALUE = "value"; // public static final String SIZE = "size"; // public static final String DOMAIN = "domain"; // public static final String EXPR = "expr"; // public static final String FILE = "file"; // public static final String DELIMITER = "delimiter"; // public static final String ITEMS = "items"; // public static final String INDEX = "index"; // public static final String HOST = "host"; // public static final String PORT = "port"; // public static final String CLUSTER_NAME = "clusterName"; // public static final String CONNECTION_URL = "connectionUrl"; // public static final String JDBC_DRIVER = "jdbcDriver"; // public static final String DEPTH = "depth"; // public static final String FIELD = "field"; // public static final String VAR = "var"; // public static final String OP = "op"; // public static final String FORMAT = "format"; // public static final String HEADER = "header"; // public static final String SUFFIX = "suffix"; // public static final String PREFIX = "prefix"; // public static final String PATH_PROVIDER = "pathProvider"; // public static final String BROKER_LIST = "brokerList"; // public static final String GENDER = "gender"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/cons/TypeConst.java // public class TypeConst { // // public static final String STRING = "string"; // public static final String LONG = "long"; // public static final String INT = "int"; // public static final String BOOLEAN = "boolean"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java // public class Context { // // private Parent parent; // // private Map<String, Template> templates; // // private Map<String, Object> variables; // // private Sink sink; // // public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) { // this.templates = templates; // this.variables = variables; // this.sink = sink; // } // // public Context(Context parentContext, Map<String, Object> entity) { // parent = new Parent(entity, parentContext.getParent()); // templates = parentContext.getTemplates(); // variables = parentContext.getVariables(); // sink = parentContext.getSink(); // } // // public Parent getParent() { // return parent; // } // // public Map<String, Object> getVariables() { // return variables; // } // // public Sink getSink() { // return sink; // } // // public Map<String, Template> getTemplates() { // return templates; // } // // } // // Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java // public class Field { // // private String name; // // private String type; // // private Provider provider; // // public Field() { // } // // public Field(String name, String type, Provider provider) { // this.name = name; // this.type = type; // this.provider = provider; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // public Provider getProvider() { // return provider; // } // // public void setProvider(Provider provider) { // this.provider = provider; // } // }
import com.presidentio.testdatagenerator.cons.PropConst; import com.presidentio.testdatagenerator.cons.TypeConst; import com.presidentio.testdatagenerator.context.Context; import com.presidentio.testdatagenerator.model.Field; import org.mvel2.MVEL; import java.io.Serializable; import java.util.HashMap; import java.util.Map;
/** * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.presidentio.testdatagenerator.provider; public class ExpressionProvider implements ValueProvider { private String expr; private Serializable compiledExpression; @Override public void init(Map<String, String> props) { Map<String, String> propsCopy = new HashMap<>(props);
// Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java // public class PropConst { // // public static final String TYPE = "type"; // public static final String VALUE = "value"; // public static final String SIZE = "size"; // public static final String DOMAIN = "domain"; // public static final String EXPR = "expr"; // public static final String FILE = "file"; // public static final String DELIMITER = "delimiter"; // public static final String ITEMS = "items"; // public static final String INDEX = "index"; // public static final String HOST = "host"; // public static final String PORT = "port"; // public static final String CLUSTER_NAME = "clusterName"; // public static final String CONNECTION_URL = "connectionUrl"; // public static final String JDBC_DRIVER = "jdbcDriver"; // public static final String DEPTH = "depth"; // public static final String FIELD = "field"; // public static final String VAR = "var"; // public static final String OP = "op"; // public static final String FORMAT = "format"; // public static final String HEADER = "header"; // public static final String SUFFIX = "suffix"; // public static final String PREFIX = "prefix"; // public static final String PATH_PROVIDER = "pathProvider"; // public static final String BROKER_LIST = "brokerList"; // public static final String GENDER = "gender"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/cons/TypeConst.java // public class TypeConst { // // public static final String STRING = "string"; // public static final String LONG = "long"; // public static final String INT = "int"; // public static final String BOOLEAN = "boolean"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java // public class Context { // // private Parent parent; // // private Map<String, Template> templates; // // private Map<String, Object> variables; // // private Sink sink; // // public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) { // this.templates = templates; // this.variables = variables; // this.sink = sink; // } // // public Context(Context parentContext, Map<String, Object> entity) { // parent = new Parent(entity, parentContext.getParent()); // templates = parentContext.getTemplates(); // variables = parentContext.getVariables(); // sink = parentContext.getSink(); // } // // public Parent getParent() { // return parent; // } // // public Map<String, Object> getVariables() { // return variables; // } // // public Sink getSink() { // return sink; // } // // public Map<String, Template> getTemplates() { // return templates; // } // // } // // Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java // public class Field { // // private String name; // // private String type; // // private Provider provider; // // public Field() { // } // // public Field(String name, String type, Provider provider) { // this.name = name; // this.type = type; // this.provider = provider; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // public Provider getProvider() { // return provider; // } // // public void setProvider(Provider provider) { // this.provider = provider; // } // } // Path: src/main/java/com/presidentio/testdatagenerator/provider/ExpressionProvider.java import com.presidentio.testdatagenerator.cons.PropConst; import com.presidentio.testdatagenerator.cons.TypeConst; import com.presidentio.testdatagenerator.context.Context; import com.presidentio.testdatagenerator.model.Field; import org.mvel2.MVEL; import java.io.Serializable; import java.util.HashMap; import java.util.Map; /** * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.presidentio.testdatagenerator.provider; public class ExpressionProvider implements ValueProvider { private String expr; private Serializable compiledExpression; @Override public void init(Map<String, String> props) { Map<String, String> propsCopy = new HashMap<>(props);
expr = propsCopy.remove(PropConst.EXPR);
presidentio/test-data-generator
src/main/java/com/presidentio/testdatagenerator/provider/ExpressionProvider.java
// Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java // public class PropConst { // // public static final String TYPE = "type"; // public static final String VALUE = "value"; // public static final String SIZE = "size"; // public static final String DOMAIN = "domain"; // public static final String EXPR = "expr"; // public static final String FILE = "file"; // public static final String DELIMITER = "delimiter"; // public static final String ITEMS = "items"; // public static final String INDEX = "index"; // public static final String HOST = "host"; // public static final String PORT = "port"; // public static final String CLUSTER_NAME = "clusterName"; // public static final String CONNECTION_URL = "connectionUrl"; // public static final String JDBC_DRIVER = "jdbcDriver"; // public static final String DEPTH = "depth"; // public static final String FIELD = "field"; // public static final String VAR = "var"; // public static final String OP = "op"; // public static final String FORMAT = "format"; // public static final String HEADER = "header"; // public static final String SUFFIX = "suffix"; // public static final String PREFIX = "prefix"; // public static final String PATH_PROVIDER = "pathProvider"; // public static final String BROKER_LIST = "brokerList"; // public static final String GENDER = "gender"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/cons/TypeConst.java // public class TypeConst { // // public static final String STRING = "string"; // public static final String LONG = "long"; // public static final String INT = "int"; // public static final String BOOLEAN = "boolean"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java // public class Context { // // private Parent parent; // // private Map<String, Template> templates; // // private Map<String, Object> variables; // // private Sink sink; // // public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) { // this.templates = templates; // this.variables = variables; // this.sink = sink; // } // // public Context(Context parentContext, Map<String, Object> entity) { // parent = new Parent(entity, parentContext.getParent()); // templates = parentContext.getTemplates(); // variables = parentContext.getVariables(); // sink = parentContext.getSink(); // } // // public Parent getParent() { // return parent; // } // // public Map<String, Object> getVariables() { // return variables; // } // // public Sink getSink() { // return sink; // } // // public Map<String, Template> getTemplates() { // return templates; // } // // } // // Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java // public class Field { // // private String name; // // private String type; // // private Provider provider; // // public Field() { // } // // public Field(String name, String type, Provider provider) { // this.name = name; // this.type = type; // this.provider = provider; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // public Provider getProvider() { // return provider; // } // // public void setProvider(Provider provider) { // this.provider = provider; // } // }
import com.presidentio.testdatagenerator.cons.PropConst; import com.presidentio.testdatagenerator.cons.TypeConst; import com.presidentio.testdatagenerator.context.Context; import com.presidentio.testdatagenerator.model.Field; import org.mvel2.MVEL; import java.io.Serializable; import java.util.HashMap; import java.util.Map;
/** * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.presidentio.testdatagenerator.provider; public class ExpressionProvider implements ValueProvider { private String expr; private Serializable compiledExpression; @Override public void init(Map<String, String> props) { Map<String, String> propsCopy = new HashMap<>(props); expr = propsCopy.remove(PropConst.EXPR); if (expr == null) { throw new IllegalArgumentException("Value does not specified or null"); } if (!propsCopy.isEmpty()) { throw new IllegalArgumentException("Redundant props for " + getClass().getName() + ": " + propsCopy); } compiledExpression = MVEL.compileExpression(expr); } @Override
// Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java // public class PropConst { // // public static final String TYPE = "type"; // public static final String VALUE = "value"; // public static final String SIZE = "size"; // public static final String DOMAIN = "domain"; // public static final String EXPR = "expr"; // public static final String FILE = "file"; // public static final String DELIMITER = "delimiter"; // public static final String ITEMS = "items"; // public static final String INDEX = "index"; // public static final String HOST = "host"; // public static final String PORT = "port"; // public static final String CLUSTER_NAME = "clusterName"; // public static final String CONNECTION_URL = "connectionUrl"; // public static final String JDBC_DRIVER = "jdbcDriver"; // public static final String DEPTH = "depth"; // public static final String FIELD = "field"; // public static final String VAR = "var"; // public static final String OP = "op"; // public static final String FORMAT = "format"; // public static final String HEADER = "header"; // public static final String SUFFIX = "suffix"; // public static final String PREFIX = "prefix"; // public static final String PATH_PROVIDER = "pathProvider"; // public static final String BROKER_LIST = "brokerList"; // public static final String GENDER = "gender"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/cons/TypeConst.java // public class TypeConst { // // public static final String STRING = "string"; // public static final String LONG = "long"; // public static final String INT = "int"; // public static final String BOOLEAN = "boolean"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java // public class Context { // // private Parent parent; // // private Map<String, Template> templates; // // private Map<String, Object> variables; // // private Sink sink; // // public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) { // this.templates = templates; // this.variables = variables; // this.sink = sink; // } // // public Context(Context parentContext, Map<String, Object> entity) { // parent = new Parent(entity, parentContext.getParent()); // templates = parentContext.getTemplates(); // variables = parentContext.getVariables(); // sink = parentContext.getSink(); // } // // public Parent getParent() { // return parent; // } // // public Map<String, Object> getVariables() { // return variables; // } // // public Sink getSink() { // return sink; // } // // public Map<String, Template> getTemplates() { // return templates; // } // // } // // Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java // public class Field { // // private String name; // // private String type; // // private Provider provider; // // public Field() { // } // // public Field(String name, String type, Provider provider) { // this.name = name; // this.type = type; // this.provider = provider; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // public Provider getProvider() { // return provider; // } // // public void setProvider(Provider provider) { // this.provider = provider; // } // } // Path: src/main/java/com/presidentio/testdatagenerator/provider/ExpressionProvider.java import com.presidentio.testdatagenerator.cons.PropConst; import com.presidentio.testdatagenerator.cons.TypeConst; import com.presidentio.testdatagenerator.context.Context; import com.presidentio.testdatagenerator.model.Field; import org.mvel2.MVEL; import java.io.Serializable; import java.util.HashMap; import java.util.Map; /** * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.presidentio.testdatagenerator.provider; public class ExpressionProvider implements ValueProvider { private String expr; private Serializable compiledExpression; @Override public void init(Map<String, String> props) { Map<String, String> propsCopy = new HashMap<>(props); expr = propsCopy.remove(PropConst.EXPR); if (expr == null) { throw new IllegalArgumentException("Value does not specified or null"); } if (!propsCopy.isEmpty()) { throw new IllegalArgumentException("Redundant props for " + getClass().getName() + ": " + propsCopy); } compiledExpression = MVEL.compileExpression(expr); } @Override
public Object nextValue(Context context, Field field) {
presidentio/test-data-generator
src/main/java/com/presidentio/testdatagenerator/provider/ExpressionProvider.java
// Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java // public class PropConst { // // public static final String TYPE = "type"; // public static final String VALUE = "value"; // public static final String SIZE = "size"; // public static final String DOMAIN = "domain"; // public static final String EXPR = "expr"; // public static final String FILE = "file"; // public static final String DELIMITER = "delimiter"; // public static final String ITEMS = "items"; // public static final String INDEX = "index"; // public static final String HOST = "host"; // public static final String PORT = "port"; // public static final String CLUSTER_NAME = "clusterName"; // public static final String CONNECTION_URL = "connectionUrl"; // public static final String JDBC_DRIVER = "jdbcDriver"; // public static final String DEPTH = "depth"; // public static final String FIELD = "field"; // public static final String VAR = "var"; // public static final String OP = "op"; // public static final String FORMAT = "format"; // public static final String HEADER = "header"; // public static final String SUFFIX = "suffix"; // public static final String PREFIX = "prefix"; // public static final String PATH_PROVIDER = "pathProvider"; // public static final String BROKER_LIST = "brokerList"; // public static final String GENDER = "gender"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/cons/TypeConst.java // public class TypeConst { // // public static final String STRING = "string"; // public static final String LONG = "long"; // public static final String INT = "int"; // public static final String BOOLEAN = "boolean"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java // public class Context { // // private Parent parent; // // private Map<String, Template> templates; // // private Map<String, Object> variables; // // private Sink sink; // // public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) { // this.templates = templates; // this.variables = variables; // this.sink = sink; // } // // public Context(Context parentContext, Map<String, Object> entity) { // parent = new Parent(entity, parentContext.getParent()); // templates = parentContext.getTemplates(); // variables = parentContext.getVariables(); // sink = parentContext.getSink(); // } // // public Parent getParent() { // return parent; // } // // public Map<String, Object> getVariables() { // return variables; // } // // public Sink getSink() { // return sink; // } // // public Map<String, Template> getTemplates() { // return templates; // } // // } // // Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java // public class Field { // // private String name; // // private String type; // // private Provider provider; // // public Field() { // } // // public Field(String name, String type, Provider provider) { // this.name = name; // this.type = type; // this.provider = provider; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // public Provider getProvider() { // return provider; // } // // public void setProvider(Provider provider) { // this.provider = provider; // } // }
import com.presidentio.testdatagenerator.cons.PropConst; import com.presidentio.testdatagenerator.cons.TypeConst; import com.presidentio.testdatagenerator.context.Context; import com.presidentio.testdatagenerator.model.Field; import org.mvel2.MVEL; import java.io.Serializable; import java.util.HashMap; import java.util.Map;
/** * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.presidentio.testdatagenerator.provider; public class ExpressionProvider implements ValueProvider { private String expr; private Serializable compiledExpression; @Override public void init(Map<String, String> props) { Map<String, String> propsCopy = new HashMap<>(props); expr = propsCopy.remove(PropConst.EXPR); if (expr == null) { throw new IllegalArgumentException("Value does not specified or null"); } if (!propsCopy.isEmpty()) { throw new IllegalArgumentException("Redundant props for " + getClass().getName() + ": " + propsCopy); } compiledExpression = MVEL.compileExpression(expr); } @Override
// Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java // public class PropConst { // // public static final String TYPE = "type"; // public static final String VALUE = "value"; // public static final String SIZE = "size"; // public static final String DOMAIN = "domain"; // public static final String EXPR = "expr"; // public static final String FILE = "file"; // public static final String DELIMITER = "delimiter"; // public static final String ITEMS = "items"; // public static final String INDEX = "index"; // public static final String HOST = "host"; // public static final String PORT = "port"; // public static final String CLUSTER_NAME = "clusterName"; // public static final String CONNECTION_URL = "connectionUrl"; // public static final String JDBC_DRIVER = "jdbcDriver"; // public static final String DEPTH = "depth"; // public static final String FIELD = "field"; // public static final String VAR = "var"; // public static final String OP = "op"; // public static final String FORMAT = "format"; // public static final String HEADER = "header"; // public static final String SUFFIX = "suffix"; // public static final String PREFIX = "prefix"; // public static final String PATH_PROVIDER = "pathProvider"; // public static final String BROKER_LIST = "brokerList"; // public static final String GENDER = "gender"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/cons/TypeConst.java // public class TypeConst { // // public static final String STRING = "string"; // public static final String LONG = "long"; // public static final String INT = "int"; // public static final String BOOLEAN = "boolean"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java // public class Context { // // private Parent parent; // // private Map<String, Template> templates; // // private Map<String, Object> variables; // // private Sink sink; // // public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) { // this.templates = templates; // this.variables = variables; // this.sink = sink; // } // // public Context(Context parentContext, Map<String, Object> entity) { // parent = new Parent(entity, parentContext.getParent()); // templates = parentContext.getTemplates(); // variables = parentContext.getVariables(); // sink = parentContext.getSink(); // } // // public Parent getParent() { // return parent; // } // // public Map<String, Object> getVariables() { // return variables; // } // // public Sink getSink() { // return sink; // } // // public Map<String, Template> getTemplates() { // return templates; // } // // } // // Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java // public class Field { // // private String name; // // private String type; // // private Provider provider; // // public Field() { // } // // public Field(String name, String type, Provider provider) { // this.name = name; // this.type = type; // this.provider = provider; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // public Provider getProvider() { // return provider; // } // // public void setProvider(Provider provider) { // this.provider = provider; // } // } // Path: src/main/java/com/presidentio/testdatagenerator/provider/ExpressionProvider.java import com.presidentio.testdatagenerator.cons.PropConst; import com.presidentio.testdatagenerator.cons.TypeConst; import com.presidentio.testdatagenerator.context.Context; import com.presidentio.testdatagenerator.model.Field; import org.mvel2.MVEL; import java.io.Serializable; import java.util.HashMap; import java.util.Map; /** * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.presidentio.testdatagenerator.provider; public class ExpressionProvider implements ValueProvider { private String expr; private Serializable compiledExpression; @Override public void init(Map<String, String> props) { Map<String, String> propsCopy = new HashMap<>(props); expr = propsCopy.remove(PropConst.EXPR); if (expr == null) { throw new IllegalArgumentException("Value does not specified or null"); } if (!propsCopy.isEmpty()) { throw new IllegalArgumentException("Redundant props for " + getClass().getName() + ": " + propsCopy); } compiledExpression = MVEL.compileExpression(expr); } @Override
public Object nextValue(Context context, Field field) {
presidentio/test-data-generator
src/main/java/com/presidentio/testdatagenerator/provider/ExpressionProvider.java
// Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java // public class PropConst { // // public static final String TYPE = "type"; // public static final String VALUE = "value"; // public static final String SIZE = "size"; // public static final String DOMAIN = "domain"; // public static final String EXPR = "expr"; // public static final String FILE = "file"; // public static final String DELIMITER = "delimiter"; // public static final String ITEMS = "items"; // public static final String INDEX = "index"; // public static final String HOST = "host"; // public static final String PORT = "port"; // public static final String CLUSTER_NAME = "clusterName"; // public static final String CONNECTION_URL = "connectionUrl"; // public static final String JDBC_DRIVER = "jdbcDriver"; // public static final String DEPTH = "depth"; // public static final String FIELD = "field"; // public static final String VAR = "var"; // public static final String OP = "op"; // public static final String FORMAT = "format"; // public static final String HEADER = "header"; // public static final String SUFFIX = "suffix"; // public static final String PREFIX = "prefix"; // public static final String PATH_PROVIDER = "pathProvider"; // public static final String BROKER_LIST = "brokerList"; // public static final String GENDER = "gender"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/cons/TypeConst.java // public class TypeConst { // // public static final String STRING = "string"; // public static final String LONG = "long"; // public static final String INT = "int"; // public static final String BOOLEAN = "boolean"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java // public class Context { // // private Parent parent; // // private Map<String, Template> templates; // // private Map<String, Object> variables; // // private Sink sink; // // public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) { // this.templates = templates; // this.variables = variables; // this.sink = sink; // } // // public Context(Context parentContext, Map<String, Object> entity) { // parent = new Parent(entity, parentContext.getParent()); // templates = parentContext.getTemplates(); // variables = parentContext.getVariables(); // sink = parentContext.getSink(); // } // // public Parent getParent() { // return parent; // } // // public Map<String, Object> getVariables() { // return variables; // } // // public Sink getSink() { // return sink; // } // // public Map<String, Template> getTemplates() { // return templates; // } // // } // // Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java // public class Field { // // private String name; // // private String type; // // private Provider provider; // // public Field() { // } // // public Field(String name, String type, Provider provider) { // this.name = name; // this.type = type; // this.provider = provider; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // public Provider getProvider() { // return provider; // } // // public void setProvider(Provider provider) { // this.provider = provider; // } // }
import com.presidentio.testdatagenerator.cons.PropConst; import com.presidentio.testdatagenerator.cons.TypeConst; import com.presidentio.testdatagenerator.context.Context; import com.presidentio.testdatagenerator.model.Field; import org.mvel2.MVEL; import java.io.Serializable; import java.util.HashMap; import java.util.Map;
/** * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.presidentio.testdatagenerator.provider; public class ExpressionProvider implements ValueProvider { private String expr; private Serializable compiledExpression; @Override public void init(Map<String, String> props) { Map<String, String> propsCopy = new HashMap<>(props); expr = propsCopy.remove(PropConst.EXPR); if (expr == null) { throw new IllegalArgumentException("Value does not specified or null"); } if (!propsCopy.isEmpty()) { throw new IllegalArgumentException("Redundant props for " + getClass().getName() + ": " + propsCopy); } compiledExpression = MVEL.compileExpression(expr); } @Override public Object nextValue(Context context, Field field) { Class type; switch (field.getType()) {
// Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java // public class PropConst { // // public static final String TYPE = "type"; // public static final String VALUE = "value"; // public static final String SIZE = "size"; // public static final String DOMAIN = "domain"; // public static final String EXPR = "expr"; // public static final String FILE = "file"; // public static final String DELIMITER = "delimiter"; // public static final String ITEMS = "items"; // public static final String INDEX = "index"; // public static final String HOST = "host"; // public static final String PORT = "port"; // public static final String CLUSTER_NAME = "clusterName"; // public static final String CONNECTION_URL = "connectionUrl"; // public static final String JDBC_DRIVER = "jdbcDriver"; // public static final String DEPTH = "depth"; // public static final String FIELD = "field"; // public static final String VAR = "var"; // public static final String OP = "op"; // public static final String FORMAT = "format"; // public static final String HEADER = "header"; // public static final String SUFFIX = "suffix"; // public static final String PREFIX = "prefix"; // public static final String PATH_PROVIDER = "pathProvider"; // public static final String BROKER_LIST = "brokerList"; // public static final String GENDER = "gender"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/cons/TypeConst.java // public class TypeConst { // // public static final String STRING = "string"; // public static final String LONG = "long"; // public static final String INT = "int"; // public static final String BOOLEAN = "boolean"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java // public class Context { // // private Parent parent; // // private Map<String, Template> templates; // // private Map<String, Object> variables; // // private Sink sink; // // public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) { // this.templates = templates; // this.variables = variables; // this.sink = sink; // } // // public Context(Context parentContext, Map<String, Object> entity) { // parent = new Parent(entity, parentContext.getParent()); // templates = parentContext.getTemplates(); // variables = parentContext.getVariables(); // sink = parentContext.getSink(); // } // // public Parent getParent() { // return parent; // } // // public Map<String, Object> getVariables() { // return variables; // } // // public Sink getSink() { // return sink; // } // // public Map<String, Template> getTemplates() { // return templates; // } // // } // // Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java // public class Field { // // private String name; // // private String type; // // private Provider provider; // // public Field() { // } // // public Field(String name, String type, Provider provider) { // this.name = name; // this.type = type; // this.provider = provider; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // public Provider getProvider() { // return provider; // } // // public void setProvider(Provider provider) { // this.provider = provider; // } // } // Path: src/main/java/com/presidentio/testdatagenerator/provider/ExpressionProvider.java import com.presidentio.testdatagenerator.cons.PropConst; import com.presidentio.testdatagenerator.cons.TypeConst; import com.presidentio.testdatagenerator.context.Context; import com.presidentio.testdatagenerator.model.Field; import org.mvel2.MVEL; import java.io.Serializable; import java.util.HashMap; import java.util.Map; /** * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.presidentio.testdatagenerator.provider; public class ExpressionProvider implements ValueProvider { private String expr; private Serializable compiledExpression; @Override public void init(Map<String, String> props) { Map<String, String> propsCopy = new HashMap<>(props); expr = propsCopy.remove(PropConst.EXPR); if (expr == null) { throw new IllegalArgumentException("Value does not specified or null"); } if (!propsCopy.isEmpty()) { throw new IllegalArgumentException("Redundant props for " + getClass().getName() + ": " + propsCopy); } compiledExpression = MVEL.compileExpression(expr); } @Override public Object nextValue(Context context, Field field) { Class type; switch (field.getType()) {
case TypeConst.STRING:
presidentio/test-data-generator
src/main/java/com/presidentio/testdatagenerator/benchmark/RandomBenchmark.java
// Path: src/main/java/com/presidentio/testdatagenerator/cons/TypeConst.java // public class TypeConst { // // public static final String STRING = "string"; // public static final String LONG = "long"; // public static final String INT = "int"; // public static final String BOOLEAN = "boolean"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java // public class Context { // // private Parent parent; // // private Map<String, Template> templates; // // private Map<String, Object> variables; // // private Sink sink; // // public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) { // this.templates = templates; // this.variables = variables; // this.sink = sink; // } // // public Context(Context parentContext, Map<String, Object> entity) { // parent = new Parent(entity, parentContext.getParent()); // templates = parentContext.getTemplates(); // variables = parentContext.getVariables(); // sink = parentContext.getSink(); // } // // public Parent getParent() { // return parent; // } // // public Map<String, Object> getVariables() { // return variables; // } // // public Sink getSink() { // return sink; // } // // public Map<String, Template> getTemplates() { // return templates; // } // // } // // Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java // public class Field { // // private String name; // // private String type; // // private Provider provider; // // public Field() { // } // // public Field(String name, String type, Provider provider) { // this.name = name; // this.type = type; // this.provider = provider; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // public Provider getProvider() { // return provider; // } // // public void setProvider(Provider provider) { // this.provider = provider; // } // } // // Path: src/main/java/com/presidentio/testdatagenerator/provider/RandomProvider.java // public class RandomProvider implements ValueProvider { // // private static final String ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; // // private long size = 10; // private Random random = new Random(); // // @Override // public void init(Map<String, String> props) { // Map<String, String> propsCopy = new HashMap<>(props); // if (propsCopy.containsKey(PropConst.SIZE)) { // size = Long.valueOf(propsCopy.remove(PropConst.SIZE)); // } // if (!propsCopy.isEmpty()) { // throw new IllegalArgumentException("Redundant props for RandomProvider: " + propsCopy); // } // // } // // @Override // public Object nextValue(Context context, Field field) { // String type = field.getType(); // switch (type) { // case TypeConst.STRING: // StringBuilder result = new StringBuilder((int) size); // for (int i = 0; i < size; i++) { // result.append(ALPHABET.charAt(random.nextInt(ALPHABET.length()))); // } // return result; // case TypeConst.LONG: // return random.nextLong() % size; // case TypeConst.INT: // return random.nextInt((int) size); // case TypeConst.BOOLEAN: // return random.nextBoolean(); // default: // throw new IllegalArgumentException("Field type not known: " + type); // } // } // } // // Path: src/main/java/com/presidentio/testdatagenerator/provider/ValueProvider.java // public interface ValueProvider { // // void init(Map<String, String> props); // // Object nextValue(Context context, Field field); // // }
import com.presidentio.testdatagenerator.cons.TypeConst; import com.presidentio.testdatagenerator.context.Context; import com.presidentio.testdatagenerator.model.Field; import com.presidentio.testdatagenerator.provider.RandomProvider; import com.presidentio.testdatagenerator.provider.ValueProvider; import org.openjdk.jmh.annotations.*; import java.util.Collections; import java.util.concurrent.TimeUnit;
package com.presidentio.testdatagenerator.benchmark; /** * Created by Vitalii_Gergel on 3/19/2015. */ @Fork(1) @Warmup(iterations = 3) @OutputTimeUnit(TimeUnit.MICROSECONDS) @Measurement(iterations = 10) @State(Scope.Benchmark) public class RandomBenchmark {
// Path: src/main/java/com/presidentio/testdatagenerator/cons/TypeConst.java // public class TypeConst { // // public static final String STRING = "string"; // public static final String LONG = "long"; // public static final String INT = "int"; // public static final String BOOLEAN = "boolean"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java // public class Context { // // private Parent parent; // // private Map<String, Template> templates; // // private Map<String, Object> variables; // // private Sink sink; // // public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) { // this.templates = templates; // this.variables = variables; // this.sink = sink; // } // // public Context(Context parentContext, Map<String, Object> entity) { // parent = new Parent(entity, parentContext.getParent()); // templates = parentContext.getTemplates(); // variables = parentContext.getVariables(); // sink = parentContext.getSink(); // } // // public Parent getParent() { // return parent; // } // // public Map<String, Object> getVariables() { // return variables; // } // // public Sink getSink() { // return sink; // } // // public Map<String, Template> getTemplates() { // return templates; // } // // } // // Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java // public class Field { // // private String name; // // private String type; // // private Provider provider; // // public Field() { // } // // public Field(String name, String type, Provider provider) { // this.name = name; // this.type = type; // this.provider = provider; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // public Provider getProvider() { // return provider; // } // // public void setProvider(Provider provider) { // this.provider = provider; // } // } // // Path: src/main/java/com/presidentio/testdatagenerator/provider/RandomProvider.java // public class RandomProvider implements ValueProvider { // // private static final String ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; // // private long size = 10; // private Random random = new Random(); // // @Override // public void init(Map<String, String> props) { // Map<String, String> propsCopy = new HashMap<>(props); // if (propsCopy.containsKey(PropConst.SIZE)) { // size = Long.valueOf(propsCopy.remove(PropConst.SIZE)); // } // if (!propsCopy.isEmpty()) { // throw new IllegalArgumentException("Redundant props for RandomProvider: " + propsCopy); // } // // } // // @Override // public Object nextValue(Context context, Field field) { // String type = field.getType(); // switch (type) { // case TypeConst.STRING: // StringBuilder result = new StringBuilder((int) size); // for (int i = 0; i < size; i++) { // result.append(ALPHABET.charAt(random.nextInt(ALPHABET.length()))); // } // return result; // case TypeConst.LONG: // return random.nextLong() % size; // case TypeConst.INT: // return random.nextInt((int) size); // case TypeConst.BOOLEAN: // return random.nextBoolean(); // default: // throw new IllegalArgumentException("Field type not known: " + type); // } // } // } // // Path: src/main/java/com/presidentio/testdatagenerator/provider/ValueProvider.java // public interface ValueProvider { // // void init(Map<String, String> props); // // Object nextValue(Context context, Field field); // // } // Path: src/main/java/com/presidentio/testdatagenerator/benchmark/RandomBenchmark.java import com.presidentio.testdatagenerator.cons.TypeConst; import com.presidentio.testdatagenerator.context.Context; import com.presidentio.testdatagenerator.model.Field; import com.presidentio.testdatagenerator.provider.RandomProvider; import com.presidentio.testdatagenerator.provider.ValueProvider; import org.openjdk.jmh.annotations.*; import java.util.Collections; import java.util.concurrent.TimeUnit; package com.presidentio.testdatagenerator.benchmark; /** * Created by Vitalii_Gergel on 3/19/2015. */ @Fork(1) @Warmup(iterations = 3) @OutputTimeUnit(TimeUnit.MICROSECONDS) @Measurement(iterations = 10) @State(Scope.Benchmark) public class RandomBenchmark {
private Context context;
presidentio/test-data-generator
src/main/java/com/presidentio/testdatagenerator/benchmark/RandomBenchmark.java
// Path: src/main/java/com/presidentio/testdatagenerator/cons/TypeConst.java // public class TypeConst { // // public static final String STRING = "string"; // public static final String LONG = "long"; // public static final String INT = "int"; // public static final String BOOLEAN = "boolean"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java // public class Context { // // private Parent parent; // // private Map<String, Template> templates; // // private Map<String, Object> variables; // // private Sink sink; // // public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) { // this.templates = templates; // this.variables = variables; // this.sink = sink; // } // // public Context(Context parentContext, Map<String, Object> entity) { // parent = new Parent(entity, parentContext.getParent()); // templates = parentContext.getTemplates(); // variables = parentContext.getVariables(); // sink = parentContext.getSink(); // } // // public Parent getParent() { // return parent; // } // // public Map<String, Object> getVariables() { // return variables; // } // // public Sink getSink() { // return sink; // } // // public Map<String, Template> getTemplates() { // return templates; // } // // } // // Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java // public class Field { // // private String name; // // private String type; // // private Provider provider; // // public Field() { // } // // public Field(String name, String type, Provider provider) { // this.name = name; // this.type = type; // this.provider = provider; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // public Provider getProvider() { // return provider; // } // // public void setProvider(Provider provider) { // this.provider = provider; // } // } // // Path: src/main/java/com/presidentio/testdatagenerator/provider/RandomProvider.java // public class RandomProvider implements ValueProvider { // // private static final String ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; // // private long size = 10; // private Random random = new Random(); // // @Override // public void init(Map<String, String> props) { // Map<String, String> propsCopy = new HashMap<>(props); // if (propsCopy.containsKey(PropConst.SIZE)) { // size = Long.valueOf(propsCopy.remove(PropConst.SIZE)); // } // if (!propsCopy.isEmpty()) { // throw new IllegalArgumentException("Redundant props for RandomProvider: " + propsCopy); // } // // } // // @Override // public Object nextValue(Context context, Field field) { // String type = field.getType(); // switch (type) { // case TypeConst.STRING: // StringBuilder result = new StringBuilder((int) size); // for (int i = 0; i < size; i++) { // result.append(ALPHABET.charAt(random.nextInt(ALPHABET.length()))); // } // return result; // case TypeConst.LONG: // return random.nextLong() % size; // case TypeConst.INT: // return random.nextInt((int) size); // case TypeConst.BOOLEAN: // return random.nextBoolean(); // default: // throw new IllegalArgumentException("Field type not known: " + type); // } // } // } // // Path: src/main/java/com/presidentio/testdatagenerator/provider/ValueProvider.java // public interface ValueProvider { // // void init(Map<String, String> props); // // Object nextValue(Context context, Field field); // // }
import com.presidentio.testdatagenerator.cons.TypeConst; import com.presidentio.testdatagenerator.context.Context; import com.presidentio.testdatagenerator.model.Field; import com.presidentio.testdatagenerator.provider.RandomProvider; import com.presidentio.testdatagenerator.provider.ValueProvider; import org.openjdk.jmh.annotations.*; import java.util.Collections; import java.util.concurrent.TimeUnit;
package com.presidentio.testdatagenerator.benchmark; /** * Created by Vitalii_Gergel on 3/19/2015. */ @Fork(1) @Warmup(iterations = 3) @OutputTimeUnit(TimeUnit.MICROSECONDS) @Measurement(iterations = 10) @State(Scope.Benchmark) public class RandomBenchmark { private Context context;
// Path: src/main/java/com/presidentio/testdatagenerator/cons/TypeConst.java // public class TypeConst { // // public static final String STRING = "string"; // public static final String LONG = "long"; // public static final String INT = "int"; // public static final String BOOLEAN = "boolean"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java // public class Context { // // private Parent parent; // // private Map<String, Template> templates; // // private Map<String, Object> variables; // // private Sink sink; // // public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) { // this.templates = templates; // this.variables = variables; // this.sink = sink; // } // // public Context(Context parentContext, Map<String, Object> entity) { // parent = new Parent(entity, parentContext.getParent()); // templates = parentContext.getTemplates(); // variables = parentContext.getVariables(); // sink = parentContext.getSink(); // } // // public Parent getParent() { // return parent; // } // // public Map<String, Object> getVariables() { // return variables; // } // // public Sink getSink() { // return sink; // } // // public Map<String, Template> getTemplates() { // return templates; // } // // } // // Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java // public class Field { // // private String name; // // private String type; // // private Provider provider; // // public Field() { // } // // public Field(String name, String type, Provider provider) { // this.name = name; // this.type = type; // this.provider = provider; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // public Provider getProvider() { // return provider; // } // // public void setProvider(Provider provider) { // this.provider = provider; // } // } // // Path: src/main/java/com/presidentio/testdatagenerator/provider/RandomProvider.java // public class RandomProvider implements ValueProvider { // // private static final String ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; // // private long size = 10; // private Random random = new Random(); // // @Override // public void init(Map<String, String> props) { // Map<String, String> propsCopy = new HashMap<>(props); // if (propsCopy.containsKey(PropConst.SIZE)) { // size = Long.valueOf(propsCopy.remove(PropConst.SIZE)); // } // if (!propsCopy.isEmpty()) { // throw new IllegalArgumentException("Redundant props for RandomProvider: " + propsCopy); // } // // } // // @Override // public Object nextValue(Context context, Field field) { // String type = field.getType(); // switch (type) { // case TypeConst.STRING: // StringBuilder result = new StringBuilder((int) size); // for (int i = 0; i < size; i++) { // result.append(ALPHABET.charAt(random.nextInt(ALPHABET.length()))); // } // return result; // case TypeConst.LONG: // return random.nextLong() % size; // case TypeConst.INT: // return random.nextInt((int) size); // case TypeConst.BOOLEAN: // return random.nextBoolean(); // default: // throw new IllegalArgumentException("Field type not known: " + type); // } // } // } // // Path: src/main/java/com/presidentio/testdatagenerator/provider/ValueProvider.java // public interface ValueProvider { // // void init(Map<String, String> props); // // Object nextValue(Context context, Field field); // // } // Path: src/main/java/com/presidentio/testdatagenerator/benchmark/RandomBenchmark.java import com.presidentio.testdatagenerator.cons.TypeConst; import com.presidentio.testdatagenerator.context.Context; import com.presidentio.testdatagenerator.model.Field; import com.presidentio.testdatagenerator.provider.RandomProvider; import com.presidentio.testdatagenerator.provider.ValueProvider; import org.openjdk.jmh.annotations.*; import java.util.Collections; import java.util.concurrent.TimeUnit; package com.presidentio.testdatagenerator.benchmark; /** * Created by Vitalii_Gergel on 3/19/2015. */ @Fork(1) @Warmup(iterations = 3) @OutputTimeUnit(TimeUnit.MICROSECONDS) @Measurement(iterations = 10) @State(Scope.Benchmark) public class RandomBenchmark { private Context context;
private ValueProvider valueProvider;
presidentio/test-data-generator
src/main/java/com/presidentio/testdatagenerator/benchmark/RandomBenchmark.java
// Path: src/main/java/com/presidentio/testdatagenerator/cons/TypeConst.java // public class TypeConst { // // public static final String STRING = "string"; // public static final String LONG = "long"; // public static final String INT = "int"; // public static final String BOOLEAN = "boolean"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java // public class Context { // // private Parent parent; // // private Map<String, Template> templates; // // private Map<String, Object> variables; // // private Sink sink; // // public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) { // this.templates = templates; // this.variables = variables; // this.sink = sink; // } // // public Context(Context parentContext, Map<String, Object> entity) { // parent = new Parent(entity, parentContext.getParent()); // templates = parentContext.getTemplates(); // variables = parentContext.getVariables(); // sink = parentContext.getSink(); // } // // public Parent getParent() { // return parent; // } // // public Map<String, Object> getVariables() { // return variables; // } // // public Sink getSink() { // return sink; // } // // public Map<String, Template> getTemplates() { // return templates; // } // // } // // Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java // public class Field { // // private String name; // // private String type; // // private Provider provider; // // public Field() { // } // // public Field(String name, String type, Provider provider) { // this.name = name; // this.type = type; // this.provider = provider; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // public Provider getProvider() { // return provider; // } // // public void setProvider(Provider provider) { // this.provider = provider; // } // } // // Path: src/main/java/com/presidentio/testdatagenerator/provider/RandomProvider.java // public class RandomProvider implements ValueProvider { // // private static final String ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; // // private long size = 10; // private Random random = new Random(); // // @Override // public void init(Map<String, String> props) { // Map<String, String> propsCopy = new HashMap<>(props); // if (propsCopy.containsKey(PropConst.SIZE)) { // size = Long.valueOf(propsCopy.remove(PropConst.SIZE)); // } // if (!propsCopy.isEmpty()) { // throw new IllegalArgumentException("Redundant props for RandomProvider: " + propsCopy); // } // // } // // @Override // public Object nextValue(Context context, Field field) { // String type = field.getType(); // switch (type) { // case TypeConst.STRING: // StringBuilder result = new StringBuilder((int) size); // for (int i = 0; i < size; i++) { // result.append(ALPHABET.charAt(random.nextInt(ALPHABET.length()))); // } // return result; // case TypeConst.LONG: // return random.nextLong() % size; // case TypeConst.INT: // return random.nextInt((int) size); // case TypeConst.BOOLEAN: // return random.nextBoolean(); // default: // throw new IllegalArgumentException("Field type not known: " + type); // } // } // } // // Path: src/main/java/com/presidentio/testdatagenerator/provider/ValueProvider.java // public interface ValueProvider { // // void init(Map<String, String> props); // // Object nextValue(Context context, Field field); // // }
import com.presidentio.testdatagenerator.cons.TypeConst; import com.presidentio.testdatagenerator.context.Context; import com.presidentio.testdatagenerator.model.Field; import com.presidentio.testdatagenerator.provider.RandomProvider; import com.presidentio.testdatagenerator.provider.ValueProvider; import org.openjdk.jmh.annotations.*; import java.util.Collections; import java.util.concurrent.TimeUnit;
package com.presidentio.testdatagenerator.benchmark; /** * Created by Vitalii_Gergel on 3/19/2015. */ @Fork(1) @Warmup(iterations = 3) @OutputTimeUnit(TimeUnit.MICROSECONDS) @Measurement(iterations = 10) @State(Scope.Benchmark) public class RandomBenchmark { private Context context; private ValueProvider valueProvider;
// Path: src/main/java/com/presidentio/testdatagenerator/cons/TypeConst.java // public class TypeConst { // // public static final String STRING = "string"; // public static final String LONG = "long"; // public static final String INT = "int"; // public static final String BOOLEAN = "boolean"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java // public class Context { // // private Parent parent; // // private Map<String, Template> templates; // // private Map<String, Object> variables; // // private Sink sink; // // public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) { // this.templates = templates; // this.variables = variables; // this.sink = sink; // } // // public Context(Context parentContext, Map<String, Object> entity) { // parent = new Parent(entity, parentContext.getParent()); // templates = parentContext.getTemplates(); // variables = parentContext.getVariables(); // sink = parentContext.getSink(); // } // // public Parent getParent() { // return parent; // } // // public Map<String, Object> getVariables() { // return variables; // } // // public Sink getSink() { // return sink; // } // // public Map<String, Template> getTemplates() { // return templates; // } // // } // // Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java // public class Field { // // private String name; // // private String type; // // private Provider provider; // // public Field() { // } // // public Field(String name, String type, Provider provider) { // this.name = name; // this.type = type; // this.provider = provider; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // public Provider getProvider() { // return provider; // } // // public void setProvider(Provider provider) { // this.provider = provider; // } // } // // Path: src/main/java/com/presidentio/testdatagenerator/provider/RandomProvider.java // public class RandomProvider implements ValueProvider { // // private static final String ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; // // private long size = 10; // private Random random = new Random(); // // @Override // public void init(Map<String, String> props) { // Map<String, String> propsCopy = new HashMap<>(props); // if (propsCopy.containsKey(PropConst.SIZE)) { // size = Long.valueOf(propsCopy.remove(PropConst.SIZE)); // } // if (!propsCopy.isEmpty()) { // throw new IllegalArgumentException("Redundant props for RandomProvider: " + propsCopy); // } // // } // // @Override // public Object nextValue(Context context, Field field) { // String type = field.getType(); // switch (type) { // case TypeConst.STRING: // StringBuilder result = new StringBuilder((int) size); // for (int i = 0; i < size; i++) { // result.append(ALPHABET.charAt(random.nextInt(ALPHABET.length()))); // } // return result; // case TypeConst.LONG: // return random.nextLong() % size; // case TypeConst.INT: // return random.nextInt((int) size); // case TypeConst.BOOLEAN: // return random.nextBoolean(); // default: // throw new IllegalArgumentException("Field type not known: " + type); // } // } // } // // Path: src/main/java/com/presidentio/testdatagenerator/provider/ValueProvider.java // public interface ValueProvider { // // void init(Map<String, String> props); // // Object nextValue(Context context, Field field); // // } // Path: src/main/java/com/presidentio/testdatagenerator/benchmark/RandomBenchmark.java import com.presidentio.testdatagenerator.cons.TypeConst; import com.presidentio.testdatagenerator.context.Context; import com.presidentio.testdatagenerator.model.Field; import com.presidentio.testdatagenerator.provider.RandomProvider; import com.presidentio.testdatagenerator.provider.ValueProvider; import org.openjdk.jmh.annotations.*; import java.util.Collections; import java.util.concurrent.TimeUnit; package com.presidentio.testdatagenerator.benchmark; /** * Created by Vitalii_Gergel on 3/19/2015. */ @Fork(1) @Warmup(iterations = 3) @OutputTimeUnit(TimeUnit.MICROSECONDS) @Measurement(iterations = 10) @State(Scope.Benchmark) public class RandomBenchmark { private Context context; private ValueProvider valueProvider;
private Field field;
presidentio/test-data-generator
src/main/java/com/presidentio/testdatagenerator/benchmark/RandomBenchmark.java
// Path: src/main/java/com/presidentio/testdatagenerator/cons/TypeConst.java // public class TypeConst { // // public static final String STRING = "string"; // public static final String LONG = "long"; // public static final String INT = "int"; // public static final String BOOLEAN = "boolean"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java // public class Context { // // private Parent parent; // // private Map<String, Template> templates; // // private Map<String, Object> variables; // // private Sink sink; // // public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) { // this.templates = templates; // this.variables = variables; // this.sink = sink; // } // // public Context(Context parentContext, Map<String, Object> entity) { // parent = new Parent(entity, parentContext.getParent()); // templates = parentContext.getTemplates(); // variables = parentContext.getVariables(); // sink = parentContext.getSink(); // } // // public Parent getParent() { // return parent; // } // // public Map<String, Object> getVariables() { // return variables; // } // // public Sink getSink() { // return sink; // } // // public Map<String, Template> getTemplates() { // return templates; // } // // } // // Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java // public class Field { // // private String name; // // private String type; // // private Provider provider; // // public Field() { // } // // public Field(String name, String type, Provider provider) { // this.name = name; // this.type = type; // this.provider = provider; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // public Provider getProvider() { // return provider; // } // // public void setProvider(Provider provider) { // this.provider = provider; // } // } // // Path: src/main/java/com/presidentio/testdatagenerator/provider/RandomProvider.java // public class RandomProvider implements ValueProvider { // // private static final String ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; // // private long size = 10; // private Random random = new Random(); // // @Override // public void init(Map<String, String> props) { // Map<String, String> propsCopy = new HashMap<>(props); // if (propsCopy.containsKey(PropConst.SIZE)) { // size = Long.valueOf(propsCopy.remove(PropConst.SIZE)); // } // if (!propsCopy.isEmpty()) { // throw new IllegalArgumentException("Redundant props for RandomProvider: " + propsCopy); // } // // } // // @Override // public Object nextValue(Context context, Field field) { // String type = field.getType(); // switch (type) { // case TypeConst.STRING: // StringBuilder result = new StringBuilder((int) size); // for (int i = 0; i < size; i++) { // result.append(ALPHABET.charAt(random.nextInt(ALPHABET.length()))); // } // return result; // case TypeConst.LONG: // return random.nextLong() % size; // case TypeConst.INT: // return random.nextInt((int) size); // case TypeConst.BOOLEAN: // return random.nextBoolean(); // default: // throw new IllegalArgumentException("Field type not known: " + type); // } // } // } // // Path: src/main/java/com/presidentio/testdatagenerator/provider/ValueProvider.java // public interface ValueProvider { // // void init(Map<String, String> props); // // Object nextValue(Context context, Field field); // // }
import com.presidentio.testdatagenerator.cons.TypeConst; import com.presidentio.testdatagenerator.context.Context; import com.presidentio.testdatagenerator.model.Field; import com.presidentio.testdatagenerator.provider.RandomProvider; import com.presidentio.testdatagenerator.provider.ValueProvider; import org.openjdk.jmh.annotations.*; import java.util.Collections; import java.util.concurrent.TimeUnit;
package com.presidentio.testdatagenerator.benchmark; /** * Created by Vitalii_Gergel on 3/19/2015. */ @Fork(1) @Warmup(iterations = 3) @OutputTimeUnit(TimeUnit.MICROSECONDS) @Measurement(iterations = 10) @State(Scope.Benchmark) public class RandomBenchmark { private Context context; private ValueProvider valueProvider; private Field field; @Setup public void init() {
// Path: src/main/java/com/presidentio/testdatagenerator/cons/TypeConst.java // public class TypeConst { // // public static final String STRING = "string"; // public static final String LONG = "long"; // public static final String INT = "int"; // public static final String BOOLEAN = "boolean"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java // public class Context { // // private Parent parent; // // private Map<String, Template> templates; // // private Map<String, Object> variables; // // private Sink sink; // // public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) { // this.templates = templates; // this.variables = variables; // this.sink = sink; // } // // public Context(Context parentContext, Map<String, Object> entity) { // parent = new Parent(entity, parentContext.getParent()); // templates = parentContext.getTemplates(); // variables = parentContext.getVariables(); // sink = parentContext.getSink(); // } // // public Parent getParent() { // return parent; // } // // public Map<String, Object> getVariables() { // return variables; // } // // public Sink getSink() { // return sink; // } // // public Map<String, Template> getTemplates() { // return templates; // } // // } // // Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java // public class Field { // // private String name; // // private String type; // // private Provider provider; // // public Field() { // } // // public Field(String name, String type, Provider provider) { // this.name = name; // this.type = type; // this.provider = provider; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // public Provider getProvider() { // return provider; // } // // public void setProvider(Provider provider) { // this.provider = provider; // } // } // // Path: src/main/java/com/presidentio/testdatagenerator/provider/RandomProvider.java // public class RandomProvider implements ValueProvider { // // private static final String ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; // // private long size = 10; // private Random random = new Random(); // // @Override // public void init(Map<String, String> props) { // Map<String, String> propsCopy = new HashMap<>(props); // if (propsCopy.containsKey(PropConst.SIZE)) { // size = Long.valueOf(propsCopy.remove(PropConst.SIZE)); // } // if (!propsCopy.isEmpty()) { // throw new IllegalArgumentException("Redundant props for RandomProvider: " + propsCopy); // } // // } // // @Override // public Object nextValue(Context context, Field field) { // String type = field.getType(); // switch (type) { // case TypeConst.STRING: // StringBuilder result = new StringBuilder((int) size); // for (int i = 0; i < size; i++) { // result.append(ALPHABET.charAt(random.nextInt(ALPHABET.length()))); // } // return result; // case TypeConst.LONG: // return random.nextLong() % size; // case TypeConst.INT: // return random.nextInt((int) size); // case TypeConst.BOOLEAN: // return random.nextBoolean(); // default: // throw new IllegalArgumentException("Field type not known: " + type); // } // } // } // // Path: src/main/java/com/presidentio/testdatagenerator/provider/ValueProvider.java // public interface ValueProvider { // // void init(Map<String, String> props); // // Object nextValue(Context context, Field field); // // } // Path: src/main/java/com/presidentio/testdatagenerator/benchmark/RandomBenchmark.java import com.presidentio.testdatagenerator.cons.TypeConst; import com.presidentio.testdatagenerator.context.Context; import com.presidentio.testdatagenerator.model.Field; import com.presidentio.testdatagenerator.provider.RandomProvider; import com.presidentio.testdatagenerator.provider.ValueProvider; import org.openjdk.jmh.annotations.*; import java.util.Collections; import java.util.concurrent.TimeUnit; package com.presidentio.testdatagenerator.benchmark; /** * Created by Vitalii_Gergel on 3/19/2015. */ @Fork(1) @Warmup(iterations = 3) @OutputTimeUnit(TimeUnit.MICROSECONDS) @Measurement(iterations = 10) @State(Scope.Benchmark) public class RandomBenchmark { private Context context; private ValueProvider valueProvider; private Field field; @Setup public void init() {
valueProvider = new RandomProvider();
presidentio/test-data-generator
src/main/java/com/presidentio/testdatagenerator/benchmark/RandomBenchmark.java
// Path: src/main/java/com/presidentio/testdatagenerator/cons/TypeConst.java // public class TypeConst { // // public static final String STRING = "string"; // public static final String LONG = "long"; // public static final String INT = "int"; // public static final String BOOLEAN = "boolean"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java // public class Context { // // private Parent parent; // // private Map<String, Template> templates; // // private Map<String, Object> variables; // // private Sink sink; // // public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) { // this.templates = templates; // this.variables = variables; // this.sink = sink; // } // // public Context(Context parentContext, Map<String, Object> entity) { // parent = new Parent(entity, parentContext.getParent()); // templates = parentContext.getTemplates(); // variables = parentContext.getVariables(); // sink = parentContext.getSink(); // } // // public Parent getParent() { // return parent; // } // // public Map<String, Object> getVariables() { // return variables; // } // // public Sink getSink() { // return sink; // } // // public Map<String, Template> getTemplates() { // return templates; // } // // } // // Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java // public class Field { // // private String name; // // private String type; // // private Provider provider; // // public Field() { // } // // public Field(String name, String type, Provider provider) { // this.name = name; // this.type = type; // this.provider = provider; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // public Provider getProvider() { // return provider; // } // // public void setProvider(Provider provider) { // this.provider = provider; // } // } // // Path: src/main/java/com/presidentio/testdatagenerator/provider/RandomProvider.java // public class RandomProvider implements ValueProvider { // // private static final String ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; // // private long size = 10; // private Random random = new Random(); // // @Override // public void init(Map<String, String> props) { // Map<String, String> propsCopy = new HashMap<>(props); // if (propsCopy.containsKey(PropConst.SIZE)) { // size = Long.valueOf(propsCopy.remove(PropConst.SIZE)); // } // if (!propsCopy.isEmpty()) { // throw new IllegalArgumentException("Redundant props for RandomProvider: " + propsCopy); // } // // } // // @Override // public Object nextValue(Context context, Field field) { // String type = field.getType(); // switch (type) { // case TypeConst.STRING: // StringBuilder result = new StringBuilder((int) size); // for (int i = 0; i < size; i++) { // result.append(ALPHABET.charAt(random.nextInt(ALPHABET.length()))); // } // return result; // case TypeConst.LONG: // return random.nextLong() % size; // case TypeConst.INT: // return random.nextInt((int) size); // case TypeConst.BOOLEAN: // return random.nextBoolean(); // default: // throw new IllegalArgumentException("Field type not known: " + type); // } // } // } // // Path: src/main/java/com/presidentio/testdatagenerator/provider/ValueProvider.java // public interface ValueProvider { // // void init(Map<String, String> props); // // Object nextValue(Context context, Field field); // // }
import com.presidentio.testdatagenerator.cons.TypeConst; import com.presidentio.testdatagenerator.context.Context; import com.presidentio.testdatagenerator.model.Field; import com.presidentio.testdatagenerator.provider.RandomProvider; import com.presidentio.testdatagenerator.provider.ValueProvider; import org.openjdk.jmh.annotations.*; import java.util.Collections; import java.util.concurrent.TimeUnit;
package com.presidentio.testdatagenerator.benchmark; /** * Created by Vitalii_Gergel on 3/19/2015. */ @Fork(1) @Warmup(iterations = 3) @OutputTimeUnit(TimeUnit.MICROSECONDS) @Measurement(iterations = 10) @State(Scope.Benchmark) public class RandomBenchmark { private Context context; private ValueProvider valueProvider; private Field field; @Setup public void init() { valueProvider = new RandomProvider(); valueProvider.init(Collections.<String, String>emptyMap());
// Path: src/main/java/com/presidentio/testdatagenerator/cons/TypeConst.java // public class TypeConst { // // public static final String STRING = "string"; // public static final String LONG = "long"; // public static final String INT = "int"; // public static final String BOOLEAN = "boolean"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java // public class Context { // // private Parent parent; // // private Map<String, Template> templates; // // private Map<String, Object> variables; // // private Sink sink; // // public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) { // this.templates = templates; // this.variables = variables; // this.sink = sink; // } // // public Context(Context parentContext, Map<String, Object> entity) { // parent = new Parent(entity, parentContext.getParent()); // templates = parentContext.getTemplates(); // variables = parentContext.getVariables(); // sink = parentContext.getSink(); // } // // public Parent getParent() { // return parent; // } // // public Map<String, Object> getVariables() { // return variables; // } // // public Sink getSink() { // return sink; // } // // public Map<String, Template> getTemplates() { // return templates; // } // // } // // Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java // public class Field { // // private String name; // // private String type; // // private Provider provider; // // public Field() { // } // // public Field(String name, String type, Provider provider) { // this.name = name; // this.type = type; // this.provider = provider; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // public Provider getProvider() { // return provider; // } // // public void setProvider(Provider provider) { // this.provider = provider; // } // } // // Path: src/main/java/com/presidentio/testdatagenerator/provider/RandomProvider.java // public class RandomProvider implements ValueProvider { // // private static final String ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; // // private long size = 10; // private Random random = new Random(); // // @Override // public void init(Map<String, String> props) { // Map<String, String> propsCopy = new HashMap<>(props); // if (propsCopy.containsKey(PropConst.SIZE)) { // size = Long.valueOf(propsCopy.remove(PropConst.SIZE)); // } // if (!propsCopy.isEmpty()) { // throw new IllegalArgumentException("Redundant props for RandomProvider: " + propsCopy); // } // // } // // @Override // public Object nextValue(Context context, Field field) { // String type = field.getType(); // switch (type) { // case TypeConst.STRING: // StringBuilder result = new StringBuilder((int) size); // for (int i = 0; i < size; i++) { // result.append(ALPHABET.charAt(random.nextInt(ALPHABET.length()))); // } // return result; // case TypeConst.LONG: // return random.nextLong() % size; // case TypeConst.INT: // return random.nextInt((int) size); // case TypeConst.BOOLEAN: // return random.nextBoolean(); // default: // throw new IllegalArgumentException("Field type not known: " + type); // } // } // } // // Path: src/main/java/com/presidentio/testdatagenerator/provider/ValueProvider.java // public interface ValueProvider { // // void init(Map<String, String> props); // // Object nextValue(Context context, Field field); // // } // Path: src/main/java/com/presidentio/testdatagenerator/benchmark/RandomBenchmark.java import com.presidentio.testdatagenerator.cons.TypeConst; import com.presidentio.testdatagenerator.context.Context; import com.presidentio.testdatagenerator.model.Field; import com.presidentio.testdatagenerator.provider.RandomProvider; import com.presidentio.testdatagenerator.provider.ValueProvider; import org.openjdk.jmh.annotations.*; import java.util.Collections; import java.util.concurrent.TimeUnit; package com.presidentio.testdatagenerator.benchmark; /** * Created by Vitalii_Gergel on 3/19/2015. */ @Fork(1) @Warmup(iterations = 3) @OutputTimeUnit(TimeUnit.MICROSECONDS) @Measurement(iterations = 10) @State(Scope.Benchmark) public class RandomBenchmark { private Context context; private ValueProvider valueProvider; private Field field; @Setup public void init() { valueProvider = new RandomProvider(); valueProvider.init(Collections.<String, String>emptyMap());
field = new Field(null, TypeConst.BOOLEAN, null);
presidentio/test-data-generator
src/test/java/com/presidentio/testdatagenerator/ExtendTemplateTest.java
// Path: src/main/java/com/presidentio/testdatagenerator/model/Output.java // public class Output { // // private String type; // // @JsonDeserialize(contentUsing = StringDeserializer.class) // private Map<String, String> props; // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // public Map<String, String> getProps() { // return props; // } // // public void setProps(Map<String, String> props) { // this.props = props; // } // }
import com.presidentio.testdatagenerator.model.Output; import org.elasticsearch.action.count.CountResponse; import org.elasticsearch.client.Client; import org.elasticsearch.index.query.QueryBuilders; import org.junit.Assert; import java.util.Arrays; import java.util.List;
package com.presidentio.testdatagenerator; /** * Created by Vitalii_Gergel on 3/2/2015. */ public class ExtendTemplateTest extends AbstractEsTest { private String indexName = "test_data_generator"; @Override protected List<String> getSchemaResource() { return Arrays.asList("extend-template-test-schema.json"); } @Override
// Path: src/main/java/com/presidentio/testdatagenerator/model/Output.java // public class Output { // // private String type; // // @JsonDeserialize(contentUsing = StringDeserializer.class) // private Map<String, String> props; // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // public Map<String, String> getProps() { // return props; // } // // public void setProps(Map<String, String> props) { // this.props = props; // } // } // Path: src/test/java/com/presidentio/testdatagenerator/ExtendTemplateTest.java import com.presidentio.testdatagenerator.model.Output; import org.elasticsearch.action.count.CountResponse; import org.elasticsearch.client.Client; import org.elasticsearch.index.query.QueryBuilders; import org.junit.Assert; import java.util.Arrays; import java.util.List; package com.presidentio.testdatagenerator; /** * Created by Vitalii_Gergel on 3/2/2015. */ public class ExtendTemplateTest extends AbstractEsTest { private String indexName = "test_data_generator"; @Override protected List<String> getSchemaResource() { return Arrays.asList("extend-template-test-schema.json"); } @Override
protected void testResult(Output output) {
presidentio/test-data-generator
src/main/java/com/presidentio/testdatagenerator/provider/RandomProvider.java
// Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java // public class PropConst { // // public static final String TYPE = "type"; // public static final String VALUE = "value"; // public static final String SIZE = "size"; // public static final String DOMAIN = "domain"; // public static final String EXPR = "expr"; // public static final String FILE = "file"; // public static final String DELIMITER = "delimiter"; // public static final String ITEMS = "items"; // public static final String INDEX = "index"; // public static final String HOST = "host"; // public static final String PORT = "port"; // public static final String CLUSTER_NAME = "clusterName"; // public static final String CONNECTION_URL = "connectionUrl"; // public static final String JDBC_DRIVER = "jdbcDriver"; // public static final String DEPTH = "depth"; // public static final String FIELD = "field"; // public static final String VAR = "var"; // public static final String OP = "op"; // public static final String FORMAT = "format"; // public static final String HEADER = "header"; // public static final String SUFFIX = "suffix"; // public static final String PREFIX = "prefix"; // public static final String PATH_PROVIDER = "pathProvider"; // public static final String BROKER_LIST = "brokerList"; // public static final String GENDER = "gender"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/cons/TypeConst.java // public class TypeConst { // // public static final String STRING = "string"; // public static final String LONG = "long"; // public static final String INT = "int"; // public static final String BOOLEAN = "boolean"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java // public class Context { // // private Parent parent; // // private Map<String, Template> templates; // // private Map<String, Object> variables; // // private Sink sink; // // public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) { // this.templates = templates; // this.variables = variables; // this.sink = sink; // } // // public Context(Context parentContext, Map<String, Object> entity) { // parent = new Parent(entity, parentContext.getParent()); // templates = parentContext.getTemplates(); // variables = parentContext.getVariables(); // sink = parentContext.getSink(); // } // // public Parent getParent() { // return parent; // } // // public Map<String, Object> getVariables() { // return variables; // } // // public Sink getSink() { // return sink; // } // // public Map<String, Template> getTemplates() { // return templates; // } // // } // // Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java // public class Field { // // private String name; // // private String type; // // private Provider provider; // // public Field() { // } // // public Field(String name, String type, Provider provider) { // this.name = name; // this.type = type; // this.provider = provider; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // public Provider getProvider() { // return provider; // } // // public void setProvider(Provider provider) { // this.provider = provider; // } // }
import com.presidentio.testdatagenerator.cons.PropConst; import com.presidentio.testdatagenerator.cons.TypeConst; import com.presidentio.testdatagenerator.context.Context; import com.presidentio.testdatagenerator.model.Field; import java.util.HashMap; import java.util.Map; import java.util.Random;
/** * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.presidentio.testdatagenerator.provider; public class RandomProvider implements ValueProvider { private static final String ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; private long size = 10; private Random random = new Random(); @Override public void init(Map<String, String> props) { Map<String, String> propsCopy = new HashMap<>(props);
// Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java // public class PropConst { // // public static final String TYPE = "type"; // public static final String VALUE = "value"; // public static final String SIZE = "size"; // public static final String DOMAIN = "domain"; // public static final String EXPR = "expr"; // public static final String FILE = "file"; // public static final String DELIMITER = "delimiter"; // public static final String ITEMS = "items"; // public static final String INDEX = "index"; // public static final String HOST = "host"; // public static final String PORT = "port"; // public static final String CLUSTER_NAME = "clusterName"; // public static final String CONNECTION_URL = "connectionUrl"; // public static final String JDBC_DRIVER = "jdbcDriver"; // public static final String DEPTH = "depth"; // public static final String FIELD = "field"; // public static final String VAR = "var"; // public static final String OP = "op"; // public static final String FORMAT = "format"; // public static final String HEADER = "header"; // public static final String SUFFIX = "suffix"; // public static final String PREFIX = "prefix"; // public static final String PATH_PROVIDER = "pathProvider"; // public static final String BROKER_LIST = "brokerList"; // public static final String GENDER = "gender"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/cons/TypeConst.java // public class TypeConst { // // public static final String STRING = "string"; // public static final String LONG = "long"; // public static final String INT = "int"; // public static final String BOOLEAN = "boolean"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java // public class Context { // // private Parent parent; // // private Map<String, Template> templates; // // private Map<String, Object> variables; // // private Sink sink; // // public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) { // this.templates = templates; // this.variables = variables; // this.sink = sink; // } // // public Context(Context parentContext, Map<String, Object> entity) { // parent = new Parent(entity, parentContext.getParent()); // templates = parentContext.getTemplates(); // variables = parentContext.getVariables(); // sink = parentContext.getSink(); // } // // public Parent getParent() { // return parent; // } // // public Map<String, Object> getVariables() { // return variables; // } // // public Sink getSink() { // return sink; // } // // public Map<String, Template> getTemplates() { // return templates; // } // // } // // Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java // public class Field { // // private String name; // // private String type; // // private Provider provider; // // public Field() { // } // // public Field(String name, String type, Provider provider) { // this.name = name; // this.type = type; // this.provider = provider; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // public Provider getProvider() { // return provider; // } // // public void setProvider(Provider provider) { // this.provider = provider; // } // } // Path: src/main/java/com/presidentio/testdatagenerator/provider/RandomProvider.java import com.presidentio.testdatagenerator.cons.PropConst; import com.presidentio.testdatagenerator.cons.TypeConst; import com.presidentio.testdatagenerator.context.Context; import com.presidentio.testdatagenerator.model.Field; import java.util.HashMap; import java.util.Map; import java.util.Random; /** * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.presidentio.testdatagenerator.provider; public class RandomProvider implements ValueProvider { private static final String ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; private long size = 10; private Random random = new Random(); @Override public void init(Map<String, String> props) { Map<String, String> propsCopy = new HashMap<>(props);
if (propsCopy.containsKey(PropConst.SIZE)) {
presidentio/test-data-generator
src/main/java/com/presidentio/testdatagenerator/provider/RandomProvider.java
// Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java // public class PropConst { // // public static final String TYPE = "type"; // public static final String VALUE = "value"; // public static final String SIZE = "size"; // public static final String DOMAIN = "domain"; // public static final String EXPR = "expr"; // public static final String FILE = "file"; // public static final String DELIMITER = "delimiter"; // public static final String ITEMS = "items"; // public static final String INDEX = "index"; // public static final String HOST = "host"; // public static final String PORT = "port"; // public static final String CLUSTER_NAME = "clusterName"; // public static final String CONNECTION_URL = "connectionUrl"; // public static final String JDBC_DRIVER = "jdbcDriver"; // public static final String DEPTH = "depth"; // public static final String FIELD = "field"; // public static final String VAR = "var"; // public static final String OP = "op"; // public static final String FORMAT = "format"; // public static final String HEADER = "header"; // public static final String SUFFIX = "suffix"; // public static final String PREFIX = "prefix"; // public static final String PATH_PROVIDER = "pathProvider"; // public static final String BROKER_LIST = "brokerList"; // public static final String GENDER = "gender"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/cons/TypeConst.java // public class TypeConst { // // public static final String STRING = "string"; // public static final String LONG = "long"; // public static final String INT = "int"; // public static final String BOOLEAN = "boolean"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java // public class Context { // // private Parent parent; // // private Map<String, Template> templates; // // private Map<String, Object> variables; // // private Sink sink; // // public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) { // this.templates = templates; // this.variables = variables; // this.sink = sink; // } // // public Context(Context parentContext, Map<String, Object> entity) { // parent = new Parent(entity, parentContext.getParent()); // templates = parentContext.getTemplates(); // variables = parentContext.getVariables(); // sink = parentContext.getSink(); // } // // public Parent getParent() { // return parent; // } // // public Map<String, Object> getVariables() { // return variables; // } // // public Sink getSink() { // return sink; // } // // public Map<String, Template> getTemplates() { // return templates; // } // // } // // Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java // public class Field { // // private String name; // // private String type; // // private Provider provider; // // public Field() { // } // // public Field(String name, String type, Provider provider) { // this.name = name; // this.type = type; // this.provider = provider; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // public Provider getProvider() { // return provider; // } // // public void setProvider(Provider provider) { // this.provider = provider; // } // }
import com.presidentio.testdatagenerator.cons.PropConst; import com.presidentio.testdatagenerator.cons.TypeConst; import com.presidentio.testdatagenerator.context.Context; import com.presidentio.testdatagenerator.model.Field; import java.util.HashMap; import java.util.Map; import java.util.Random;
/** * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.presidentio.testdatagenerator.provider; public class RandomProvider implements ValueProvider { private static final String ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; private long size = 10; private Random random = new Random(); @Override public void init(Map<String, String> props) { Map<String, String> propsCopy = new HashMap<>(props); if (propsCopy.containsKey(PropConst.SIZE)) { size = Long.valueOf(propsCopy.remove(PropConst.SIZE)); } if (!propsCopy.isEmpty()) { throw new IllegalArgumentException("Redundant props for RandomProvider: " + propsCopy); } } @Override
// Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java // public class PropConst { // // public static final String TYPE = "type"; // public static final String VALUE = "value"; // public static final String SIZE = "size"; // public static final String DOMAIN = "domain"; // public static final String EXPR = "expr"; // public static final String FILE = "file"; // public static final String DELIMITER = "delimiter"; // public static final String ITEMS = "items"; // public static final String INDEX = "index"; // public static final String HOST = "host"; // public static final String PORT = "port"; // public static final String CLUSTER_NAME = "clusterName"; // public static final String CONNECTION_URL = "connectionUrl"; // public static final String JDBC_DRIVER = "jdbcDriver"; // public static final String DEPTH = "depth"; // public static final String FIELD = "field"; // public static final String VAR = "var"; // public static final String OP = "op"; // public static final String FORMAT = "format"; // public static final String HEADER = "header"; // public static final String SUFFIX = "suffix"; // public static final String PREFIX = "prefix"; // public static final String PATH_PROVIDER = "pathProvider"; // public static final String BROKER_LIST = "brokerList"; // public static final String GENDER = "gender"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/cons/TypeConst.java // public class TypeConst { // // public static final String STRING = "string"; // public static final String LONG = "long"; // public static final String INT = "int"; // public static final String BOOLEAN = "boolean"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java // public class Context { // // private Parent parent; // // private Map<String, Template> templates; // // private Map<String, Object> variables; // // private Sink sink; // // public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) { // this.templates = templates; // this.variables = variables; // this.sink = sink; // } // // public Context(Context parentContext, Map<String, Object> entity) { // parent = new Parent(entity, parentContext.getParent()); // templates = parentContext.getTemplates(); // variables = parentContext.getVariables(); // sink = parentContext.getSink(); // } // // public Parent getParent() { // return parent; // } // // public Map<String, Object> getVariables() { // return variables; // } // // public Sink getSink() { // return sink; // } // // public Map<String, Template> getTemplates() { // return templates; // } // // } // // Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java // public class Field { // // private String name; // // private String type; // // private Provider provider; // // public Field() { // } // // public Field(String name, String type, Provider provider) { // this.name = name; // this.type = type; // this.provider = provider; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // public Provider getProvider() { // return provider; // } // // public void setProvider(Provider provider) { // this.provider = provider; // } // } // Path: src/main/java/com/presidentio/testdatagenerator/provider/RandomProvider.java import com.presidentio.testdatagenerator.cons.PropConst; import com.presidentio.testdatagenerator.cons.TypeConst; import com.presidentio.testdatagenerator.context.Context; import com.presidentio.testdatagenerator.model.Field; import java.util.HashMap; import java.util.Map; import java.util.Random; /** * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.presidentio.testdatagenerator.provider; public class RandomProvider implements ValueProvider { private static final String ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; private long size = 10; private Random random = new Random(); @Override public void init(Map<String, String> props) { Map<String, String> propsCopy = new HashMap<>(props); if (propsCopy.containsKey(PropConst.SIZE)) { size = Long.valueOf(propsCopy.remove(PropConst.SIZE)); } if (!propsCopy.isEmpty()) { throw new IllegalArgumentException("Redundant props for RandomProvider: " + propsCopy); } } @Override
public Object nextValue(Context context, Field field) {
presidentio/test-data-generator
src/main/java/com/presidentio/testdatagenerator/provider/RandomProvider.java
// Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java // public class PropConst { // // public static final String TYPE = "type"; // public static final String VALUE = "value"; // public static final String SIZE = "size"; // public static final String DOMAIN = "domain"; // public static final String EXPR = "expr"; // public static final String FILE = "file"; // public static final String DELIMITER = "delimiter"; // public static final String ITEMS = "items"; // public static final String INDEX = "index"; // public static final String HOST = "host"; // public static final String PORT = "port"; // public static final String CLUSTER_NAME = "clusterName"; // public static final String CONNECTION_URL = "connectionUrl"; // public static final String JDBC_DRIVER = "jdbcDriver"; // public static final String DEPTH = "depth"; // public static final String FIELD = "field"; // public static final String VAR = "var"; // public static final String OP = "op"; // public static final String FORMAT = "format"; // public static final String HEADER = "header"; // public static final String SUFFIX = "suffix"; // public static final String PREFIX = "prefix"; // public static final String PATH_PROVIDER = "pathProvider"; // public static final String BROKER_LIST = "brokerList"; // public static final String GENDER = "gender"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/cons/TypeConst.java // public class TypeConst { // // public static final String STRING = "string"; // public static final String LONG = "long"; // public static final String INT = "int"; // public static final String BOOLEAN = "boolean"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java // public class Context { // // private Parent parent; // // private Map<String, Template> templates; // // private Map<String, Object> variables; // // private Sink sink; // // public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) { // this.templates = templates; // this.variables = variables; // this.sink = sink; // } // // public Context(Context parentContext, Map<String, Object> entity) { // parent = new Parent(entity, parentContext.getParent()); // templates = parentContext.getTemplates(); // variables = parentContext.getVariables(); // sink = parentContext.getSink(); // } // // public Parent getParent() { // return parent; // } // // public Map<String, Object> getVariables() { // return variables; // } // // public Sink getSink() { // return sink; // } // // public Map<String, Template> getTemplates() { // return templates; // } // // } // // Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java // public class Field { // // private String name; // // private String type; // // private Provider provider; // // public Field() { // } // // public Field(String name, String type, Provider provider) { // this.name = name; // this.type = type; // this.provider = provider; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // public Provider getProvider() { // return provider; // } // // public void setProvider(Provider provider) { // this.provider = provider; // } // }
import com.presidentio.testdatagenerator.cons.PropConst; import com.presidentio.testdatagenerator.cons.TypeConst; import com.presidentio.testdatagenerator.context.Context; import com.presidentio.testdatagenerator.model.Field; import java.util.HashMap; import java.util.Map; import java.util.Random;
/** * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.presidentio.testdatagenerator.provider; public class RandomProvider implements ValueProvider { private static final String ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; private long size = 10; private Random random = new Random(); @Override public void init(Map<String, String> props) { Map<String, String> propsCopy = new HashMap<>(props); if (propsCopy.containsKey(PropConst.SIZE)) { size = Long.valueOf(propsCopy.remove(PropConst.SIZE)); } if (!propsCopy.isEmpty()) { throw new IllegalArgumentException("Redundant props for RandomProvider: " + propsCopy); } } @Override
// Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java // public class PropConst { // // public static final String TYPE = "type"; // public static final String VALUE = "value"; // public static final String SIZE = "size"; // public static final String DOMAIN = "domain"; // public static final String EXPR = "expr"; // public static final String FILE = "file"; // public static final String DELIMITER = "delimiter"; // public static final String ITEMS = "items"; // public static final String INDEX = "index"; // public static final String HOST = "host"; // public static final String PORT = "port"; // public static final String CLUSTER_NAME = "clusterName"; // public static final String CONNECTION_URL = "connectionUrl"; // public static final String JDBC_DRIVER = "jdbcDriver"; // public static final String DEPTH = "depth"; // public static final String FIELD = "field"; // public static final String VAR = "var"; // public static final String OP = "op"; // public static final String FORMAT = "format"; // public static final String HEADER = "header"; // public static final String SUFFIX = "suffix"; // public static final String PREFIX = "prefix"; // public static final String PATH_PROVIDER = "pathProvider"; // public static final String BROKER_LIST = "brokerList"; // public static final String GENDER = "gender"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/cons/TypeConst.java // public class TypeConst { // // public static final String STRING = "string"; // public static final String LONG = "long"; // public static final String INT = "int"; // public static final String BOOLEAN = "boolean"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java // public class Context { // // private Parent parent; // // private Map<String, Template> templates; // // private Map<String, Object> variables; // // private Sink sink; // // public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) { // this.templates = templates; // this.variables = variables; // this.sink = sink; // } // // public Context(Context parentContext, Map<String, Object> entity) { // parent = new Parent(entity, parentContext.getParent()); // templates = parentContext.getTemplates(); // variables = parentContext.getVariables(); // sink = parentContext.getSink(); // } // // public Parent getParent() { // return parent; // } // // public Map<String, Object> getVariables() { // return variables; // } // // public Sink getSink() { // return sink; // } // // public Map<String, Template> getTemplates() { // return templates; // } // // } // // Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java // public class Field { // // private String name; // // private String type; // // private Provider provider; // // public Field() { // } // // public Field(String name, String type, Provider provider) { // this.name = name; // this.type = type; // this.provider = provider; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // public Provider getProvider() { // return provider; // } // // public void setProvider(Provider provider) { // this.provider = provider; // } // } // Path: src/main/java/com/presidentio/testdatagenerator/provider/RandomProvider.java import com.presidentio.testdatagenerator.cons.PropConst; import com.presidentio.testdatagenerator.cons.TypeConst; import com.presidentio.testdatagenerator.context.Context; import com.presidentio.testdatagenerator.model.Field; import java.util.HashMap; import java.util.Map; import java.util.Random; /** * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.presidentio.testdatagenerator.provider; public class RandomProvider implements ValueProvider { private static final String ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; private long size = 10; private Random random = new Random(); @Override public void init(Map<String, String> props) { Map<String, String> propsCopy = new HashMap<>(props); if (propsCopy.containsKey(PropConst.SIZE)) { size = Long.valueOf(propsCopy.remove(PropConst.SIZE)); } if (!propsCopy.isEmpty()) { throw new IllegalArgumentException("Redundant props for RandomProvider: " + propsCopy); } } @Override
public Object nextValue(Context context, Field field) {
presidentio/test-data-generator
src/main/java/com/presidentio/testdatagenerator/provider/RandomProvider.java
// Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java // public class PropConst { // // public static final String TYPE = "type"; // public static final String VALUE = "value"; // public static final String SIZE = "size"; // public static final String DOMAIN = "domain"; // public static final String EXPR = "expr"; // public static final String FILE = "file"; // public static final String DELIMITER = "delimiter"; // public static final String ITEMS = "items"; // public static final String INDEX = "index"; // public static final String HOST = "host"; // public static final String PORT = "port"; // public static final String CLUSTER_NAME = "clusterName"; // public static final String CONNECTION_URL = "connectionUrl"; // public static final String JDBC_DRIVER = "jdbcDriver"; // public static final String DEPTH = "depth"; // public static final String FIELD = "field"; // public static final String VAR = "var"; // public static final String OP = "op"; // public static final String FORMAT = "format"; // public static final String HEADER = "header"; // public static final String SUFFIX = "suffix"; // public static final String PREFIX = "prefix"; // public static final String PATH_PROVIDER = "pathProvider"; // public static final String BROKER_LIST = "brokerList"; // public static final String GENDER = "gender"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/cons/TypeConst.java // public class TypeConst { // // public static final String STRING = "string"; // public static final String LONG = "long"; // public static final String INT = "int"; // public static final String BOOLEAN = "boolean"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java // public class Context { // // private Parent parent; // // private Map<String, Template> templates; // // private Map<String, Object> variables; // // private Sink sink; // // public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) { // this.templates = templates; // this.variables = variables; // this.sink = sink; // } // // public Context(Context parentContext, Map<String, Object> entity) { // parent = new Parent(entity, parentContext.getParent()); // templates = parentContext.getTemplates(); // variables = parentContext.getVariables(); // sink = parentContext.getSink(); // } // // public Parent getParent() { // return parent; // } // // public Map<String, Object> getVariables() { // return variables; // } // // public Sink getSink() { // return sink; // } // // public Map<String, Template> getTemplates() { // return templates; // } // // } // // Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java // public class Field { // // private String name; // // private String type; // // private Provider provider; // // public Field() { // } // // public Field(String name, String type, Provider provider) { // this.name = name; // this.type = type; // this.provider = provider; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // public Provider getProvider() { // return provider; // } // // public void setProvider(Provider provider) { // this.provider = provider; // } // }
import com.presidentio.testdatagenerator.cons.PropConst; import com.presidentio.testdatagenerator.cons.TypeConst; import com.presidentio.testdatagenerator.context.Context; import com.presidentio.testdatagenerator.model.Field; import java.util.HashMap; import java.util.Map; import java.util.Random;
/** * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.presidentio.testdatagenerator.provider; public class RandomProvider implements ValueProvider { private static final String ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; private long size = 10; private Random random = new Random(); @Override public void init(Map<String, String> props) { Map<String, String> propsCopy = new HashMap<>(props); if (propsCopy.containsKey(PropConst.SIZE)) { size = Long.valueOf(propsCopy.remove(PropConst.SIZE)); } if (!propsCopy.isEmpty()) { throw new IllegalArgumentException("Redundant props for RandomProvider: " + propsCopy); } } @Override public Object nextValue(Context context, Field field) { String type = field.getType(); switch (type) {
// Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java // public class PropConst { // // public static final String TYPE = "type"; // public static final String VALUE = "value"; // public static final String SIZE = "size"; // public static final String DOMAIN = "domain"; // public static final String EXPR = "expr"; // public static final String FILE = "file"; // public static final String DELIMITER = "delimiter"; // public static final String ITEMS = "items"; // public static final String INDEX = "index"; // public static final String HOST = "host"; // public static final String PORT = "port"; // public static final String CLUSTER_NAME = "clusterName"; // public static final String CONNECTION_URL = "connectionUrl"; // public static final String JDBC_DRIVER = "jdbcDriver"; // public static final String DEPTH = "depth"; // public static final String FIELD = "field"; // public static final String VAR = "var"; // public static final String OP = "op"; // public static final String FORMAT = "format"; // public static final String HEADER = "header"; // public static final String SUFFIX = "suffix"; // public static final String PREFIX = "prefix"; // public static final String PATH_PROVIDER = "pathProvider"; // public static final String BROKER_LIST = "brokerList"; // public static final String GENDER = "gender"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/cons/TypeConst.java // public class TypeConst { // // public static final String STRING = "string"; // public static final String LONG = "long"; // public static final String INT = "int"; // public static final String BOOLEAN = "boolean"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java // public class Context { // // private Parent parent; // // private Map<String, Template> templates; // // private Map<String, Object> variables; // // private Sink sink; // // public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) { // this.templates = templates; // this.variables = variables; // this.sink = sink; // } // // public Context(Context parentContext, Map<String, Object> entity) { // parent = new Parent(entity, parentContext.getParent()); // templates = parentContext.getTemplates(); // variables = parentContext.getVariables(); // sink = parentContext.getSink(); // } // // public Parent getParent() { // return parent; // } // // public Map<String, Object> getVariables() { // return variables; // } // // public Sink getSink() { // return sink; // } // // public Map<String, Template> getTemplates() { // return templates; // } // // } // // Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java // public class Field { // // private String name; // // private String type; // // private Provider provider; // // public Field() { // } // // public Field(String name, String type, Provider provider) { // this.name = name; // this.type = type; // this.provider = provider; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // public Provider getProvider() { // return provider; // } // // public void setProvider(Provider provider) { // this.provider = provider; // } // } // Path: src/main/java/com/presidentio/testdatagenerator/provider/RandomProvider.java import com.presidentio.testdatagenerator.cons.PropConst; import com.presidentio.testdatagenerator.cons.TypeConst; import com.presidentio.testdatagenerator.context.Context; import com.presidentio.testdatagenerator.model.Field; import java.util.HashMap; import java.util.Map; import java.util.Random; /** * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.presidentio.testdatagenerator.provider; public class RandomProvider implements ValueProvider { private static final String ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; private long size = 10; private Random random = new Random(); @Override public void init(Map<String, String> props) { Map<String, String> propsCopy = new HashMap<>(props); if (propsCopy.containsKey(PropConst.SIZE)) { size = Long.valueOf(propsCopy.remove(PropConst.SIZE)); } if (!propsCopy.isEmpty()) { throw new IllegalArgumentException("Redundant props for RandomProvider: " + propsCopy); } } @Override public Object nextValue(Context context, Field field) { String type = field.getType(); switch (type) {
case TypeConst.STRING:
presidentio/test-data-generator
src/main/java/com/presidentio/testdatagenerator/provider/CountryProvider.java
// Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java // public class PropConst { // // public static final String TYPE = "type"; // public static final String VALUE = "value"; // public static final String SIZE = "size"; // public static final String DOMAIN = "domain"; // public static final String EXPR = "expr"; // public static final String FILE = "file"; // public static final String DELIMITER = "delimiter"; // public static final String ITEMS = "items"; // public static final String INDEX = "index"; // public static final String HOST = "host"; // public static final String PORT = "port"; // public static final String CLUSTER_NAME = "clusterName"; // public static final String CONNECTION_URL = "connectionUrl"; // public static final String JDBC_DRIVER = "jdbcDriver"; // public static final String DEPTH = "depth"; // public static final String FIELD = "field"; // public static final String VAR = "var"; // public static final String OP = "op"; // public static final String FORMAT = "format"; // public static final String HEADER = "header"; // public static final String SUFFIX = "suffix"; // public static final String PREFIX = "prefix"; // public static final String PATH_PROVIDER = "pathProvider"; // public static final String BROKER_LIST = "brokerList"; // public static final String GENDER = "gender"; // // }
import com.presidentio.testdatagenerator.cons.PropConst; import org.apache.commons.io.IOUtils; import java.io.IOException; import java.io.InputStream; import java.util.HashMap; import java.util.Map;
package com.presidentio.testdatagenerator.provider; /** * Created by Vitalii_Gergel on 2/11/2015. */ public class CountryProvider extends SelectProvider { private static String COUNTRIES; public static final String DELIMITER = "\r?\n"; private String getCountries() { if (COUNTRIES == null) { try (InputStream nameStream = DefaultValueProviderFactory.class.getClassLoader().getResourceAsStream("country.dat")) { COUNTRIES = IOUtils.toString(nameStream); } catch (IOException e) { throw new RuntimeException("Failed to load names", e); } } return COUNTRIES; } @Override public void init(Map<String, String> props) { Map<String, String> propsCopy = new HashMap<>(props);
// Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java // public class PropConst { // // public static final String TYPE = "type"; // public static final String VALUE = "value"; // public static final String SIZE = "size"; // public static final String DOMAIN = "domain"; // public static final String EXPR = "expr"; // public static final String FILE = "file"; // public static final String DELIMITER = "delimiter"; // public static final String ITEMS = "items"; // public static final String INDEX = "index"; // public static final String HOST = "host"; // public static final String PORT = "port"; // public static final String CLUSTER_NAME = "clusterName"; // public static final String CONNECTION_URL = "connectionUrl"; // public static final String JDBC_DRIVER = "jdbcDriver"; // public static final String DEPTH = "depth"; // public static final String FIELD = "field"; // public static final String VAR = "var"; // public static final String OP = "op"; // public static final String FORMAT = "format"; // public static final String HEADER = "header"; // public static final String SUFFIX = "suffix"; // public static final String PREFIX = "prefix"; // public static final String PATH_PROVIDER = "pathProvider"; // public static final String BROKER_LIST = "brokerList"; // public static final String GENDER = "gender"; // // } // Path: src/main/java/com/presidentio/testdatagenerator/provider/CountryProvider.java import com.presidentio.testdatagenerator.cons.PropConst; import org.apache.commons.io.IOUtils; import java.io.IOException; import java.io.InputStream; import java.util.HashMap; import java.util.Map; package com.presidentio.testdatagenerator.provider; /** * Created by Vitalii_Gergel on 2/11/2015. */ public class CountryProvider extends SelectProvider { private static String COUNTRIES; public static final String DELIMITER = "\r?\n"; private String getCountries() { if (COUNTRIES == null) { try (InputStream nameStream = DefaultValueProviderFactory.class.getClassLoader().getResourceAsStream("country.dat")) { COUNTRIES = IOUtils.toString(nameStream); } catch (IOException e) { throw new RuntimeException("Failed to load names", e); } } return COUNTRIES; } @Override public void init(Map<String, String> props) { Map<String, String> propsCopy = new HashMap<>(props);
propsCopy.put(PropConst.ITEMS, getCountries());
presidentio/test-data-generator
src/test/java/com/presidentio/testdatagenerator/provider/ExpressionProxyProviderTest.java
// Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java // public class PropConst { // // public static final String TYPE = "type"; // public static final String VALUE = "value"; // public static final String SIZE = "size"; // public static final String DOMAIN = "domain"; // public static final String EXPR = "expr"; // public static final String FILE = "file"; // public static final String DELIMITER = "delimiter"; // public static final String ITEMS = "items"; // public static final String INDEX = "index"; // public static final String HOST = "host"; // public static final String PORT = "port"; // public static final String CLUSTER_NAME = "clusterName"; // public static final String CONNECTION_URL = "connectionUrl"; // public static final String JDBC_DRIVER = "jdbcDriver"; // public static final String DEPTH = "depth"; // public static final String FIELD = "field"; // public static final String VAR = "var"; // public static final String OP = "op"; // public static final String FORMAT = "format"; // public static final String HEADER = "header"; // public static final String SUFFIX = "suffix"; // public static final String PREFIX = "prefix"; // public static final String PATH_PROVIDER = "pathProvider"; // public static final String BROKER_LIST = "brokerList"; // public static final String GENDER = "gender"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/cons/TypeConst.java // public class TypeConst { // // public static final String STRING = "string"; // public static final String LONG = "long"; // public static final String INT = "int"; // public static final String BOOLEAN = "boolean"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java // public class Context { // // private Parent parent; // // private Map<String, Template> templates; // // private Map<String, Object> variables; // // private Sink sink; // // public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) { // this.templates = templates; // this.variables = variables; // this.sink = sink; // } // // public Context(Context parentContext, Map<String, Object> entity) { // parent = new Parent(entity, parentContext.getParent()); // templates = parentContext.getTemplates(); // variables = parentContext.getVariables(); // sink = parentContext.getSink(); // } // // public Parent getParent() { // return parent; // } // // public Map<String, Object> getVariables() { // return variables; // } // // public Sink getSink() { // return sink; // } // // public Map<String, Template> getTemplates() { // return templates; // } // // } // // Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java // public class Field { // // private String name; // // private String type; // // private Provider provider; // // public Field() { // } // // public Field(String name, String type, Provider provider) { // this.name = name; // this.type = type; // this.provider = provider; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // public Provider getProvider() { // return provider; // } // // public void setProvider(Provider provider) { // this.provider = provider; // } // }
import com.presidentio.testdatagenerator.cons.PropConst; import com.presidentio.testdatagenerator.cons.TypeConst; import com.presidentio.testdatagenerator.context.Context; import com.presidentio.testdatagenerator.model.Field; import org.junit.Assert; import org.junit.Test; import java.util.Collections; import java.util.HashMap; import java.util.Map;
/** * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.presidentio.testdatagenerator.provider; public class ExpressionProxyProviderTest { @Test public void testNextValueSimpleMath() throws Exception { Map<String, String> props = new HashMap<>(); String propExpr = "2 + 10";
// Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java // public class PropConst { // // public static final String TYPE = "type"; // public static final String VALUE = "value"; // public static final String SIZE = "size"; // public static final String DOMAIN = "domain"; // public static final String EXPR = "expr"; // public static final String FILE = "file"; // public static final String DELIMITER = "delimiter"; // public static final String ITEMS = "items"; // public static final String INDEX = "index"; // public static final String HOST = "host"; // public static final String PORT = "port"; // public static final String CLUSTER_NAME = "clusterName"; // public static final String CONNECTION_URL = "connectionUrl"; // public static final String JDBC_DRIVER = "jdbcDriver"; // public static final String DEPTH = "depth"; // public static final String FIELD = "field"; // public static final String VAR = "var"; // public static final String OP = "op"; // public static final String FORMAT = "format"; // public static final String HEADER = "header"; // public static final String SUFFIX = "suffix"; // public static final String PREFIX = "prefix"; // public static final String PATH_PROVIDER = "pathProvider"; // public static final String BROKER_LIST = "brokerList"; // public static final String GENDER = "gender"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/cons/TypeConst.java // public class TypeConst { // // public static final String STRING = "string"; // public static final String LONG = "long"; // public static final String INT = "int"; // public static final String BOOLEAN = "boolean"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java // public class Context { // // private Parent parent; // // private Map<String, Template> templates; // // private Map<String, Object> variables; // // private Sink sink; // // public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) { // this.templates = templates; // this.variables = variables; // this.sink = sink; // } // // public Context(Context parentContext, Map<String, Object> entity) { // parent = new Parent(entity, parentContext.getParent()); // templates = parentContext.getTemplates(); // variables = parentContext.getVariables(); // sink = parentContext.getSink(); // } // // public Parent getParent() { // return parent; // } // // public Map<String, Object> getVariables() { // return variables; // } // // public Sink getSink() { // return sink; // } // // public Map<String, Template> getTemplates() { // return templates; // } // // } // // Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java // public class Field { // // private String name; // // private String type; // // private Provider provider; // // public Field() { // } // // public Field(String name, String type, Provider provider) { // this.name = name; // this.type = type; // this.provider = provider; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // public Provider getProvider() { // return provider; // } // // public void setProvider(Provider provider) { // this.provider = provider; // } // } // Path: src/test/java/com/presidentio/testdatagenerator/provider/ExpressionProxyProviderTest.java import com.presidentio.testdatagenerator.cons.PropConst; import com.presidentio.testdatagenerator.cons.TypeConst; import com.presidentio.testdatagenerator.context.Context; import com.presidentio.testdatagenerator.model.Field; import org.junit.Assert; import org.junit.Test; import java.util.Collections; import java.util.HashMap; import java.util.Map; /** * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.presidentio.testdatagenerator.provider; public class ExpressionProxyProviderTest { @Test public void testNextValueSimpleMath() throws Exception { Map<String, String> props = new HashMap<>(); String propExpr = "2 + 10";
props.put(PropConst.EXPR, propExpr);
presidentio/test-data-generator
src/test/java/com/presidentio/testdatagenerator/provider/ExpressionProxyProviderTest.java
// Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java // public class PropConst { // // public static final String TYPE = "type"; // public static final String VALUE = "value"; // public static final String SIZE = "size"; // public static final String DOMAIN = "domain"; // public static final String EXPR = "expr"; // public static final String FILE = "file"; // public static final String DELIMITER = "delimiter"; // public static final String ITEMS = "items"; // public static final String INDEX = "index"; // public static final String HOST = "host"; // public static final String PORT = "port"; // public static final String CLUSTER_NAME = "clusterName"; // public static final String CONNECTION_URL = "connectionUrl"; // public static final String JDBC_DRIVER = "jdbcDriver"; // public static final String DEPTH = "depth"; // public static final String FIELD = "field"; // public static final String VAR = "var"; // public static final String OP = "op"; // public static final String FORMAT = "format"; // public static final String HEADER = "header"; // public static final String SUFFIX = "suffix"; // public static final String PREFIX = "prefix"; // public static final String PATH_PROVIDER = "pathProvider"; // public static final String BROKER_LIST = "brokerList"; // public static final String GENDER = "gender"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/cons/TypeConst.java // public class TypeConst { // // public static final String STRING = "string"; // public static final String LONG = "long"; // public static final String INT = "int"; // public static final String BOOLEAN = "boolean"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java // public class Context { // // private Parent parent; // // private Map<String, Template> templates; // // private Map<String, Object> variables; // // private Sink sink; // // public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) { // this.templates = templates; // this.variables = variables; // this.sink = sink; // } // // public Context(Context parentContext, Map<String, Object> entity) { // parent = new Parent(entity, parentContext.getParent()); // templates = parentContext.getTemplates(); // variables = parentContext.getVariables(); // sink = parentContext.getSink(); // } // // public Parent getParent() { // return parent; // } // // public Map<String, Object> getVariables() { // return variables; // } // // public Sink getSink() { // return sink; // } // // public Map<String, Template> getTemplates() { // return templates; // } // // } // // Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java // public class Field { // // private String name; // // private String type; // // private Provider provider; // // public Field() { // } // // public Field(String name, String type, Provider provider) { // this.name = name; // this.type = type; // this.provider = provider; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // public Provider getProvider() { // return provider; // } // // public void setProvider(Provider provider) { // this.provider = provider; // } // }
import com.presidentio.testdatagenerator.cons.PropConst; import com.presidentio.testdatagenerator.cons.TypeConst; import com.presidentio.testdatagenerator.context.Context; import com.presidentio.testdatagenerator.model.Field; import org.junit.Assert; import org.junit.Test; import java.util.Collections; import java.util.HashMap; import java.util.Map;
/** * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.presidentio.testdatagenerator.provider; public class ExpressionProxyProviderTest { @Test public void testNextValueSimpleMath() throws Exception { Map<String, String> props = new HashMap<>(); String propExpr = "2 + 10"; props.put(PropConst.EXPR, propExpr); ValueProvider provider = new ExpressionProxyProvider(); provider.init(props);
// Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java // public class PropConst { // // public static final String TYPE = "type"; // public static final String VALUE = "value"; // public static final String SIZE = "size"; // public static final String DOMAIN = "domain"; // public static final String EXPR = "expr"; // public static final String FILE = "file"; // public static final String DELIMITER = "delimiter"; // public static final String ITEMS = "items"; // public static final String INDEX = "index"; // public static final String HOST = "host"; // public static final String PORT = "port"; // public static final String CLUSTER_NAME = "clusterName"; // public static final String CONNECTION_URL = "connectionUrl"; // public static final String JDBC_DRIVER = "jdbcDriver"; // public static final String DEPTH = "depth"; // public static final String FIELD = "field"; // public static final String VAR = "var"; // public static final String OP = "op"; // public static final String FORMAT = "format"; // public static final String HEADER = "header"; // public static final String SUFFIX = "suffix"; // public static final String PREFIX = "prefix"; // public static final String PATH_PROVIDER = "pathProvider"; // public static final String BROKER_LIST = "brokerList"; // public static final String GENDER = "gender"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/cons/TypeConst.java // public class TypeConst { // // public static final String STRING = "string"; // public static final String LONG = "long"; // public static final String INT = "int"; // public static final String BOOLEAN = "boolean"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java // public class Context { // // private Parent parent; // // private Map<String, Template> templates; // // private Map<String, Object> variables; // // private Sink sink; // // public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) { // this.templates = templates; // this.variables = variables; // this.sink = sink; // } // // public Context(Context parentContext, Map<String, Object> entity) { // parent = new Parent(entity, parentContext.getParent()); // templates = parentContext.getTemplates(); // variables = parentContext.getVariables(); // sink = parentContext.getSink(); // } // // public Parent getParent() { // return parent; // } // // public Map<String, Object> getVariables() { // return variables; // } // // public Sink getSink() { // return sink; // } // // public Map<String, Template> getTemplates() { // return templates; // } // // } // // Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java // public class Field { // // private String name; // // private String type; // // private Provider provider; // // public Field() { // } // // public Field(String name, String type, Provider provider) { // this.name = name; // this.type = type; // this.provider = provider; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // public Provider getProvider() { // return provider; // } // // public void setProvider(Provider provider) { // this.provider = provider; // } // } // Path: src/test/java/com/presidentio/testdatagenerator/provider/ExpressionProxyProviderTest.java import com.presidentio.testdatagenerator.cons.PropConst; import com.presidentio.testdatagenerator.cons.TypeConst; import com.presidentio.testdatagenerator.context.Context; import com.presidentio.testdatagenerator.model.Field; import org.junit.Assert; import org.junit.Test; import java.util.Collections; import java.util.HashMap; import java.util.Map; /** * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.presidentio.testdatagenerator.provider; public class ExpressionProxyProviderTest { @Test public void testNextValueSimpleMath() throws Exception { Map<String, String> props = new HashMap<>(); String propExpr = "2 + 10"; props.put(PropConst.EXPR, propExpr); ValueProvider provider = new ExpressionProxyProvider(); provider.init(props);
Context context = new Context(null, new HashMap<String, Object>(), null);
presidentio/test-data-generator
src/test/java/com/presidentio/testdatagenerator/provider/ExpressionProxyProviderTest.java
// Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java // public class PropConst { // // public static final String TYPE = "type"; // public static final String VALUE = "value"; // public static final String SIZE = "size"; // public static final String DOMAIN = "domain"; // public static final String EXPR = "expr"; // public static final String FILE = "file"; // public static final String DELIMITER = "delimiter"; // public static final String ITEMS = "items"; // public static final String INDEX = "index"; // public static final String HOST = "host"; // public static final String PORT = "port"; // public static final String CLUSTER_NAME = "clusterName"; // public static final String CONNECTION_URL = "connectionUrl"; // public static final String JDBC_DRIVER = "jdbcDriver"; // public static final String DEPTH = "depth"; // public static final String FIELD = "field"; // public static final String VAR = "var"; // public static final String OP = "op"; // public static final String FORMAT = "format"; // public static final String HEADER = "header"; // public static final String SUFFIX = "suffix"; // public static final String PREFIX = "prefix"; // public static final String PATH_PROVIDER = "pathProvider"; // public static final String BROKER_LIST = "brokerList"; // public static final String GENDER = "gender"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/cons/TypeConst.java // public class TypeConst { // // public static final String STRING = "string"; // public static final String LONG = "long"; // public static final String INT = "int"; // public static final String BOOLEAN = "boolean"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java // public class Context { // // private Parent parent; // // private Map<String, Template> templates; // // private Map<String, Object> variables; // // private Sink sink; // // public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) { // this.templates = templates; // this.variables = variables; // this.sink = sink; // } // // public Context(Context parentContext, Map<String, Object> entity) { // parent = new Parent(entity, parentContext.getParent()); // templates = parentContext.getTemplates(); // variables = parentContext.getVariables(); // sink = parentContext.getSink(); // } // // public Parent getParent() { // return parent; // } // // public Map<String, Object> getVariables() { // return variables; // } // // public Sink getSink() { // return sink; // } // // public Map<String, Template> getTemplates() { // return templates; // } // // } // // Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java // public class Field { // // private String name; // // private String type; // // private Provider provider; // // public Field() { // } // // public Field(String name, String type, Provider provider) { // this.name = name; // this.type = type; // this.provider = provider; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // public Provider getProvider() { // return provider; // } // // public void setProvider(Provider provider) { // this.provider = provider; // } // }
import com.presidentio.testdatagenerator.cons.PropConst; import com.presidentio.testdatagenerator.cons.TypeConst; import com.presidentio.testdatagenerator.context.Context; import com.presidentio.testdatagenerator.model.Field; import org.junit.Assert; import org.junit.Test; import java.util.Collections; import java.util.HashMap; import java.util.Map;
/** * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.presidentio.testdatagenerator.provider; public class ExpressionProxyProviderTest { @Test public void testNextValueSimpleMath() throws Exception { Map<String, String> props = new HashMap<>(); String propExpr = "2 + 10"; props.put(PropConst.EXPR, propExpr); ValueProvider provider = new ExpressionProxyProvider(); provider.init(props); Context context = new Context(null, new HashMap<String, Object>(), null);
// Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java // public class PropConst { // // public static final String TYPE = "type"; // public static final String VALUE = "value"; // public static final String SIZE = "size"; // public static final String DOMAIN = "domain"; // public static final String EXPR = "expr"; // public static final String FILE = "file"; // public static final String DELIMITER = "delimiter"; // public static final String ITEMS = "items"; // public static final String INDEX = "index"; // public static final String HOST = "host"; // public static final String PORT = "port"; // public static final String CLUSTER_NAME = "clusterName"; // public static final String CONNECTION_URL = "connectionUrl"; // public static final String JDBC_DRIVER = "jdbcDriver"; // public static final String DEPTH = "depth"; // public static final String FIELD = "field"; // public static final String VAR = "var"; // public static final String OP = "op"; // public static final String FORMAT = "format"; // public static final String HEADER = "header"; // public static final String SUFFIX = "suffix"; // public static final String PREFIX = "prefix"; // public static final String PATH_PROVIDER = "pathProvider"; // public static final String BROKER_LIST = "brokerList"; // public static final String GENDER = "gender"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/cons/TypeConst.java // public class TypeConst { // // public static final String STRING = "string"; // public static final String LONG = "long"; // public static final String INT = "int"; // public static final String BOOLEAN = "boolean"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java // public class Context { // // private Parent parent; // // private Map<String, Template> templates; // // private Map<String, Object> variables; // // private Sink sink; // // public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) { // this.templates = templates; // this.variables = variables; // this.sink = sink; // } // // public Context(Context parentContext, Map<String, Object> entity) { // parent = new Parent(entity, parentContext.getParent()); // templates = parentContext.getTemplates(); // variables = parentContext.getVariables(); // sink = parentContext.getSink(); // } // // public Parent getParent() { // return parent; // } // // public Map<String, Object> getVariables() { // return variables; // } // // public Sink getSink() { // return sink; // } // // public Map<String, Template> getTemplates() { // return templates; // } // // } // // Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java // public class Field { // // private String name; // // private String type; // // private Provider provider; // // public Field() { // } // // public Field(String name, String type, Provider provider) { // this.name = name; // this.type = type; // this.provider = provider; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // public Provider getProvider() { // return provider; // } // // public void setProvider(Provider provider) { // this.provider = provider; // } // } // Path: src/test/java/com/presidentio/testdatagenerator/provider/ExpressionProxyProviderTest.java import com.presidentio.testdatagenerator.cons.PropConst; import com.presidentio.testdatagenerator.cons.TypeConst; import com.presidentio.testdatagenerator.context.Context; import com.presidentio.testdatagenerator.model.Field; import org.junit.Assert; import org.junit.Test; import java.util.Collections; import java.util.HashMap; import java.util.Map; /** * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.presidentio.testdatagenerator.provider; public class ExpressionProxyProviderTest { @Test public void testNextValueSimpleMath() throws Exception { Map<String, String> props = new HashMap<>(); String propExpr = "2 + 10"; props.put(PropConst.EXPR, propExpr); ValueProvider provider = new ExpressionProxyProvider(); provider.init(props); Context context = new Context(null, new HashMap<String, Object>(), null);
Object result = provider.nextValue(context, new Field(null, TypeConst.INT, null));
presidentio/test-data-generator
src/test/java/com/presidentio/testdatagenerator/provider/ExpressionProxyProviderTest.java
// Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java // public class PropConst { // // public static final String TYPE = "type"; // public static final String VALUE = "value"; // public static final String SIZE = "size"; // public static final String DOMAIN = "domain"; // public static final String EXPR = "expr"; // public static final String FILE = "file"; // public static final String DELIMITER = "delimiter"; // public static final String ITEMS = "items"; // public static final String INDEX = "index"; // public static final String HOST = "host"; // public static final String PORT = "port"; // public static final String CLUSTER_NAME = "clusterName"; // public static final String CONNECTION_URL = "connectionUrl"; // public static final String JDBC_DRIVER = "jdbcDriver"; // public static final String DEPTH = "depth"; // public static final String FIELD = "field"; // public static final String VAR = "var"; // public static final String OP = "op"; // public static final String FORMAT = "format"; // public static final String HEADER = "header"; // public static final String SUFFIX = "suffix"; // public static final String PREFIX = "prefix"; // public static final String PATH_PROVIDER = "pathProvider"; // public static final String BROKER_LIST = "brokerList"; // public static final String GENDER = "gender"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/cons/TypeConst.java // public class TypeConst { // // public static final String STRING = "string"; // public static final String LONG = "long"; // public static final String INT = "int"; // public static final String BOOLEAN = "boolean"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java // public class Context { // // private Parent parent; // // private Map<String, Template> templates; // // private Map<String, Object> variables; // // private Sink sink; // // public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) { // this.templates = templates; // this.variables = variables; // this.sink = sink; // } // // public Context(Context parentContext, Map<String, Object> entity) { // parent = new Parent(entity, parentContext.getParent()); // templates = parentContext.getTemplates(); // variables = parentContext.getVariables(); // sink = parentContext.getSink(); // } // // public Parent getParent() { // return parent; // } // // public Map<String, Object> getVariables() { // return variables; // } // // public Sink getSink() { // return sink; // } // // public Map<String, Template> getTemplates() { // return templates; // } // // } // // Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java // public class Field { // // private String name; // // private String type; // // private Provider provider; // // public Field() { // } // // public Field(String name, String type, Provider provider) { // this.name = name; // this.type = type; // this.provider = provider; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // public Provider getProvider() { // return provider; // } // // public void setProvider(Provider provider) { // this.provider = provider; // } // }
import com.presidentio.testdatagenerator.cons.PropConst; import com.presidentio.testdatagenerator.cons.TypeConst; import com.presidentio.testdatagenerator.context.Context; import com.presidentio.testdatagenerator.model.Field; import org.junit.Assert; import org.junit.Test; import java.util.Collections; import java.util.HashMap; import java.util.Map;
/** * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.presidentio.testdatagenerator.provider; public class ExpressionProxyProviderTest { @Test public void testNextValueSimpleMath() throws Exception { Map<String, String> props = new HashMap<>(); String propExpr = "2 + 10"; props.put(PropConst.EXPR, propExpr); ValueProvider provider = new ExpressionProxyProvider(); provider.init(props); Context context = new Context(null, new HashMap<String, Object>(), null);
// Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java // public class PropConst { // // public static final String TYPE = "type"; // public static final String VALUE = "value"; // public static final String SIZE = "size"; // public static final String DOMAIN = "domain"; // public static final String EXPR = "expr"; // public static final String FILE = "file"; // public static final String DELIMITER = "delimiter"; // public static final String ITEMS = "items"; // public static final String INDEX = "index"; // public static final String HOST = "host"; // public static final String PORT = "port"; // public static final String CLUSTER_NAME = "clusterName"; // public static final String CONNECTION_URL = "connectionUrl"; // public static final String JDBC_DRIVER = "jdbcDriver"; // public static final String DEPTH = "depth"; // public static final String FIELD = "field"; // public static final String VAR = "var"; // public static final String OP = "op"; // public static final String FORMAT = "format"; // public static final String HEADER = "header"; // public static final String SUFFIX = "suffix"; // public static final String PREFIX = "prefix"; // public static final String PATH_PROVIDER = "pathProvider"; // public static final String BROKER_LIST = "brokerList"; // public static final String GENDER = "gender"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/cons/TypeConst.java // public class TypeConst { // // public static final String STRING = "string"; // public static final String LONG = "long"; // public static final String INT = "int"; // public static final String BOOLEAN = "boolean"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java // public class Context { // // private Parent parent; // // private Map<String, Template> templates; // // private Map<String, Object> variables; // // private Sink sink; // // public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) { // this.templates = templates; // this.variables = variables; // this.sink = sink; // } // // public Context(Context parentContext, Map<String, Object> entity) { // parent = new Parent(entity, parentContext.getParent()); // templates = parentContext.getTemplates(); // variables = parentContext.getVariables(); // sink = parentContext.getSink(); // } // // public Parent getParent() { // return parent; // } // // public Map<String, Object> getVariables() { // return variables; // } // // public Sink getSink() { // return sink; // } // // public Map<String, Template> getTemplates() { // return templates; // } // // } // // Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java // public class Field { // // private String name; // // private String type; // // private Provider provider; // // public Field() { // } // // public Field(String name, String type, Provider provider) { // this.name = name; // this.type = type; // this.provider = provider; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // public Provider getProvider() { // return provider; // } // // public void setProvider(Provider provider) { // this.provider = provider; // } // } // Path: src/test/java/com/presidentio/testdatagenerator/provider/ExpressionProxyProviderTest.java import com.presidentio.testdatagenerator.cons.PropConst; import com.presidentio.testdatagenerator.cons.TypeConst; import com.presidentio.testdatagenerator.context.Context; import com.presidentio.testdatagenerator.model.Field; import org.junit.Assert; import org.junit.Test; import java.util.Collections; import java.util.HashMap; import java.util.Map; /** * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.presidentio.testdatagenerator.provider; public class ExpressionProxyProviderTest { @Test public void testNextValueSimpleMath() throws Exception { Map<String, String> props = new HashMap<>(); String propExpr = "2 + 10"; props.put(PropConst.EXPR, propExpr); ValueProvider provider = new ExpressionProxyProvider(); provider.init(props); Context context = new Context(null, new HashMap<String, Object>(), null);
Object result = provider.nextValue(context, new Field(null, TypeConst.INT, null));
presidentio/test-data-generator
src/main/java/com/presidentio/testdatagenerator/output/formatter/EsFormatter.java
// Path: src/main/java/com/presidentio/testdatagenerator/cons/DelimiterConst.java // public class DelimiterConst { // // public static final String COMMA = ","; // public static final String TAB = "\t"; // public static final String NEW_LINE = "\n"; // public static final String SPACE = " "; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java // public class PropConst { // // public static final String TYPE = "type"; // public static final String VALUE = "value"; // public static final String SIZE = "size"; // public static final String DOMAIN = "domain"; // public static final String EXPR = "expr"; // public static final String FILE = "file"; // public static final String DELIMITER = "delimiter"; // public static final String ITEMS = "items"; // public static final String INDEX = "index"; // public static final String HOST = "host"; // public static final String PORT = "port"; // public static final String CLUSTER_NAME = "clusterName"; // public static final String CONNECTION_URL = "connectionUrl"; // public static final String JDBC_DRIVER = "jdbcDriver"; // public static final String DEPTH = "depth"; // public static final String FIELD = "field"; // public static final String VAR = "var"; // public static final String OP = "op"; // public static final String FORMAT = "format"; // public static final String HEADER = "header"; // public static final String SUFFIX = "suffix"; // public static final String PREFIX = "prefix"; // public static final String PATH_PROVIDER = "pathProvider"; // public static final String BROKER_LIST = "brokerList"; // public static final String GENDER = "gender"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/model/Template.java // public class Template { // // private String id; // // private String extend; // // @JsonIgnore // private Template extendTemplate; // // private Integer count; // // private String name; // // private List<Field> fields; // // private List<String> childs = new ArrayList<>(); // // public String getId() { // return id; // } // // public void setId(String id) { // this.id = id; // } // // public String getExtend() { // return extend; // } // // public void setExtend(String extend) { // this.extend = extend; // } // // public Template getExtendTemplate() { // return extendTemplate; // } // // public void setExtendTemplate(Template extendTemplate) { // this.extendTemplate = extendTemplate; // } // // public Integer getCount() { // if (count == null && extendTemplate != null) { // return extendTemplate.getCount(); // } // return count; // } // // public void setCount(Integer count) { // this.count = count; // } // // public String getName() { // if (name == null && extendTemplate != null) { // return extendTemplate.getName(); // } // return name; // } // // public void setName(String name) { // this.name = name; // } // // public List<Field> getFields() { // List<Field> result = new ArrayList<>(); // if (extendTemplate != null && extendTemplate.getFields() != null) { // result.addAll(extendTemplate.getFields()); // } // if (fields != null) { // result.addAll(fields); // } // return result; // } // // public void setFields(List<Field> fields) { // this.fields = fields; // } // // public List<String> getChilds() { // List<String> result = new ArrayList<>(); // if (extendTemplate != null && extendTemplate.getChilds() != null) { // result.addAll(extendTemplate.getChilds()); // } // if (childs != null) { // result.addAll(childs); // } // return result; // } // // public void setChilds(List<String> childs) { // this.childs = childs; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // Template template = (Template) o; // // if (name != null ? !name.equals(template.name) : template.name != null) return false; // // return true; // } // // @Override // public int hashCode() { // return name != null ? name.hashCode() : 0; // } // }
import com.presidentio.testdatagenerator.cons.DelimiterConst; import com.presidentio.testdatagenerator.cons.PropConst; import com.presidentio.testdatagenerator.model.Template; import org.codehaus.jackson.map.ObjectMapper; import java.io.IOException; import java.util.List; import java.util.Map;
package com.presidentio.testdatagenerator.output.formatter; /** * Created by Vitalii_Gergel on 2/19/2015. */ public class EsFormatter implements Formatter { private static final String INDEX = "{ \"index\" : { \"_index\" : \"%s\", \"_type\" : \"%s\"} }"; private ObjectMapper objectMapper = new ObjectMapper(); private String index; @Override public void init(Map<String, String> props) {
// Path: src/main/java/com/presidentio/testdatagenerator/cons/DelimiterConst.java // public class DelimiterConst { // // public static final String COMMA = ","; // public static final String TAB = "\t"; // public static final String NEW_LINE = "\n"; // public static final String SPACE = " "; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java // public class PropConst { // // public static final String TYPE = "type"; // public static final String VALUE = "value"; // public static final String SIZE = "size"; // public static final String DOMAIN = "domain"; // public static final String EXPR = "expr"; // public static final String FILE = "file"; // public static final String DELIMITER = "delimiter"; // public static final String ITEMS = "items"; // public static final String INDEX = "index"; // public static final String HOST = "host"; // public static final String PORT = "port"; // public static final String CLUSTER_NAME = "clusterName"; // public static final String CONNECTION_URL = "connectionUrl"; // public static final String JDBC_DRIVER = "jdbcDriver"; // public static final String DEPTH = "depth"; // public static final String FIELD = "field"; // public static final String VAR = "var"; // public static final String OP = "op"; // public static final String FORMAT = "format"; // public static final String HEADER = "header"; // public static final String SUFFIX = "suffix"; // public static final String PREFIX = "prefix"; // public static final String PATH_PROVIDER = "pathProvider"; // public static final String BROKER_LIST = "brokerList"; // public static final String GENDER = "gender"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/model/Template.java // public class Template { // // private String id; // // private String extend; // // @JsonIgnore // private Template extendTemplate; // // private Integer count; // // private String name; // // private List<Field> fields; // // private List<String> childs = new ArrayList<>(); // // public String getId() { // return id; // } // // public void setId(String id) { // this.id = id; // } // // public String getExtend() { // return extend; // } // // public void setExtend(String extend) { // this.extend = extend; // } // // public Template getExtendTemplate() { // return extendTemplate; // } // // public void setExtendTemplate(Template extendTemplate) { // this.extendTemplate = extendTemplate; // } // // public Integer getCount() { // if (count == null && extendTemplate != null) { // return extendTemplate.getCount(); // } // return count; // } // // public void setCount(Integer count) { // this.count = count; // } // // public String getName() { // if (name == null && extendTemplate != null) { // return extendTemplate.getName(); // } // return name; // } // // public void setName(String name) { // this.name = name; // } // // public List<Field> getFields() { // List<Field> result = new ArrayList<>(); // if (extendTemplate != null && extendTemplate.getFields() != null) { // result.addAll(extendTemplate.getFields()); // } // if (fields != null) { // result.addAll(fields); // } // return result; // } // // public void setFields(List<Field> fields) { // this.fields = fields; // } // // public List<String> getChilds() { // List<String> result = new ArrayList<>(); // if (extendTemplate != null && extendTemplate.getChilds() != null) { // result.addAll(extendTemplate.getChilds()); // } // if (childs != null) { // result.addAll(childs); // } // return result; // } // // public void setChilds(List<String> childs) { // this.childs = childs; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // Template template = (Template) o; // // if (name != null ? !name.equals(template.name) : template.name != null) return false; // // return true; // } // // @Override // public int hashCode() { // return name != null ? name.hashCode() : 0; // } // } // Path: src/main/java/com/presidentio/testdatagenerator/output/formatter/EsFormatter.java import com.presidentio.testdatagenerator.cons.DelimiterConst; import com.presidentio.testdatagenerator.cons.PropConst; import com.presidentio.testdatagenerator.model.Template; import org.codehaus.jackson.map.ObjectMapper; import java.io.IOException; import java.util.List; import java.util.Map; package com.presidentio.testdatagenerator.output.formatter; /** * Created by Vitalii_Gergel on 2/19/2015. */ public class EsFormatter implements Formatter { private static final String INDEX = "{ \"index\" : { \"_index\" : \"%s\", \"_type\" : \"%s\"} }"; private ObjectMapper objectMapper = new ObjectMapper(); private String index; @Override public void init(Map<String, String> props) {
index = props.get(PropConst.INDEX);
presidentio/test-data-generator
src/main/java/com/presidentio/testdatagenerator/output/formatter/EsFormatter.java
// Path: src/main/java/com/presidentio/testdatagenerator/cons/DelimiterConst.java // public class DelimiterConst { // // public static final String COMMA = ","; // public static final String TAB = "\t"; // public static final String NEW_LINE = "\n"; // public static final String SPACE = " "; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java // public class PropConst { // // public static final String TYPE = "type"; // public static final String VALUE = "value"; // public static final String SIZE = "size"; // public static final String DOMAIN = "domain"; // public static final String EXPR = "expr"; // public static final String FILE = "file"; // public static final String DELIMITER = "delimiter"; // public static final String ITEMS = "items"; // public static final String INDEX = "index"; // public static final String HOST = "host"; // public static final String PORT = "port"; // public static final String CLUSTER_NAME = "clusterName"; // public static final String CONNECTION_URL = "connectionUrl"; // public static final String JDBC_DRIVER = "jdbcDriver"; // public static final String DEPTH = "depth"; // public static final String FIELD = "field"; // public static final String VAR = "var"; // public static final String OP = "op"; // public static final String FORMAT = "format"; // public static final String HEADER = "header"; // public static final String SUFFIX = "suffix"; // public static final String PREFIX = "prefix"; // public static final String PATH_PROVIDER = "pathProvider"; // public static final String BROKER_LIST = "brokerList"; // public static final String GENDER = "gender"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/model/Template.java // public class Template { // // private String id; // // private String extend; // // @JsonIgnore // private Template extendTemplate; // // private Integer count; // // private String name; // // private List<Field> fields; // // private List<String> childs = new ArrayList<>(); // // public String getId() { // return id; // } // // public void setId(String id) { // this.id = id; // } // // public String getExtend() { // return extend; // } // // public void setExtend(String extend) { // this.extend = extend; // } // // public Template getExtendTemplate() { // return extendTemplate; // } // // public void setExtendTemplate(Template extendTemplate) { // this.extendTemplate = extendTemplate; // } // // public Integer getCount() { // if (count == null && extendTemplate != null) { // return extendTemplate.getCount(); // } // return count; // } // // public void setCount(Integer count) { // this.count = count; // } // // public String getName() { // if (name == null && extendTemplate != null) { // return extendTemplate.getName(); // } // return name; // } // // public void setName(String name) { // this.name = name; // } // // public List<Field> getFields() { // List<Field> result = new ArrayList<>(); // if (extendTemplate != null && extendTemplate.getFields() != null) { // result.addAll(extendTemplate.getFields()); // } // if (fields != null) { // result.addAll(fields); // } // return result; // } // // public void setFields(List<Field> fields) { // this.fields = fields; // } // // public List<String> getChilds() { // List<String> result = new ArrayList<>(); // if (extendTemplate != null && extendTemplate.getChilds() != null) { // result.addAll(extendTemplate.getChilds()); // } // if (childs != null) { // result.addAll(childs); // } // return result; // } // // public void setChilds(List<String> childs) { // this.childs = childs; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // Template template = (Template) o; // // if (name != null ? !name.equals(template.name) : template.name != null) return false; // // return true; // } // // @Override // public int hashCode() { // return name != null ? name.hashCode() : 0; // } // }
import com.presidentio.testdatagenerator.cons.DelimiterConst; import com.presidentio.testdatagenerator.cons.PropConst; import com.presidentio.testdatagenerator.model.Template; import org.codehaus.jackson.map.ObjectMapper; import java.io.IOException; import java.util.List; import java.util.Map;
package com.presidentio.testdatagenerator.output.formatter; /** * Created by Vitalii_Gergel on 2/19/2015. */ public class EsFormatter implements Formatter { private static final String INDEX = "{ \"index\" : { \"_index\" : \"%s\", \"_type\" : \"%s\"} }"; private ObjectMapper objectMapper = new ObjectMapper(); private String index; @Override public void init(Map<String, String> props) { index = props.get(PropConst.INDEX); if (index == null) { throw new IllegalArgumentException(PropConst.INDEX + " does not specified or null"); } } @Override
// Path: src/main/java/com/presidentio/testdatagenerator/cons/DelimiterConst.java // public class DelimiterConst { // // public static final String COMMA = ","; // public static final String TAB = "\t"; // public static final String NEW_LINE = "\n"; // public static final String SPACE = " "; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java // public class PropConst { // // public static final String TYPE = "type"; // public static final String VALUE = "value"; // public static final String SIZE = "size"; // public static final String DOMAIN = "domain"; // public static final String EXPR = "expr"; // public static final String FILE = "file"; // public static final String DELIMITER = "delimiter"; // public static final String ITEMS = "items"; // public static final String INDEX = "index"; // public static final String HOST = "host"; // public static final String PORT = "port"; // public static final String CLUSTER_NAME = "clusterName"; // public static final String CONNECTION_URL = "connectionUrl"; // public static final String JDBC_DRIVER = "jdbcDriver"; // public static final String DEPTH = "depth"; // public static final String FIELD = "field"; // public static final String VAR = "var"; // public static final String OP = "op"; // public static final String FORMAT = "format"; // public static final String HEADER = "header"; // public static final String SUFFIX = "suffix"; // public static final String PREFIX = "prefix"; // public static final String PATH_PROVIDER = "pathProvider"; // public static final String BROKER_LIST = "brokerList"; // public static final String GENDER = "gender"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/model/Template.java // public class Template { // // private String id; // // private String extend; // // @JsonIgnore // private Template extendTemplate; // // private Integer count; // // private String name; // // private List<Field> fields; // // private List<String> childs = new ArrayList<>(); // // public String getId() { // return id; // } // // public void setId(String id) { // this.id = id; // } // // public String getExtend() { // return extend; // } // // public void setExtend(String extend) { // this.extend = extend; // } // // public Template getExtendTemplate() { // return extendTemplate; // } // // public void setExtendTemplate(Template extendTemplate) { // this.extendTemplate = extendTemplate; // } // // public Integer getCount() { // if (count == null && extendTemplate != null) { // return extendTemplate.getCount(); // } // return count; // } // // public void setCount(Integer count) { // this.count = count; // } // // public String getName() { // if (name == null && extendTemplate != null) { // return extendTemplate.getName(); // } // return name; // } // // public void setName(String name) { // this.name = name; // } // // public List<Field> getFields() { // List<Field> result = new ArrayList<>(); // if (extendTemplate != null && extendTemplate.getFields() != null) { // result.addAll(extendTemplate.getFields()); // } // if (fields != null) { // result.addAll(fields); // } // return result; // } // // public void setFields(List<Field> fields) { // this.fields = fields; // } // // public List<String> getChilds() { // List<String> result = new ArrayList<>(); // if (extendTemplate != null && extendTemplate.getChilds() != null) { // result.addAll(extendTemplate.getChilds()); // } // if (childs != null) { // result.addAll(childs); // } // return result; // } // // public void setChilds(List<String> childs) { // this.childs = childs; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // Template template = (Template) o; // // if (name != null ? !name.equals(template.name) : template.name != null) return false; // // return true; // } // // @Override // public int hashCode() { // return name != null ? name.hashCode() : 0; // } // } // Path: src/main/java/com/presidentio/testdatagenerator/output/formatter/EsFormatter.java import com.presidentio.testdatagenerator.cons.DelimiterConst; import com.presidentio.testdatagenerator.cons.PropConst; import com.presidentio.testdatagenerator.model.Template; import org.codehaus.jackson.map.ObjectMapper; import java.io.IOException; import java.util.List; import java.util.Map; package com.presidentio.testdatagenerator.output.formatter; /** * Created by Vitalii_Gergel on 2/19/2015. */ public class EsFormatter implements Formatter { private static final String INDEX = "{ \"index\" : { \"_index\" : \"%s\", \"_type\" : \"%s\"} }"; private ObjectMapper objectMapper = new ObjectMapper(); private String index; @Override public void init(Map<String, String> props) { index = props.get(PropConst.INDEX); if (index == null) { throw new IllegalArgumentException(PropConst.INDEX + " does not specified or null"); } } @Override
public String format(Map<String, Object> map, Template template) {
presidentio/test-data-generator
src/main/java/com/presidentio/testdatagenerator/output/formatter/EsFormatter.java
// Path: src/main/java/com/presidentio/testdatagenerator/cons/DelimiterConst.java // public class DelimiterConst { // // public static final String COMMA = ","; // public static final String TAB = "\t"; // public static final String NEW_LINE = "\n"; // public static final String SPACE = " "; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java // public class PropConst { // // public static final String TYPE = "type"; // public static final String VALUE = "value"; // public static final String SIZE = "size"; // public static final String DOMAIN = "domain"; // public static final String EXPR = "expr"; // public static final String FILE = "file"; // public static final String DELIMITER = "delimiter"; // public static final String ITEMS = "items"; // public static final String INDEX = "index"; // public static final String HOST = "host"; // public static final String PORT = "port"; // public static final String CLUSTER_NAME = "clusterName"; // public static final String CONNECTION_URL = "connectionUrl"; // public static final String JDBC_DRIVER = "jdbcDriver"; // public static final String DEPTH = "depth"; // public static final String FIELD = "field"; // public static final String VAR = "var"; // public static final String OP = "op"; // public static final String FORMAT = "format"; // public static final String HEADER = "header"; // public static final String SUFFIX = "suffix"; // public static final String PREFIX = "prefix"; // public static final String PATH_PROVIDER = "pathProvider"; // public static final String BROKER_LIST = "brokerList"; // public static final String GENDER = "gender"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/model/Template.java // public class Template { // // private String id; // // private String extend; // // @JsonIgnore // private Template extendTemplate; // // private Integer count; // // private String name; // // private List<Field> fields; // // private List<String> childs = new ArrayList<>(); // // public String getId() { // return id; // } // // public void setId(String id) { // this.id = id; // } // // public String getExtend() { // return extend; // } // // public void setExtend(String extend) { // this.extend = extend; // } // // public Template getExtendTemplate() { // return extendTemplate; // } // // public void setExtendTemplate(Template extendTemplate) { // this.extendTemplate = extendTemplate; // } // // public Integer getCount() { // if (count == null && extendTemplate != null) { // return extendTemplate.getCount(); // } // return count; // } // // public void setCount(Integer count) { // this.count = count; // } // // public String getName() { // if (name == null && extendTemplate != null) { // return extendTemplate.getName(); // } // return name; // } // // public void setName(String name) { // this.name = name; // } // // public List<Field> getFields() { // List<Field> result = new ArrayList<>(); // if (extendTemplate != null && extendTemplate.getFields() != null) { // result.addAll(extendTemplate.getFields()); // } // if (fields != null) { // result.addAll(fields); // } // return result; // } // // public void setFields(List<Field> fields) { // this.fields = fields; // } // // public List<String> getChilds() { // List<String> result = new ArrayList<>(); // if (extendTemplate != null && extendTemplate.getChilds() != null) { // result.addAll(extendTemplate.getChilds()); // } // if (childs != null) { // result.addAll(childs); // } // return result; // } // // public void setChilds(List<String> childs) { // this.childs = childs; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // Template template = (Template) o; // // if (name != null ? !name.equals(template.name) : template.name != null) return false; // // return true; // } // // @Override // public int hashCode() { // return name != null ? name.hashCode() : 0; // } // }
import com.presidentio.testdatagenerator.cons.DelimiterConst; import com.presidentio.testdatagenerator.cons.PropConst; import com.presidentio.testdatagenerator.model.Template; import org.codehaus.jackson.map.ObjectMapper; import java.io.IOException; import java.util.List; import java.util.Map;
package com.presidentio.testdatagenerator.output.formatter; /** * Created by Vitalii_Gergel on 2/19/2015. */ public class EsFormatter implements Formatter { private static final String INDEX = "{ \"index\" : { \"_index\" : \"%s\", \"_type\" : \"%s\"} }"; private ObjectMapper objectMapper = new ObjectMapper(); private String index; @Override public void init(Map<String, String> props) { index = props.get(PropConst.INDEX); if (index == null) { throw new IllegalArgumentException(PropConst.INDEX + " does not specified or null"); } } @Override public String format(Map<String, Object> map, Template template) { String result = String.format(INDEX, index, template.getName());
// Path: src/main/java/com/presidentio/testdatagenerator/cons/DelimiterConst.java // public class DelimiterConst { // // public static final String COMMA = ","; // public static final String TAB = "\t"; // public static final String NEW_LINE = "\n"; // public static final String SPACE = " "; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java // public class PropConst { // // public static final String TYPE = "type"; // public static final String VALUE = "value"; // public static final String SIZE = "size"; // public static final String DOMAIN = "domain"; // public static final String EXPR = "expr"; // public static final String FILE = "file"; // public static final String DELIMITER = "delimiter"; // public static final String ITEMS = "items"; // public static final String INDEX = "index"; // public static final String HOST = "host"; // public static final String PORT = "port"; // public static final String CLUSTER_NAME = "clusterName"; // public static final String CONNECTION_URL = "connectionUrl"; // public static final String JDBC_DRIVER = "jdbcDriver"; // public static final String DEPTH = "depth"; // public static final String FIELD = "field"; // public static final String VAR = "var"; // public static final String OP = "op"; // public static final String FORMAT = "format"; // public static final String HEADER = "header"; // public static final String SUFFIX = "suffix"; // public static final String PREFIX = "prefix"; // public static final String PATH_PROVIDER = "pathProvider"; // public static final String BROKER_LIST = "brokerList"; // public static final String GENDER = "gender"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/model/Template.java // public class Template { // // private String id; // // private String extend; // // @JsonIgnore // private Template extendTemplate; // // private Integer count; // // private String name; // // private List<Field> fields; // // private List<String> childs = new ArrayList<>(); // // public String getId() { // return id; // } // // public void setId(String id) { // this.id = id; // } // // public String getExtend() { // return extend; // } // // public void setExtend(String extend) { // this.extend = extend; // } // // public Template getExtendTemplate() { // return extendTemplate; // } // // public void setExtendTemplate(Template extendTemplate) { // this.extendTemplate = extendTemplate; // } // // public Integer getCount() { // if (count == null && extendTemplate != null) { // return extendTemplate.getCount(); // } // return count; // } // // public void setCount(Integer count) { // this.count = count; // } // // public String getName() { // if (name == null && extendTemplate != null) { // return extendTemplate.getName(); // } // return name; // } // // public void setName(String name) { // this.name = name; // } // // public List<Field> getFields() { // List<Field> result = new ArrayList<>(); // if (extendTemplate != null && extendTemplate.getFields() != null) { // result.addAll(extendTemplate.getFields()); // } // if (fields != null) { // result.addAll(fields); // } // return result; // } // // public void setFields(List<Field> fields) { // this.fields = fields; // } // // public List<String> getChilds() { // List<String> result = new ArrayList<>(); // if (extendTemplate != null && extendTemplate.getChilds() != null) { // result.addAll(extendTemplate.getChilds()); // } // if (childs != null) { // result.addAll(childs); // } // return result; // } // // public void setChilds(List<String> childs) { // this.childs = childs; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // Template template = (Template) o; // // if (name != null ? !name.equals(template.name) : template.name != null) return false; // // return true; // } // // @Override // public int hashCode() { // return name != null ? name.hashCode() : 0; // } // } // Path: src/main/java/com/presidentio/testdatagenerator/output/formatter/EsFormatter.java import com.presidentio.testdatagenerator.cons.DelimiterConst; import com.presidentio.testdatagenerator.cons.PropConst; import com.presidentio.testdatagenerator.model.Template; import org.codehaus.jackson.map.ObjectMapper; import java.io.IOException; import java.util.List; import java.util.Map; package com.presidentio.testdatagenerator.output.formatter; /** * Created by Vitalii_Gergel on 2/19/2015. */ public class EsFormatter implements Formatter { private static final String INDEX = "{ \"index\" : { \"_index\" : \"%s\", \"_type\" : \"%s\"} }"; private ObjectMapper objectMapper = new ObjectMapper(); private String index; @Override public void init(Map<String, String> props) { index = props.get(PropConst.INDEX); if (index == null) { throw new IllegalArgumentException(PropConst.INDEX + " does not specified or null"); } } @Override public String format(Map<String, Object> map, Template template) { String result = String.format(INDEX, index, template.getName());
result += DelimiterConst.NEW_LINE;
presidentio/test-data-generator
src/main/java/com/presidentio/testdatagenerator/output/formatter/SvFormatter.java
// Path: src/main/java/com/presidentio/testdatagenerator/cons/DelimiterConst.java // public class DelimiterConst { // // public static final String COMMA = ","; // public static final String TAB = "\t"; // public static final String NEW_LINE = "\n"; // public static final String SPACE = " "; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java // public class PropConst { // // public static final String TYPE = "type"; // public static final String VALUE = "value"; // public static final String SIZE = "size"; // public static final String DOMAIN = "domain"; // public static final String EXPR = "expr"; // public static final String FILE = "file"; // public static final String DELIMITER = "delimiter"; // public static final String ITEMS = "items"; // public static final String INDEX = "index"; // public static final String HOST = "host"; // public static final String PORT = "port"; // public static final String CLUSTER_NAME = "clusterName"; // public static final String CONNECTION_URL = "connectionUrl"; // public static final String JDBC_DRIVER = "jdbcDriver"; // public static final String DEPTH = "depth"; // public static final String FIELD = "field"; // public static final String VAR = "var"; // public static final String OP = "op"; // public static final String FORMAT = "format"; // public static final String HEADER = "header"; // public static final String SUFFIX = "suffix"; // public static final String PREFIX = "prefix"; // public static final String PATH_PROVIDER = "pathProvider"; // public static final String BROKER_LIST = "brokerList"; // public static final String GENDER = "gender"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/model/Template.java // public class Template { // // private String id; // // private String extend; // // @JsonIgnore // private Template extendTemplate; // // private Integer count; // // private String name; // // private List<Field> fields; // // private List<String> childs = new ArrayList<>(); // // public String getId() { // return id; // } // // public void setId(String id) { // this.id = id; // } // // public String getExtend() { // return extend; // } // // public void setExtend(String extend) { // this.extend = extend; // } // // public Template getExtendTemplate() { // return extendTemplate; // } // // public void setExtendTemplate(Template extendTemplate) { // this.extendTemplate = extendTemplate; // } // // public Integer getCount() { // if (count == null && extendTemplate != null) { // return extendTemplate.getCount(); // } // return count; // } // // public void setCount(Integer count) { // this.count = count; // } // // public String getName() { // if (name == null && extendTemplate != null) { // return extendTemplate.getName(); // } // return name; // } // // public void setName(String name) { // this.name = name; // } // // public List<Field> getFields() { // List<Field> result = new ArrayList<>(); // if (extendTemplate != null && extendTemplate.getFields() != null) { // result.addAll(extendTemplate.getFields()); // } // if (fields != null) { // result.addAll(fields); // } // return result; // } // // public void setFields(List<Field> fields) { // this.fields = fields; // } // // public List<String> getChilds() { // List<String> result = new ArrayList<>(); // if (extendTemplate != null && extendTemplate.getChilds() != null) { // result.addAll(extendTemplate.getChilds()); // } // if (childs != null) { // result.addAll(childs); // } // return result; // } // // public void setChilds(List<String> childs) { // this.childs = childs; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // Template template = (Template) o; // // if (name != null ? !name.equals(template.name) : template.name != null) return false; // // return true; // } // // @Override // public int hashCode() { // return name != null ? name.hashCode() : 0; // } // }
import com.presidentio.testdatagenerator.cons.DelimiterConst; import com.presidentio.testdatagenerator.cons.PropConst; import com.presidentio.testdatagenerator.model.Template; import java.util.List; import java.util.Map; import java.util.Set;
package com.presidentio.testdatagenerator.output.formatter; /** * Created by presidentio on 23.04.15. */ public class SvFormatter implements Formatter { private String defaultDelimiter = DelimiterConst.COMMA; private boolean printHeader; private Set<String> header; private String delimiter; public SvFormatter(String defaultDelimiter) { this.defaultDelimiter = defaultDelimiter; } public SvFormatter() { } @Override public void init(Map<String, String> props) {
// Path: src/main/java/com/presidentio/testdatagenerator/cons/DelimiterConst.java // public class DelimiterConst { // // public static final String COMMA = ","; // public static final String TAB = "\t"; // public static final String NEW_LINE = "\n"; // public static final String SPACE = " "; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java // public class PropConst { // // public static final String TYPE = "type"; // public static final String VALUE = "value"; // public static final String SIZE = "size"; // public static final String DOMAIN = "domain"; // public static final String EXPR = "expr"; // public static final String FILE = "file"; // public static final String DELIMITER = "delimiter"; // public static final String ITEMS = "items"; // public static final String INDEX = "index"; // public static final String HOST = "host"; // public static final String PORT = "port"; // public static final String CLUSTER_NAME = "clusterName"; // public static final String CONNECTION_URL = "connectionUrl"; // public static final String JDBC_DRIVER = "jdbcDriver"; // public static final String DEPTH = "depth"; // public static final String FIELD = "field"; // public static final String VAR = "var"; // public static final String OP = "op"; // public static final String FORMAT = "format"; // public static final String HEADER = "header"; // public static final String SUFFIX = "suffix"; // public static final String PREFIX = "prefix"; // public static final String PATH_PROVIDER = "pathProvider"; // public static final String BROKER_LIST = "brokerList"; // public static final String GENDER = "gender"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/model/Template.java // public class Template { // // private String id; // // private String extend; // // @JsonIgnore // private Template extendTemplate; // // private Integer count; // // private String name; // // private List<Field> fields; // // private List<String> childs = new ArrayList<>(); // // public String getId() { // return id; // } // // public void setId(String id) { // this.id = id; // } // // public String getExtend() { // return extend; // } // // public void setExtend(String extend) { // this.extend = extend; // } // // public Template getExtendTemplate() { // return extendTemplate; // } // // public void setExtendTemplate(Template extendTemplate) { // this.extendTemplate = extendTemplate; // } // // public Integer getCount() { // if (count == null && extendTemplate != null) { // return extendTemplate.getCount(); // } // return count; // } // // public void setCount(Integer count) { // this.count = count; // } // // public String getName() { // if (name == null && extendTemplate != null) { // return extendTemplate.getName(); // } // return name; // } // // public void setName(String name) { // this.name = name; // } // // public List<Field> getFields() { // List<Field> result = new ArrayList<>(); // if (extendTemplate != null && extendTemplate.getFields() != null) { // result.addAll(extendTemplate.getFields()); // } // if (fields != null) { // result.addAll(fields); // } // return result; // } // // public void setFields(List<Field> fields) { // this.fields = fields; // } // // public List<String> getChilds() { // List<String> result = new ArrayList<>(); // if (extendTemplate != null && extendTemplate.getChilds() != null) { // result.addAll(extendTemplate.getChilds()); // } // if (childs != null) { // result.addAll(childs); // } // return result; // } // // public void setChilds(List<String> childs) { // this.childs = childs; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // Template template = (Template) o; // // if (name != null ? !name.equals(template.name) : template.name != null) return false; // // return true; // } // // @Override // public int hashCode() { // return name != null ? name.hashCode() : 0; // } // } // Path: src/main/java/com/presidentio/testdatagenerator/output/formatter/SvFormatter.java import com.presidentio.testdatagenerator.cons.DelimiterConst; import com.presidentio.testdatagenerator.cons.PropConst; import com.presidentio.testdatagenerator.model.Template; import java.util.List; import java.util.Map; import java.util.Set; package com.presidentio.testdatagenerator.output.formatter; /** * Created by presidentio on 23.04.15. */ public class SvFormatter implements Formatter { private String defaultDelimiter = DelimiterConst.COMMA; private boolean printHeader; private Set<String> header; private String delimiter; public SvFormatter(String defaultDelimiter) { this.defaultDelimiter = defaultDelimiter; } public SvFormatter() { } @Override public void init(Map<String, String> props) {
String headerStr = props.get(PropConst.HEADER);
presidentio/test-data-generator
src/main/java/com/presidentio/testdatagenerator/output/formatter/SvFormatter.java
// Path: src/main/java/com/presidentio/testdatagenerator/cons/DelimiterConst.java // public class DelimiterConst { // // public static final String COMMA = ","; // public static final String TAB = "\t"; // public static final String NEW_LINE = "\n"; // public static final String SPACE = " "; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java // public class PropConst { // // public static final String TYPE = "type"; // public static final String VALUE = "value"; // public static final String SIZE = "size"; // public static final String DOMAIN = "domain"; // public static final String EXPR = "expr"; // public static final String FILE = "file"; // public static final String DELIMITER = "delimiter"; // public static final String ITEMS = "items"; // public static final String INDEX = "index"; // public static final String HOST = "host"; // public static final String PORT = "port"; // public static final String CLUSTER_NAME = "clusterName"; // public static final String CONNECTION_URL = "connectionUrl"; // public static final String JDBC_DRIVER = "jdbcDriver"; // public static final String DEPTH = "depth"; // public static final String FIELD = "field"; // public static final String VAR = "var"; // public static final String OP = "op"; // public static final String FORMAT = "format"; // public static final String HEADER = "header"; // public static final String SUFFIX = "suffix"; // public static final String PREFIX = "prefix"; // public static final String PATH_PROVIDER = "pathProvider"; // public static final String BROKER_LIST = "brokerList"; // public static final String GENDER = "gender"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/model/Template.java // public class Template { // // private String id; // // private String extend; // // @JsonIgnore // private Template extendTemplate; // // private Integer count; // // private String name; // // private List<Field> fields; // // private List<String> childs = new ArrayList<>(); // // public String getId() { // return id; // } // // public void setId(String id) { // this.id = id; // } // // public String getExtend() { // return extend; // } // // public void setExtend(String extend) { // this.extend = extend; // } // // public Template getExtendTemplate() { // return extendTemplate; // } // // public void setExtendTemplate(Template extendTemplate) { // this.extendTemplate = extendTemplate; // } // // public Integer getCount() { // if (count == null && extendTemplate != null) { // return extendTemplate.getCount(); // } // return count; // } // // public void setCount(Integer count) { // this.count = count; // } // // public String getName() { // if (name == null && extendTemplate != null) { // return extendTemplate.getName(); // } // return name; // } // // public void setName(String name) { // this.name = name; // } // // public List<Field> getFields() { // List<Field> result = new ArrayList<>(); // if (extendTemplate != null && extendTemplate.getFields() != null) { // result.addAll(extendTemplate.getFields()); // } // if (fields != null) { // result.addAll(fields); // } // return result; // } // // public void setFields(List<Field> fields) { // this.fields = fields; // } // // public List<String> getChilds() { // List<String> result = new ArrayList<>(); // if (extendTemplate != null && extendTemplate.getChilds() != null) { // result.addAll(extendTemplate.getChilds()); // } // if (childs != null) { // result.addAll(childs); // } // return result; // } // // public void setChilds(List<String> childs) { // this.childs = childs; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // Template template = (Template) o; // // if (name != null ? !name.equals(template.name) : template.name != null) return false; // // return true; // } // // @Override // public int hashCode() { // return name != null ? name.hashCode() : 0; // } // }
import com.presidentio.testdatagenerator.cons.DelimiterConst; import com.presidentio.testdatagenerator.cons.PropConst; import com.presidentio.testdatagenerator.model.Template; import java.util.List; import java.util.Map; import java.util.Set;
package com.presidentio.testdatagenerator.output.formatter; /** * Created by presidentio on 23.04.15. */ public class SvFormatter implements Formatter { private String defaultDelimiter = DelimiterConst.COMMA; private boolean printHeader; private Set<String> header; private String delimiter; public SvFormatter(String defaultDelimiter) { this.defaultDelimiter = defaultDelimiter; } public SvFormatter() { } @Override public void init(Map<String, String> props) { String headerStr = props.get(PropConst.HEADER); printHeader = Boolean.valueOf(headerStr); delimiter = props.get(PropConst.DELIMITER); if (delimiter == null) { delimiter = defaultDelimiter; } } @Override
// Path: src/main/java/com/presidentio/testdatagenerator/cons/DelimiterConst.java // public class DelimiterConst { // // public static final String COMMA = ","; // public static final String TAB = "\t"; // public static final String NEW_LINE = "\n"; // public static final String SPACE = " "; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java // public class PropConst { // // public static final String TYPE = "type"; // public static final String VALUE = "value"; // public static final String SIZE = "size"; // public static final String DOMAIN = "domain"; // public static final String EXPR = "expr"; // public static final String FILE = "file"; // public static final String DELIMITER = "delimiter"; // public static final String ITEMS = "items"; // public static final String INDEX = "index"; // public static final String HOST = "host"; // public static final String PORT = "port"; // public static final String CLUSTER_NAME = "clusterName"; // public static final String CONNECTION_URL = "connectionUrl"; // public static final String JDBC_DRIVER = "jdbcDriver"; // public static final String DEPTH = "depth"; // public static final String FIELD = "field"; // public static final String VAR = "var"; // public static final String OP = "op"; // public static final String FORMAT = "format"; // public static final String HEADER = "header"; // public static final String SUFFIX = "suffix"; // public static final String PREFIX = "prefix"; // public static final String PATH_PROVIDER = "pathProvider"; // public static final String BROKER_LIST = "brokerList"; // public static final String GENDER = "gender"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/model/Template.java // public class Template { // // private String id; // // private String extend; // // @JsonIgnore // private Template extendTemplate; // // private Integer count; // // private String name; // // private List<Field> fields; // // private List<String> childs = new ArrayList<>(); // // public String getId() { // return id; // } // // public void setId(String id) { // this.id = id; // } // // public String getExtend() { // return extend; // } // // public void setExtend(String extend) { // this.extend = extend; // } // // public Template getExtendTemplate() { // return extendTemplate; // } // // public void setExtendTemplate(Template extendTemplate) { // this.extendTemplate = extendTemplate; // } // // public Integer getCount() { // if (count == null && extendTemplate != null) { // return extendTemplate.getCount(); // } // return count; // } // // public void setCount(Integer count) { // this.count = count; // } // // public String getName() { // if (name == null && extendTemplate != null) { // return extendTemplate.getName(); // } // return name; // } // // public void setName(String name) { // this.name = name; // } // // public List<Field> getFields() { // List<Field> result = new ArrayList<>(); // if (extendTemplate != null && extendTemplate.getFields() != null) { // result.addAll(extendTemplate.getFields()); // } // if (fields != null) { // result.addAll(fields); // } // return result; // } // // public void setFields(List<Field> fields) { // this.fields = fields; // } // // public List<String> getChilds() { // List<String> result = new ArrayList<>(); // if (extendTemplate != null && extendTemplate.getChilds() != null) { // result.addAll(extendTemplate.getChilds()); // } // if (childs != null) { // result.addAll(childs); // } // return result; // } // // public void setChilds(List<String> childs) { // this.childs = childs; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // Template template = (Template) o; // // if (name != null ? !name.equals(template.name) : template.name != null) return false; // // return true; // } // // @Override // public int hashCode() { // return name != null ? name.hashCode() : 0; // } // } // Path: src/main/java/com/presidentio/testdatagenerator/output/formatter/SvFormatter.java import com.presidentio.testdatagenerator.cons.DelimiterConst; import com.presidentio.testdatagenerator.cons.PropConst; import com.presidentio.testdatagenerator.model.Template; import java.util.List; import java.util.Map; import java.util.Set; package com.presidentio.testdatagenerator.output.formatter; /** * Created by presidentio on 23.04.15. */ public class SvFormatter implements Formatter { private String defaultDelimiter = DelimiterConst.COMMA; private boolean printHeader; private Set<String> header; private String delimiter; public SvFormatter(String defaultDelimiter) { this.defaultDelimiter = defaultDelimiter; } public SvFormatter() { } @Override public void init(Map<String, String> props) { String headerStr = props.get(PropConst.HEADER); printHeader = Boolean.valueOf(headerStr); delimiter = props.get(PropConst.DELIMITER); if (delimiter == null) { delimiter = defaultDelimiter; } } @Override
public String format(Map<String, Object> map, Template template) {
presidentio/test-data-generator
src/main/java/com/presidentio/testdatagenerator/provider/CompositeValueProviderFactory.java
// Path: src/main/java/com/presidentio/testdatagenerator/model/Provider.java // public class Provider { // // private String name; // // private HashMap<String, String> props; // // public Provider() { // } // // public Provider(String name, HashMap<String, String> props) { // this.name = name; // this.props = props; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public HashMap<String, String> getProps() { // return props; // } // // public void setProps(HashMap<String, String> props) { // this.props = props; // } // }
import java.util.ArrayList; import java.util.List; import com.presidentio.testdatagenerator.model.Provider;
/** * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.presidentio.testdatagenerator.provider; /** * Created by Vitalii_Gergel on 2/6/2015. */ public class CompositeValueProviderFactory implements ValueProviderFactory { private List<ValueProviderFactory> valueProviderFactories = new ArrayList<>(); @Override
// Path: src/main/java/com/presidentio/testdatagenerator/model/Provider.java // public class Provider { // // private String name; // // private HashMap<String, String> props; // // public Provider() { // } // // public Provider(String name, HashMap<String, String> props) { // this.name = name; // this.props = props; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public HashMap<String, String> getProps() { // return props; // } // // public void setProps(HashMap<String, String> props) { // this.props = props; // } // } // Path: src/main/java/com/presidentio/testdatagenerator/provider/CompositeValueProviderFactory.java import java.util.ArrayList; import java.util.List; import com.presidentio.testdatagenerator.model.Provider; /** * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.presidentio.testdatagenerator.provider; /** * Created by Vitalii_Gergel on 2/6/2015. */ public class CompositeValueProviderFactory implements ValueProviderFactory { private List<ValueProviderFactory> valueProviderFactories = new ArrayList<>(); @Override
public ValueProvider buildValueProvider(Provider provider) {
presidentio/test-data-generator
src/main/java/com/presidentio/testdatagenerator/Starter.java
// Path: src/main/java/com/presidentio/testdatagenerator/parser/JsonSchemaSerializer.java // public class JsonSchemaSerializer implements SchemaSerializer { // // private ObjectMapper objectMapper; // // public JsonSchemaSerializer() { // objectMapper = new ObjectMapper(); // SimpleDeserializers simpleDeserializers = new SimpleDeserializers(); // simpleDeserializers.addDeserializer(String.class, new StringDeserializer()); // objectMapper.setDeserializerProvider( // new StdDeserializerProvider().withAdditionalDeserializers(simpleDeserializers)); // } // // @Override // public Schema deserialize(InputStream inputStream) throws IOException { // return objectMapper.readValue(inputStream, Schema.class); // } // // @Override // public Schema deserialize(String string) throws IOException { // return objectMapper.readValue(string, Schema.class); // } // // @Override // public void serialize(Schema schema, OutputStream outputStream) throws IOException { // objectMapper.writeValue(outputStream, schema); // } // // @Override // public String serialize(Schema schema) throws IOException { // return objectMapper.writeValueAsString(schema); // } // // } // // Path: src/main/java/com/presidentio/testdatagenerator/parser/SchemaSerializer.java // public interface SchemaSerializer { // // Schema deserialize(InputStream inputStream) throws IOException; // // Schema deserialize(String string) throws IOException; // // void serialize(Schema schema, OutputStream outputStream) throws IOException; // // String serialize(Schema schema) throws IOException; // // }
import com.beust.jcommander.JCommander; import com.beust.jcommander.Parameter; import com.beust.jcommander.ParameterException; import com.presidentio.testdatagenerator.model.*; import com.presidentio.testdatagenerator.parser.JsonSchemaSerializer; import com.presidentio.testdatagenerator.parser.SchemaSerializer; import java.io.FileInputStream; import java.io.IOException;
/** * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * <p> * http://www.apache.org/licenses/LICENSE-2.0 * <p> * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.presidentio.testdatagenerator; public class Starter { @Parameter(names = "-a", description = "async, default true") private Boolean async = true; @Parameter(names = "-th", description = "thread count, work only when async true, default is processors count") private Integer threadCount; @Parameter(names = "-s", required = true, description = "Generation schema json file") private String schemaFile; public static void main(String[] args) throws IOException { Starter starter = new Starter(); JCommander jCommander = new JCommander(starter); try { jCommander.parse(args); starter.start(); } catch (ParameterException e) { System.out.println(e.getMessage()); jCommander.usage(); } } public void start() throws IOException {
// Path: src/main/java/com/presidentio/testdatagenerator/parser/JsonSchemaSerializer.java // public class JsonSchemaSerializer implements SchemaSerializer { // // private ObjectMapper objectMapper; // // public JsonSchemaSerializer() { // objectMapper = new ObjectMapper(); // SimpleDeserializers simpleDeserializers = new SimpleDeserializers(); // simpleDeserializers.addDeserializer(String.class, new StringDeserializer()); // objectMapper.setDeserializerProvider( // new StdDeserializerProvider().withAdditionalDeserializers(simpleDeserializers)); // } // // @Override // public Schema deserialize(InputStream inputStream) throws IOException { // return objectMapper.readValue(inputStream, Schema.class); // } // // @Override // public Schema deserialize(String string) throws IOException { // return objectMapper.readValue(string, Schema.class); // } // // @Override // public void serialize(Schema schema, OutputStream outputStream) throws IOException { // objectMapper.writeValue(outputStream, schema); // } // // @Override // public String serialize(Schema schema) throws IOException { // return objectMapper.writeValueAsString(schema); // } // // } // // Path: src/main/java/com/presidentio/testdatagenerator/parser/SchemaSerializer.java // public interface SchemaSerializer { // // Schema deserialize(InputStream inputStream) throws IOException; // // Schema deserialize(String string) throws IOException; // // void serialize(Schema schema, OutputStream outputStream) throws IOException; // // String serialize(Schema schema) throws IOException; // // } // Path: src/main/java/com/presidentio/testdatagenerator/Starter.java import com.beust.jcommander.JCommander; import com.beust.jcommander.Parameter; import com.beust.jcommander.ParameterException; import com.presidentio.testdatagenerator.model.*; import com.presidentio.testdatagenerator.parser.JsonSchemaSerializer; import com.presidentio.testdatagenerator.parser.SchemaSerializer; import java.io.FileInputStream; import java.io.IOException; /** * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * <p> * http://www.apache.org/licenses/LICENSE-2.0 * <p> * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.presidentio.testdatagenerator; public class Starter { @Parameter(names = "-a", description = "async, default true") private Boolean async = true; @Parameter(names = "-th", description = "thread count, work only when async true, default is processors count") private Integer threadCount; @Parameter(names = "-s", required = true, description = "Generation schema json file") private String schemaFile; public static void main(String[] args) throws IOException { Starter starter = new Starter(); JCommander jCommander = new JCommander(starter); try { jCommander.parse(args); starter.start(); } catch (ParameterException e) { System.out.println(e.getMessage()); jCommander.usage(); } } public void start() throws IOException {
SchemaSerializer schemaSerializer = new JsonSchemaSerializer();
presidentio/test-data-generator
src/main/java/com/presidentio/testdatagenerator/Starter.java
// Path: src/main/java/com/presidentio/testdatagenerator/parser/JsonSchemaSerializer.java // public class JsonSchemaSerializer implements SchemaSerializer { // // private ObjectMapper objectMapper; // // public JsonSchemaSerializer() { // objectMapper = new ObjectMapper(); // SimpleDeserializers simpleDeserializers = new SimpleDeserializers(); // simpleDeserializers.addDeserializer(String.class, new StringDeserializer()); // objectMapper.setDeserializerProvider( // new StdDeserializerProvider().withAdditionalDeserializers(simpleDeserializers)); // } // // @Override // public Schema deserialize(InputStream inputStream) throws IOException { // return objectMapper.readValue(inputStream, Schema.class); // } // // @Override // public Schema deserialize(String string) throws IOException { // return objectMapper.readValue(string, Schema.class); // } // // @Override // public void serialize(Schema schema, OutputStream outputStream) throws IOException { // objectMapper.writeValue(outputStream, schema); // } // // @Override // public String serialize(Schema schema) throws IOException { // return objectMapper.writeValueAsString(schema); // } // // } // // Path: src/main/java/com/presidentio/testdatagenerator/parser/SchemaSerializer.java // public interface SchemaSerializer { // // Schema deserialize(InputStream inputStream) throws IOException; // // Schema deserialize(String string) throws IOException; // // void serialize(Schema schema, OutputStream outputStream) throws IOException; // // String serialize(Schema schema) throws IOException; // // }
import com.beust.jcommander.JCommander; import com.beust.jcommander.Parameter; import com.beust.jcommander.ParameterException; import com.presidentio.testdatagenerator.model.*; import com.presidentio.testdatagenerator.parser.JsonSchemaSerializer; import com.presidentio.testdatagenerator.parser.SchemaSerializer; import java.io.FileInputStream; import java.io.IOException;
/** * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * <p> * http://www.apache.org/licenses/LICENSE-2.0 * <p> * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.presidentio.testdatagenerator; public class Starter { @Parameter(names = "-a", description = "async, default true") private Boolean async = true; @Parameter(names = "-th", description = "thread count, work only when async true, default is processors count") private Integer threadCount; @Parameter(names = "-s", required = true, description = "Generation schema json file") private String schemaFile; public static void main(String[] args) throws IOException { Starter starter = new Starter(); JCommander jCommander = new JCommander(starter); try { jCommander.parse(args); starter.start(); } catch (ParameterException e) { System.out.println(e.getMessage()); jCommander.usage(); } } public void start() throws IOException {
// Path: src/main/java/com/presidentio/testdatagenerator/parser/JsonSchemaSerializer.java // public class JsonSchemaSerializer implements SchemaSerializer { // // private ObjectMapper objectMapper; // // public JsonSchemaSerializer() { // objectMapper = new ObjectMapper(); // SimpleDeserializers simpleDeserializers = new SimpleDeserializers(); // simpleDeserializers.addDeserializer(String.class, new StringDeserializer()); // objectMapper.setDeserializerProvider( // new StdDeserializerProvider().withAdditionalDeserializers(simpleDeserializers)); // } // // @Override // public Schema deserialize(InputStream inputStream) throws IOException { // return objectMapper.readValue(inputStream, Schema.class); // } // // @Override // public Schema deserialize(String string) throws IOException { // return objectMapper.readValue(string, Schema.class); // } // // @Override // public void serialize(Schema schema, OutputStream outputStream) throws IOException { // objectMapper.writeValue(outputStream, schema); // } // // @Override // public String serialize(Schema schema) throws IOException { // return objectMapper.writeValueAsString(schema); // } // // } // // Path: src/main/java/com/presidentio/testdatagenerator/parser/SchemaSerializer.java // public interface SchemaSerializer { // // Schema deserialize(InputStream inputStream) throws IOException; // // Schema deserialize(String string) throws IOException; // // void serialize(Schema schema, OutputStream outputStream) throws IOException; // // String serialize(Schema schema) throws IOException; // // } // Path: src/main/java/com/presidentio/testdatagenerator/Starter.java import com.beust.jcommander.JCommander; import com.beust.jcommander.Parameter; import com.beust.jcommander.ParameterException; import com.presidentio.testdatagenerator.model.*; import com.presidentio.testdatagenerator.parser.JsonSchemaSerializer; import com.presidentio.testdatagenerator.parser.SchemaSerializer; import java.io.FileInputStream; import java.io.IOException; /** * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * <p> * http://www.apache.org/licenses/LICENSE-2.0 * <p> * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.presidentio.testdatagenerator; public class Starter { @Parameter(names = "-a", description = "async, default true") private Boolean async = true; @Parameter(names = "-th", description = "thread count, work only when async true, default is processors count") private Integer threadCount; @Parameter(names = "-s", required = true, description = "Generation schema json file") private String schemaFile; public static void main(String[] args) throws IOException { Starter starter = new Starter(); JCommander jCommander = new JCommander(starter); try { jCommander.parse(args); starter.start(); } catch (ParameterException e) { System.out.println(e.getMessage()); jCommander.usage(); } } public void start() throws IOException {
SchemaSerializer schemaSerializer = new JsonSchemaSerializer();
presidentio/test-data-generator
src/test/java/com/presidentio/testdatagenerator/output/path/ConstPathProviderTest.java
// Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java // public class PropConst { // // public static final String TYPE = "type"; // public static final String VALUE = "value"; // public static final String SIZE = "size"; // public static final String DOMAIN = "domain"; // public static final String EXPR = "expr"; // public static final String FILE = "file"; // public static final String DELIMITER = "delimiter"; // public static final String ITEMS = "items"; // public static final String INDEX = "index"; // public static final String HOST = "host"; // public static final String PORT = "port"; // public static final String CLUSTER_NAME = "clusterName"; // public static final String CONNECTION_URL = "connectionUrl"; // public static final String JDBC_DRIVER = "jdbcDriver"; // public static final String DEPTH = "depth"; // public static final String FIELD = "field"; // public static final String VAR = "var"; // public static final String OP = "op"; // public static final String FORMAT = "format"; // public static final String HEADER = "header"; // public static final String SUFFIX = "suffix"; // public static final String PREFIX = "prefix"; // public static final String PATH_PROVIDER = "pathProvider"; // public static final String BROKER_LIST = "brokerList"; // public static final String GENDER = "gender"; // // }
import com.presidentio.testdatagenerator.cons.PropConst; import junit.framework.TestCase; import org.junit.Assert; import org.junit.Test; import java.util.HashMap; import java.util.Map;
package com.presidentio.testdatagenerator.output.path; /** * Created by presidentio on 24.04.15. */ public class ConstPathProviderTest extends TestCase { @Test public void testGetFilePath() throws Exception { String expected = "a.sql"; Map<String, String> props = new HashMap<>();
// Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java // public class PropConst { // // public static final String TYPE = "type"; // public static final String VALUE = "value"; // public static final String SIZE = "size"; // public static final String DOMAIN = "domain"; // public static final String EXPR = "expr"; // public static final String FILE = "file"; // public static final String DELIMITER = "delimiter"; // public static final String ITEMS = "items"; // public static final String INDEX = "index"; // public static final String HOST = "host"; // public static final String PORT = "port"; // public static final String CLUSTER_NAME = "clusterName"; // public static final String CONNECTION_URL = "connectionUrl"; // public static final String JDBC_DRIVER = "jdbcDriver"; // public static final String DEPTH = "depth"; // public static final String FIELD = "field"; // public static final String VAR = "var"; // public static final String OP = "op"; // public static final String FORMAT = "format"; // public static final String HEADER = "header"; // public static final String SUFFIX = "suffix"; // public static final String PREFIX = "prefix"; // public static final String PATH_PROVIDER = "pathProvider"; // public static final String BROKER_LIST = "brokerList"; // public static final String GENDER = "gender"; // // } // Path: src/test/java/com/presidentio/testdatagenerator/output/path/ConstPathProviderTest.java import com.presidentio.testdatagenerator.cons.PropConst; import junit.framework.TestCase; import org.junit.Assert; import org.junit.Test; import java.util.HashMap; import java.util.Map; package com.presidentio.testdatagenerator.output.path; /** * Created by presidentio on 24.04.15. */ public class ConstPathProviderTest extends TestCase { @Test public void testGetFilePath() throws Exception { String expected = "a.sql"; Map<String, String> props = new HashMap<>();
props.put(PropConst.FILE, expected);
presidentio/test-data-generator
src/test/java/com/presidentio/testdatagenerator/KafkaTest.java
// Path: src/main/java/com/presidentio/testdatagenerator/model/Output.java // public class Output { // // private String type; // // @JsonDeserialize(contentUsing = StringDeserializer.class) // private Map<String, String> props; // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // public Map<String, String> getProps() { // return props; // } // // public void setProps(Map<String, String> props) { // this.props = props; // } // }
import com.presidentio.testdatagenerator.model.Output; import org.junit.After; import org.junit.Before; import org.junit.Ignore; import java.util.Arrays; import java.util.List;
package com.presidentio.testdatagenerator; /** * Created by presidentio on 24.04.15. */ @Ignore public class KafkaTest extends AbstractGeneratorTest { @Before public void setUp() throws Exception { } @After public void tearDown() throws Exception { } @Override protected List<String> getSchemaResource() { return Arrays.asList("test-kafka-schema.json"); } @Override
// Path: src/main/java/com/presidentio/testdatagenerator/model/Output.java // public class Output { // // private String type; // // @JsonDeserialize(contentUsing = StringDeserializer.class) // private Map<String, String> props; // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // public Map<String, String> getProps() { // return props; // } // // public void setProps(Map<String, String> props) { // this.props = props; // } // } // Path: src/test/java/com/presidentio/testdatagenerator/KafkaTest.java import com.presidentio.testdatagenerator.model.Output; import org.junit.After; import org.junit.Before; import org.junit.Ignore; import java.util.Arrays; import java.util.List; package com.presidentio.testdatagenerator; /** * Created by presidentio on 24.04.15. */ @Ignore public class KafkaTest extends AbstractGeneratorTest { @Before public void setUp() throws Exception { } @After public void tearDown() throws Exception { } @Override protected List<String> getSchemaResource() { return Arrays.asList("test-kafka-schema.json"); } @Override
protected void testResult(Output output) {
presidentio/test-data-generator
src/main/java/com/presidentio/testdatagenerator/provider/TypeConverter.java
// Path: src/main/java/com/presidentio/testdatagenerator/cons/TypeConst.java // public class TypeConst { // // public static final String STRING = "string"; // public static final String LONG = "long"; // public static final String INT = "int"; // public static final String BOOLEAN = "boolean"; // // }
import com.presidentio.testdatagenerator.cons.TypeConst;
/** * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.presidentio.testdatagenerator.provider; public class TypeConverter { public static <T> T convert(String value, String type) { switch (type) {
// Path: src/main/java/com/presidentio/testdatagenerator/cons/TypeConst.java // public class TypeConst { // // public static final String STRING = "string"; // public static final String LONG = "long"; // public static final String INT = "int"; // public static final String BOOLEAN = "boolean"; // // } // Path: src/main/java/com/presidentio/testdatagenerator/provider/TypeConverter.java import com.presidentio.testdatagenerator.cons.TypeConst; /** * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.presidentio.testdatagenerator.provider; public class TypeConverter { public static <T> T convert(String value, String type) { switch (type) {
case TypeConst.STRING:
presidentio/test-data-generator
src/main/java/com/presidentio/testdatagenerator/parser/SchemaBuilder.java
// Path: src/main/java/com/presidentio/testdatagenerator/model/Schema.java // public class Schema { // // private List<Template> templates = new ArrayList<>(); // // private List<String> root = new ArrayList<>(); // // private List<Variable> variables = new ArrayList<>(); // // private Output output; // // public List<Template> getTemplates() { // return templates; // } // // public void setTemplates(List<Template> templates) { // this.templates = templates; // } // // public List<String> getRoot() { // return root; // } // // public void setRoot(List<String> root) { // this.root = root; // } // // public List<Variable> getVariables() { // return variables; // } // // public void setVariables(List<Variable> variables) { // this.variables = variables; // } // // public Output getOutput() { // return output; // } // // public void setOutput(Output output) { // this.output = output; // } // } // // Path: src/main/java/com/presidentio/testdatagenerator/model/Template.java // public class Template { // // private String id; // // private String extend; // // @JsonIgnore // private Template extendTemplate; // // private Integer count; // // private String name; // // private List<Field> fields; // // private List<String> childs = new ArrayList<>(); // // public String getId() { // return id; // } // // public void setId(String id) { // this.id = id; // } // // public String getExtend() { // return extend; // } // // public void setExtend(String extend) { // this.extend = extend; // } // // public Template getExtendTemplate() { // return extendTemplate; // } // // public void setExtendTemplate(Template extendTemplate) { // this.extendTemplate = extendTemplate; // } // // public Integer getCount() { // if (count == null && extendTemplate != null) { // return extendTemplate.getCount(); // } // return count; // } // // public void setCount(Integer count) { // this.count = count; // } // // public String getName() { // if (name == null && extendTemplate != null) { // return extendTemplate.getName(); // } // return name; // } // // public void setName(String name) { // this.name = name; // } // // public List<Field> getFields() { // List<Field> result = new ArrayList<>(); // if (extendTemplate != null && extendTemplate.getFields() != null) { // result.addAll(extendTemplate.getFields()); // } // if (fields != null) { // result.addAll(fields); // } // return result; // } // // public void setFields(List<Field> fields) { // this.fields = fields; // } // // public List<String> getChilds() { // List<String> result = new ArrayList<>(); // if (extendTemplate != null && extendTemplate.getChilds() != null) { // result.addAll(extendTemplate.getChilds()); // } // if (childs != null) { // result.addAll(childs); // } // return result; // } // // public void setChilds(List<String> childs) { // this.childs = childs; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // Template template = (Template) o; // // if (name != null ? !name.equals(template.name) : template.name != null) return false; // // return true; // } // // @Override // public int hashCode() { // return name != null ? name.hashCode() : 0; // } // }
import com.presidentio.testdatagenerator.model.Schema; import com.presidentio.testdatagenerator.model.Template; import java.io.FileInputStream; import java.io.IOException; import java.util.ArrayList; import java.util.List;
Schema schema = schemaSerializer.deserialize( SchemaBuilder.class.getClassLoader().getResourceAsStream(resource)); schemas.add(schema); return this; } catch (IOException e) { throw new IllegalStateException(e); } } public SchemaBuilder fromFile(String file) { SchemaSerializer schemaSerializer = new JsonSchemaSerializer(); try { Schema schema = schemaSerializer.deserialize(new FileInputStream(file)); schemas.add(schema); return this; } catch (IOException e) { throw new IllegalStateException(e); } } public Schema build() { Schema schema = null; for (Schema schema1 : schemas) { if (schema == null) { schema = schema1; } else { schema = merge(schema, schema1); } } if (schema != null) {
// Path: src/main/java/com/presidentio/testdatagenerator/model/Schema.java // public class Schema { // // private List<Template> templates = new ArrayList<>(); // // private List<String> root = new ArrayList<>(); // // private List<Variable> variables = new ArrayList<>(); // // private Output output; // // public List<Template> getTemplates() { // return templates; // } // // public void setTemplates(List<Template> templates) { // this.templates = templates; // } // // public List<String> getRoot() { // return root; // } // // public void setRoot(List<String> root) { // this.root = root; // } // // public List<Variable> getVariables() { // return variables; // } // // public void setVariables(List<Variable> variables) { // this.variables = variables; // } // // public Output getOutput() { // return output; // } // // public void setOutput(Output output) { // this.output = output; // } // } // // Path: src/main/java/com/presidentio/testdatagenerator/model/Template.java // public class Template { // // private String id; // // private String extend; // // @JsonIgnore // private Template extendTemplate; // // private Integer count; // // private String name; // // private List<Field> fields; // // private List<String> childs = new ArrayList<>(); // // public String getId() { // return id; // } // // public void setId(String id) { // this.id = id; // } // // public String getExtend() { // return extend; // } // // public void setExtend(String extend) { // this.extend = extend; // } // // public Template getExtendTemplate() { // return extendTemplate; // } // // public void setExtendTemplate(Template extendTemplate) { // this.extendTemplate = extendTemplate; // } // // public Integer getCount() { // if (count == null && extendTemplate != null) { // return extendTemplate.getCount(); // } // return count; // } // // public void setCount(Integer count) { // this.count = count; // } // // public String getName() { // if (name == null && extendTemplate != null) { // return extendTemplate.getName(); // } // return name; // } // // public void setName(String name) { // this.name = name; // } // // public List<Field> getFields() { // List<Field> result = new ArrayList<>(); // if (extendTemplate != null && extendTemplate.getFields() != null) { // result.addAll(extendTemplate.getFields()); // } // if (fields != null) { // result.addAll(fields); // } // return result; // } // // public void setFields(List<Field> fields) { // this.fields = fields; // } // // public List<String> getChilds() { // List<String> result = new ArrayList<>(); // if (extendTemplate != null && extendTemplate.getChilds() != null) { // result.addAll(extendTemplate.getChilds()); // } // if (childs != null) { // result.addAll(childs); // } // return result; // } // // public void setChilds(List<String> childs) { // this.childs = childs; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // Template template = (Template) o; // // if (name != null ? !name.equals(template.name) : template.name != null) return false; // // return true; // } // // @Override // public int hashCode() { // return name != null ? name.hashCode() : 0; // } // } // Path: src/main/java/com/presidentio/testdatagenerator/parser/SchemaBuilder.java import com.presidentio.testdatagenerator.model.Schema; import com.presidentio.testdatagenerator.model.Template; import java.io.FileInputStream; import java.io.IOException; import java.util.ArrayList; import java.util.List; Schema schema = schemaSerializer.deserialize( SchemaBuilder.class.getClassLoader().getResourceAsStream(resource)); schemas.add(schema); return this; } catch (IOException e) { throw new IllegalStateException(e); } } public SchemaBuilder fromFile(String file) { SchemaSerializer schemaSerializer = new JsonSchemaSerializer(); try { Schema schema = schemaSerializer.deserialize(new FileInputStream(file)); schemas.add(schema); return this; } catch (IOException e) { throw new IllegalStateException(e); } } public Schema build() { Schema schema = null; for (Schema schema1 : schemas) { if (schema == null) { schema = schema1; } else { schema = merge(schema, schema1); } } if (schema != null) {
for (Template template : schema.getTemplates()) {
presidentio/test-data-generator
src/test/java/com/presidentio/testdatagenerator/MergeSchemaTest.java
// Path: src/main/java/com/presidentio/testdatagenerator/model/Output.java // public class Output { // // private String type; // // @JsonDeserialize(contentUsing = StringDeserializer.class) // private Map<String, String> props; // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // public Map<String, String> getProps() { // return props; // } // // public void setProps(Map<String, String> props) { // this.props = props; // } // }
import com.presidentio.testdatagenerator.model.Output; import org.elasticsearch.action.count.CountResponse; import org.elasticsearch.client.Client; import org.elasticsearch.index.query.QueryBuilders; import org.junit.Assert; import java.util.Arrays; import java.util.List;
package com.presidentio.testdatagenerator; /** * Created by Vitalii_Gergel on 3/2/2015. */ public class MergeSchemaTest extends AbstractEsTest { private String indexName = "test_data_generator"; @Override protected List<String> getSchemaResource() { return Arrays.asList("merge-1-test-schema.json", "merge-2-test-schema.json"); } @Override
// Path: src/main/java/com/presidentio/testdatagenerator/model/Output.java // public class Output { // // private String type; // // @JsonDeserialize(contentUsing = StringDeserializer.class) // private Map<String, String> props; // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // public Map<String, String> getProps() { // return props; // } // // public void setProps(Map<String, String> props) { // this.props = props; // } // } // Path: src/test/java/com/presidentio/testdatagenerator/MergeSchemaTest.java import com.presidentio.testdatagenerator.model.Output; import org.elasticsearch.action.count.CountResponse; import org.elasticsearch.client.Client; import org.elasticsearch.index.query.QueryBuilders; import org.junit.Assert; import java.util.Arrays; import java.util.List; package com.presidentio.testdatagenerator; /** * Created by Vitalii_Gergel on 3/2/2015. */ public class MergeSchemaTest extends AbstractEsTest { private String indexName = "test_data_generator"; @Override protected List<String> getSchemaResource() { return Arrays.asList("merge-1-test-schema.json", "merge-2-test-schema.json"); } @Override
protected void testResult(Output output) {
presidentio/test-data-generator
src/main/java/com/presidentio/testdatagenerator/output/AbstractBufferedSink.java
// Path: src/main/java/com/presidentio/testdatagenerator/model/Template.java // public class Template { // // private String id; // // private String extend; // // @JsonIgnore // private Template extendTemplate; // // private Integer count; // // private String name; // // private List<Field> fields; // // private List<String> childs = new ArrayList<>(); // // public String getId() { // return id; // } // // public void setId(String id) { // this.id = id; // } // // public String getExtend() { // return extend; // } // // public void setExtend(String extend) { // this.extend = extend; // } // // public Template getExtendTemplate() { // return extendTemplate; // } // // public void setExtendTemplate(Template extendTemplate) { // this.extendTemplate = extendTemplate; // } // // public Integer getCount() { // if (count == null && extendTemplate != null) { // return extendTemplate.getCount(); // } // return count; // } // // public void setCount(Integer count) { // this.count = count; // } // // public String getName() { // if (name == null && extendTemplate != null) { // return extendTemplate.getName(); // } // return name; // } // // public void setName(String name) { // this.name = name; // } // // public List<Field> getFields() { // List<Field> result = new ArrayList<>(); // if (extendTemplate != null && extendTemplate.getFields() != null) { // result.addAll(extendTemplate.getFields()); // } // if (fields != null) { // result.addAll(fields); // } // return result; // } // // public void setFields(List<Field> fields) { // this.fields = fields; // } // // public List<String> getChilds() { // List<String> result = new ArrayList<>(); // if (extendTemplate != null && extendTemplate.getChilds() != null) { // result.addAll(extendTemplate.getChilds()); // } // if (childs != null) { // result.addAll(childs); // } // return result; // } // // public void setChilds(List<String> childs) { // this.childs = childs; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // Template template = (Template) o; // // if (name != null ? !name.equals(template.name) : template.name != null) return false; // // return true; // } // // @Override // public int hashCode() { // return name != null ? name.hashCode() : 0; // } // } // // Path: src/main/java/com/presidentio/testdatagenerator/output/formatter/Formatter.java // public interface Formatter { // // void init(Map<String, String> props); // // String format(Map<String, Object> map, Template template); // // String format(List<Map<String, Object>> maps, Template template); // // boolean supportMultiInsert(); // // }
import com.presidentio.testdatagenerator.output.formatter.Formatter; import java.util.*; import com.presidentio.testdatagenerator.model.Template;
/** * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * <p> * http://www.apache.org/licenses/LICENSE-2.0 * <p> * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.presidentio.testdatagenerator.output; public abstract class AbstractBufferedSink implements Sink { private static final String DEFAULT_PARTITION = "default";
// Path: src/main/java/com/presidentio/testdatagenerator/model/Template.java // public class Template { // // private String id; // // private String extend; // // @JsonIgnore // private Template extendTemplate; // // private Integer count; // // private String name; // // private List<Field> fields; // // private List<String> childs = new ArrayList<>(); // // public String getId() { // return id; // } // // public void setId(String id) { // this.id = id; // } // // public String getExtend() { // return extend; // } // // public void setExtend(String extend) { // this.extend = extend; // } // // public Template getExtendTemplate() { // return extendTemplate; // } // // public void setExtendTemplate(Template extendTemplate) { // this.extendTemplate = extendTemplate; // } // // public Integer getCount() { // if (count == null && extendTemplate != null) { // return extendTemplate.getCount(); // } // return count; // } // // public void setCount(Integer count) { // this.count = count; // } // // public String getName() { // if (name == null && extendTemplate != null) { // return extendTemplate.getName(); // } // return name; // } // // public void setName(String name) { // this.name = name; // } // // public List<Field> getFields() { // List<Field> result = new ArrayList<>(); // if (extendTemplate != null && extendTemplate.getFields() != null) { // result.addAll(extendTemplate.getFields()); // } // if (fields != null) { // result.addAll(fields); // } // return result; // } // // public void setFields(List<Field> fields) { // this.fields = fields; // } // // public List<String> getChilds() { // List<String> result = new ArrayList<>(); // if (extendTemplate != null && extendTemplate.getChilds() != null) { // result.addAll(extendTemplate.getChilds()); // } // if (childs != null) { // result.addAll(childs); // } // return result; // } // // public void setChilds(List<String> childs) { // this.childs = childs; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // Template template = (Template) o; // // if (name != null ? !name.equals(template.name) : template.name != null) return false; // // return true; // } // // @Override // public int hashCode() { // return name != null ? name.hashCode() : 0; // } // } // // Path: src/main/java/com/presidentio/testdatagenerator/output/formatter/Formatter.java // public interface Formatter { // // void init(Map<String, String> props); // // String format(Map<String, Object> map, Template template); // // String format(List<Map<String, Object>> maps, Template template); // // boolean supportMultiInsert(); // // } // Path: src/main/java/com/presidentio/testdatagenerator/output/AbstractBufferedSink.java import com.presidentio.testdatagenerator.output.formatter.Formatter; import java.util.*; import com.presidentio.testdatagenerator.model.Template; /** * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * <p> * http://www.apache.org/licenses/LICENSE-2.0 * <p> * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.presidentio.testdatagenerator.output; public abstract class AbstractBufferedSink implements Sink { private static final String DEFAULT_PARTITION = "default";
private Map<Template, Map<Object, List<Map<String, Object>>>> buffer = new HashMap<>();
presidentio/test-data-generator
src/main/java/com/presidentio/testdatagenerator/output/AbstractBufferedSink.java
// Path: src/main/java/com/presidentio/testdatagenerator/model/Template.java // public class Template { // // private String id; // // private String extend; // // @JsonIgnore // private Template extendTemplate; // // private Integer count; // // private String name; // // private List<Field> fields; // // private List<String> childs = new ArrayList<>(); // // public String getId() { // return id; // } // // public void setId(String id) { // this.id = id; // } // // public String getExtend() { // return extend; // } // // public void setExtend(String extend) { // this.extend = extend; // } // // public Template getExtendTemplate() { // return extendTemplate; // } // // public void setExtendTemplate(Template extendTemplate) { // this.extendTemplate = extendTemplate; // } // // public Integer getCount() { // if (count == null && extendTemplate != null) { // return extendTemplate.getCount(); // } // return count; // } // // public void setCount(Integer count) { // this.count = count; // } // // public String getName() { // if (name == null && extendTemplate != null) { // return extendTemplate.getName(); // } // return name; // } // // public void setName(String name) { // this.name = name; // } // // public List<Field> getFields() { // List<Field> result = new ArrayList<>(); // if (extendTemplate != null && extendTemplate.getFields() != null) { // result.addAll(extendTemplate.getFields()); // } // if (fields != null) { // result.addAll(fields); // } // return result; // } // // public void setFields(List<Field> fields) { // this.fields = fields; // } // // public List<String> getChilds() { // List<String> result = new ArrayList<>(); // if (extendTemplate != null && extendTemplate.getChilds() != null) { // result.addAll(extendTemplate.getChilds()); // } // if (childs != null) { // result.addAll(childs); // } // return result; // } // // public void setChilds(List<String> childs) { // this.childs = childs; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // Template template = (Template) o; // // if (name != null ? !name.equals(template.name) : template.name != null) return false; // // return true; // } // // @Override // public int hashCode() { // return name != null ? name.hashCode() : 0; // } // } // // Path: src/main/java/com/presidentio/testdatagenerator/output/formatter/Formatter.java // public interface Formatter { // // void init(Map<String, String> props); // // String format(Map<String, Object> map, Template template); // // String format(List<Map<String, Object>> maps, Template template); // // boolean supportMultiInsert(); // // }
import com.presidentio.testdatagenerator.output.formatter.Formatter; import java.util.*; import com.presidentio.testdatagenerator.model.Template;
/** * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * <p> * http://www.apache.org/licenses/LICENSE-2.0 * <p> * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.presidentio.testdatagenerator.output; public abstract class AbstractBufferedSink implements Sink { private static final String DEFAULT_PARTITION = "default"; private Map<Template, Map<Object, List<Map<String, Object>>>> buffer = new HashMap<>();
// Path: src/main/java/com/presidentio/testdatagenerator/model/Template.java // public class Template { // // private String id; // // private String extend; // // @JsonIgnore // private Template extendTemplate; // // private Integer count; // // private String name; // // private List<Field> fields; // // private List<String> childs = new ArrayList<>(); // // public String getId() { // return id; // } // // public void setId(String id) { // this.id = id; // } // // public String getExtend() { // return extend; // } // // public void setExtend(String extend) { // this.extend = extend; // } // // public Template getExtendTemplate() { // return extendTemplate; // } // // public void setExtendTemplate(Template extendTemplate) { // this.extendTemplate = extendTemplate; // } // // public Integer getCount() { // if (count == null && extendTemplate != null) { // return extendTemplate.getCount(); // } // return count; // } // // public void setCount(Integer count) { // this.count = count; // } // // public String getName() { // if (name == null && extendTemplate != null) { // return extendTemplate.getName(); // } // return name; // } // // public void setName(String name) { // this.name = name; // } // // public List<Field> getFields() { // List<Field> result = new ArrayList<>(); // if (extendTemplate != null && extendTemplate.getFields() != null) { // result.addAll(extendTemplate.getFields()); // } // if (fields != null) { // result.addAll(fields); // } // return result; // } // // public void setFields(List<Field> fields) { // this.fields = fields; // } // // public List<String> getChilds() { // List<String> result = new ArrayList<>(); // if (extendTemplate != null && extendTemplate.getChilds() != null) { // result.addAll(extendTemplate.getChilds()); // } // if (childs != null) { // result.addAll(childs); // } // return result; // } // // public void setChilds(List<String> childs) { // this.childs = childs; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // Template template = (Template) o; // // if (name != null ? !name.equals(template.name) : template.name != null) return false; // // return true; // } // // @Override // public int hashCode() { // return name != null ? name.hashCode() : 0; // } // } // // Path: src/main/java/com/presidentio/testdatagenerator/output/formatter/Formatter.java // public interface Formatter { // // void init(Map<String, String> props); // // String format(Map<String, Object> map, Template template); // // String format(List<Map<String, Object>> maps, Template template); // // boolean supportMultiInsert(); // // } // Path: src/main/java/com/presidentio/testdatagenerator/output/AbstractBufferedSink.java import com.presidentio.testdatagenerator.output.formatter.Formatter; import java.util.*; import com.presidentio.testdatagenerator.model.Template; /** * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * <p> * http://www.apache.org/licenses/LICENSE-2.0 * <p> * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.presidentio.testdatagenerator.output; public abstract class AbstractBufferedSink implements Sink { private static final String DEFAULT_PARTITION = "default"; private Map<Template, Map<Object, List<Map<String, Object>>>> buffer = new HashMap<>();
private Formatter formatter;
presidentio/test-data-generator
src/main/java/com/presidentio/testdatagenerator/model/Output.java
// Path: src/main/java/com/presidentio/testdatagenerator/parser/StringDeserializer.java // public class StringDeserializer extends JsonDeserializer<String> { // // private static final Pattern REGEX = Pattern.compile("\\$\\{(\\w+)}"); // // @Override // public String deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) // throws IOException { // String str = jsonParser.getText(); // return formatString(str); // } // // public String formatString(String s) { // Matcher matcher = REGEX.matcher(s); // StringBuilder result = new StringBuilder(); // int curIndex = 0; // while (matcher.find()) { // String group = matcher.group(1); // result.append(s.substring(curIndex, matcher.start())); // result.append(evaluate(group)); // curIndex = matcher.end(); // } // result.append(s.substring(curIndex, s.length())); // return result.toString(); // } // // private String evaluate(String s) { // switch (s) { // case StringPlaceholderConst.TMP: // return System.getProperty("java.io.tmpdir"); // default: // throw new IllegalArgumentException("Unknown expression: " + s); // } // } // }
import org.codehaus.jackson.map.annotate.JsonDeserialize; import java.util.Map; import com.presidentio.testdatagenerator.parser.StringDeserializer;
/** * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.presidentio.testdatagenerator.model; public class Output { private String type;
// Path: src/main/java/com/presidentio/testdatagenerator/parser/StringDeserializer.java // public class StringDeserializer extends JsonDeserializer<String> { // // private static final Pattern REGEX = Pattern.compile("\\$\\{(\\w+)}"); // // @Override // public String deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) // throws IOException { // String str = jsonParser.getText(); // return formatString(str); // } // // public String formatString(String s) { // Matcher matcher = REGEX.matcher(s); // StringBuilder result = new StringBuilder(); // int curIndex = 0; // while (matcher.find()) { // String group = matcher.group(1); // result.append(s.substring(curIndex, matcher.start())); // result.append(evaluate(group)); // curIndex = matcher.end(); // } // result.append(s.substring(curIndex, s.length())); // return result.toString(); // } // // private String evaluate(String s) { // switch (s) { // case StringPlaceholderConst.TMP: // return System.getProperty("java.io.tmpdir"); // default: // throw new IllegalArgumentException("Unknown expression: " + s); // } // } // } // Path: src/main/java/com/presidentio/testdatagenerator/model/Output.java import org.codehaus.jackson.map.annotate.JsonDeserialize; import java.util.Map; import com.presidentio.testdatagenerator.parser.StringDeserializer; /** * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.presidentio.testdatagenerator.model; public class Output { private String type;
@JsonDeserialize(contentUsing = StringDeserializer.class)
presidentio/test-data-generator
src/main/java/com/presidentio/testdatagenerator/output/AbstractEsSink.java
// Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java // public class PropConst { // // public static final String TYPE = "type"; // public static final String VALUE = "value"; // public static final String SIZE = "size"; // public static final String DOMAIN = "domain"; // public static final String EXPR = "expr"; // public static final String FILE = "file"; // public static final String DELIMITER = "delimiter"; // public static final String ITEMS = "items"; // public static final String INDEX = "index"; // public static final String HOST = "host"; // public static final String PORT = "port"; // public static final String CLUSTER_NAME = "clusterName"; // public static final String CONNECTION_URL = "connectionUrl"; // public static final String JDBC_DRIVER = "jdbcDriver"; // public static final String DEPTH = "depth"; // public static final String FIELD = "field"; // public static final String VAR = "var"; // public static final String OP = "op"; // public static final String FORMAT = "format"; // public static final String HEADER = "header"; // public static final String SUFFIX = "suffix"; // public static final String PREFIX = "prefix"; // public static final String PATH_PROVIDER = "pathProvider"; // public static final String BROKER_LIST = "brokerList"; // public static final String GENDER = "gender"; // // }
import com.presidentio.testdatagenerator.cons.PropConst; import org.elasticsearch.client.Client; import org.elasticsearch.client.transport.TransportClient; import org.elasticsearch.common.settings.ImmutableSettings; import org.elasticsearch.common.transport.InetSocketTransportAddress; import java.util.Map;
/** * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.presidentio.testdatagenerator.output; public abstract class AbstractEsSink extends AbstractBufferedSink { private Client client; @Override public void init(Map<String, String> props) {
// Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java // public class PropConst { // // public static final String TYPE = "type"; // public static final String VALUE = "value"; // public static final String SIZE = "size"; // public static final String DOMAIN = "domain"; // public static final String EXPR = "expr"; // public static final String FILE = "file"; // public static final String DELIMITER = "delimiter"; // public static final String ITEMS = "items"; // public static final String INDEX = "index"; // public static final String HOST = "host"; // public static final String PORT = "port"; // public static final String CLUSTER_NAME = "clusterName"; // public static final String CONNECTION_URL = "connectionUrl"; // public static final String JDBC_DRIVER = "jdbcDriver"; // public static final String DEPTH = "depth"; // public static final String FIELD = "field"; // public static final String VAR = "var"; // public static final String OP = "op"; // public static final String FORMAT = "format"; // public static final String HEADER = "header"; // public static final String SUFFIX = "suffix"; // public static final String PREFIX = "prefix"; // public static final String PATH_PROVIDER = "pathProvider"; // public static final String BROKER_LIST = "brokerList"; // public static final String GENDER = "gender"; // // } // Path: src/main/java/com/presidentio/testdatagenerator/output/AbstractEsSink.java import com.presidentio.testdatagenerator.cons.PropConst; import org.elasticsearch.client.Client; import org.elasticsearch.client.transport.TransportClient; import org.elasticsearch.common.settings.ImmutableSettings; import org.elasticsearch.common.transport.InetSocketTransportAddress; import java.util.Map; /** * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.presidentio.testdatagenerator.output; public abstract class AbstractEsSink extends AbstractBufferedSink { private Client client; @Override public void init(Map<String, String> props) {
String host = props.get(PropConst.HOST);
presidentio/test-data-generator
src/main/java/com/presidentio/testdatagenerator/provider/ParentProvider.java
// Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java // public class PropConst { // // public static final String TYPE = "type"; // public static final String VALUE = "value"; // public static final String SIZE = "size"; // public static final String DOMAIN = "domain"; // public static final String EXPR = "expr"; // public static final String FILE = "file"; // public static final String DELIMITER = "delimiter"; // public static final String ITEMS = "items"; // public static final String INDEX = "index"; // public static final String HOST = "host"; // public static final String PORT = "port"; // public static final String CLUSTER_NAME = "clusterName"; // public static final String CONNECTION_URL = "connectionUrl"; // public static final String JDBC_DRIVER = "jdbcDriver"; // public static final String DEPTH = "depth"; // public static final String FIELD = "field"; // public static final String VAR = "var"; // public static final String OP = "op"; // public static final String FORMAT = "format"; // public static final String HEADER = "header"; // public static final String SUFFIX = "suffix"; // public static final String PREFIX = "prefix"; // public static final String PATH_PROVIDER = "pathProvider"; // public static final String BROKER_LIST = "brokerList"; // public static final String GENDER = "gender"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java // public class Context { // // private Parent parent; // // private Map<String, Template> templates; // // private Map<String, Object> variables; // // private Sink sink; // // public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) { // this.templates = templates; // this.variables = variables; // this.sink = sink; // } // // public Context(Context parentContext, Map<String, Object> entity) { // parent = new Parent(entity, parentContext.getParent()); // templates = parentContext.getTemplates(); // variables = parentContext.getVariables(); // sink = parentContext.getSink(); // } // // public Parent getParent() { // return parent; // } // // public Map<String, Object> getVariables() { // return variables; // } // // public Sink getSink() { // return sink; // } // // public Map<String, Template> getTemplates() { // return templates; // } // // } // // Path: src/main/java/com/presidentio/testdatagenerator/context/Parent.java // public class Parent extends HashMap<String, Object> { // // private Parent parent; // // public Parent() { // } // // public Parent(Map<String, Object> entity, Parent parent) { // super(entity); // this.parent = parent; // } // // public Parent getParent() { // return parent; // } // // public void setParent(Parent parent) { // this.parent = parent; // } // } // // Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java // public class Field { // // private String name; // // private String type; // // private Provider provider; // // public Field() { // } // // public Field(String name, String type, Provider provider) { // this.name = name; // this.type = type; // this.provider = provider; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // public Provider getProvider() { // return provider; // } // // public void setProvider(Provider provider) { // this.provider = provider; // } // }
import com.presidentio.testdatagenerator.cons.PropConst; import com.presidentio.testdatagenerator.context.Context; import com.presidentio.testdatagenerator.context.Parent; import com.presidentio.testdatagenerator.model.Field; import java.util.Map;
/** * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.presidentio.testdatagenerator.provider; public class ParentProvider implements ValueProvider { private int depth = 1; private String field; @Override public void init(Map<String, String> props) {
// Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java // public class PropConst { // // public static final String TYPE = "type"; // public static final String VALUE = "value"; // public static final String SIZE = "size"; // public static final String DOMAIN = "domain"; // public static final String EXPR = "expr"; // public static final String FILE = "file"; // public static final String DELIMITER = "delimiter"; // public static final String ITEMS = "items"; // public static final String INDEX = "index"; // public static final String HOST = "host"; // public static final String PORT = "port"; // public static final String CLUSTER_NAME = "clusterName"; // public static final String CONNECTION_URL = "connectionUrl"; // public static final String JDBC_DRIVER = "jdbcDriver"; // public static final String DEPTH = "depth"; // public static final String FIELD = "field"; // public static final String VAR = "var"; // public static final String OP = "op"; // public static final String FORMAT = "format"; // public static final String HEADER = "header"; // public static final String SUFFIX = "suffix"; // public static final String PREFIX = "prefix"; // public static final String PATH_PROVIDER = "pathProvider"; // public static final String BROKER_LIST = "brokerList"; // public static final String GENDER = "gender"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java // public class Context { // // private Parent parent; // // private Map<String, Template> templates; // // private Map<String, Object> variables; // // private Sink sink; // // public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) { // this.templates = templates; // this.variables = variables; // this.sink = sink; // } // // public Context(Context parentContext, Map<String, Object> entity) { // parent = new Parent(entity, parentContext.getParent()); // templates = parentContext.getTemplates(); // variables = parentContext.getVariables(); // sink = parentContext.getSink(); // } // // public Parent getParent() { // return parent; // } // // public Map<String, Object> getVariables() { // return variables; // } // // public Sink getSink() { // return sink; // } // // public Map<String, Template> getTemplates() { // return templates; // } // // } // // Path: src/main/java/com/presidentio/testdatagenerator/context/Parent.java // public class Parent extends HashMap<String, Object> { // // private Parent parent; // // public Parent() { // } // // public Parent(Map<String, Object> entity, Parent parent) { // super(entity); // this.parent = parent; // } // // public Parent getParent() { // return parent; // } // // public void setParent(Parent parent) { // this.parent = parent; // } // } // // Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java // public class Field { // // private String name; // // private String type; // // private Provider provider; // // public Field() { // } // // public Field(String name, String type, Provider provider) { // this.name = name; // this.type = type; // this.provider = provider; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // public Provider getProvider() { // return provider; // } // // public void setProvider(Provider provider) { // this.provider = provider; // } // } // Path: src/main/java/com/presidentio/testdatagenerator/provider/ParentProvider.java import com.presidentio.testdatagenerator.cons.PropConst; import com.presidentio.testdatagenerator.context.Context; import com.presidentio.testdatagenerator.context.Parent; import com.presidentio.testdatagenerator.model.Field; import java.util.Map; /** * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.presidentio.testdatagenerator.provider; public class ParentProvider implements ValueProvider { private int depth = 1; private String field; @Override public void init(Map<String, String> props) {
if (props.containsKey(PropConst.DEPTH)) {
presidentio/test-data-generator
src/main/java/com/presidentio/testdatagenerator/provider/ParentProvider.java
// Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java // public class PropConst { // // public static final String TYPE = "type"; // public static final String VALUE = "value"; // public static final String SIZE = "size"; // public static final String DOMAIN = "domain"; // public static final String EXPR = "expr"; // public static final String FILE = "file"; // public static final String DELIMITER = "delimiter"; // public static final String ITEMS = "items"; // public static final String INDEX = "index"; // public static final String HOST = "host"; // public static final String PORT = "port"; // public static final String CLUSTER_NAME = "clusterName"; // public static final String CONNECTION_URL = "connectionUrl"; // public static final String JDBC_DRIVER = "jdbcDriver"; // public static final String DEPTH = "depth"; // public static final String FIELD = "field"; // public static final String VAR = "var"; // public static final String OP = "op"; // public static final String FORMAT = "format"; // public static final String HEADER = "header"; // public static final String SUFFIX = "suffix"; // public static final String PREFIX = "prefix"; // public static final String PATH_PROVIDER = "pathProvider"; // public static final String BROKER_LIST = "brokerList"; // public static final String GENDER = "gender"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java // public class Context { // // private Parent parent; // // private Map<String, Template> templates; // // private Map<String, Object> variables; // // private Sink sink; // // public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) { // this.templates = templates; // this.variables = variables; // this.sink = sink; // } // // public Context(Context parentContext, Map<String, Object> entity) { // parent = new Parent(entity, parentContext.getParent()); // templates = parentContext.getTemplates(); // variables = parentContext.getVariables(); // sink = parentContext.getSink(); // } // // public Parent getParent() { // return parent; // } // // public Map<String, Object> getVariables() { // return variables; // } // // public Sink getSink() { // return sink; // } // // public Map<String, Template> getTemplates() { // return templates; // } // // } // // Path: src/main/java/com/presidentio/testdatagenerator/context/Parent.java // public class Parent extends HashMap<String, Object> { // // private Parent parent; // // public Parent() { // } // // public Parent(Map<String, Object> entity, Parent parent) { // super(entity); // this.parent = parent; // } // // public Parent getParent() { // return parent; // } // // public void setParent(Parent parent) { // this.parent = parent; // } // } // // Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java // public class Field { // // private String name; // // private String type; // // private Provider provider; // // public Field() { // } // // public Field(String name, String type, Provider provider) { // this.name = name; // this.type = type; // this.provider = provider; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // public Provider getProvider() { // return provider; // } // // public void setProvider(Provider provider) { // this.provider = provider; // } // }
import com.presidentio.testdatagenerator.cons.PropConst; import com.presidentio.testdatagenerator.context.Context; import com.presidentio.testdatagenerator.context.Parent; import com.presidentio.testdatagenerator.model.Field; import java.util.Map;
/** * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.presidentio.testdatagenerator.provider; public class ParentProvider implements ValueProvider { private int depth = 1; private String field; @Override public void init(Map<String, String> props) { if (props.containsKey(PropConst.DEPTH)) { depth = Integer.valueOf(props.get(PropConst.DEPTH)); } field = props.get(PropConst.FIELD); if (field == null) { throw new IllegalArgumentException("Field does not specified or null"); } } @Override
// Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java // public class PropConst { // // public static final String TYPE = "type"; // public static final String VALUE = "value"; // public static final String SIZE = "size"; // public static final String DOMAIN = "domain"; // public static final String EXPR = "expr"; // public static final String FILE = "file"; // public static final String DELIMITER = "delimiter"; // public static final String ITEMS = "items"; // public static final String INDEX = "index"; // public static final String HOST = "host"; // public static final String PORT = "port"; // public static final String CLUSTER_NAME = "clusterName"; // public static final String CONNECTION_URL = "connectionUrl"; // public static final String JDBC_DRIVER = "jdbcDriver"; // public static final String DEPTH = "depth"; // public static final String FIELD = "field"; // public static final String VAR = "var"; // public static final String OP = "op"; // public static final String FORMAT = "format"; // public static final String HEADER = "header"; // public static final String SUFFIX = "suffix"; // public static final String PREFIX = "prefix"; // public static final String PATH_PROVIDER = "pathProvider"; // public static final String BROKER_LIST = "brokerList"; // public static final String GENDER = "gender"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java // public class Context { // // private Parent parent; // // private Map<String, Template> templates; // // private Map<String, Object> variables; // // private Sink sink; // // public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) { // this.templates = templates; // this.variables = variables; // this.sink = sink; // } // // public Context(Context parentContext, Map<String, Object> entity) { // parent = new Parent(entity, parentContext.getParent()); // templates = parentContext.getTemplates(); // variables = parentContext.getVariables(); // sink = parentContext.getSink(); // } // // public Parent getParent() { // return parent; // } // // public Map<String, Object> getVariables() { // return variables; // } // // public Sink getSink() { // return sink; // } // // public Map<String, Template> getTemplates() { // return templates; // } // // } // // Path: src/main/java/com/presidentio/testdatagenerator/context/Parent.java // public class Parent extends HashMap<String, Object> { // // private Parent parent; // // public Parent() { // } // // public Parent(Map<String, Object> entity, Parent parent) { // super(entity); // this.parent = parent; // } // // public Parent getParent() { // return parent; // } // // public void setParent(Parent parent) { // this.parent = parent; // } // } // // Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java // public class Field { // // private String name; // // private String type; // // private Provider provider; // // public Field() { // } // // public Field(String name, String type, Provider provider) { // this.name = name; // this.type = type; // this.provider = provider; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // public Provider getProvider() { // return provider; // } // // public void setProvider(Provider provider) { // this.provider = provider; // } // } // Path: src/main/java/com/presidentio/testdatagenerator/provider/ParentProvider.java import com.presidentio.testdatagenerator.cons.PropConst; import com.presidentio.testdatagenerator.context.Context; import com.presidentio.testdatagenerator.context.Parent; import com.presidentio.testdatagenerator.model.Field; import java.util.Map; /** * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.presidentio.testdatagenerator.provider; public class ParentProvider implements ValueProvider { private int depth = 1; private String field; @Override public void init(Map<String, String> props) { if (props.containsKey(PropConst.DEPTH)) { depth = Integer.valueOf(props.get(PropConst.DEPTH)); } field = props.get(PropConst.FIELD); if (field == null) { throw new IllegalArgumentException("Field does not specified or null"); } } @Override
public Object nextValue(Context context, Field field) {
presidentio/test-data-generator
src/main/java/com/presidentio/testdatagenerator/provider/ParentProvider.java
// Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java // public class PropConst { // // public static final String TYPE = "type"; // public static final String VALUE = "value"; // public static final String SIZE = "size"; // public static final String DOMAIN = "domain"; // public static final String EXPR = "expr"; // public static final String FILE = "file"; // public static final String DELIMITER = "delimiter"; // public static final String ITEMS = "items"; // public static final String INDEX = "index"; // public static final String HOST = "host"; // public static final String PORT = "port"; // public static final String CLUSTER_NAME = "clusterName"; // public static final String CONNECTION_URL = "connectionUrl"; // public static final String JDBC_DRIVER = "jdbcDriver"; // public static final String DEPTH = "depth"; // public static final String FIELD = "field"; // public static final String VAR = "var"; // public static final String OP = "op"; // public static final String FORMAT = "format"; // public static final String HEADER = "header"; // public static final String SUFFIX = "suffix"; // public static final String PREFIX = "prefix"; // public static final String PATH_PROVIDER = "pathProvider"; // public static final String BROKER_LIST = "brokerList"; // public static final String GENDER = "gender"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java // public class Context { // // private Parent parent; // // private Map<String, Template> templates; // // private Map<String, Object> variables; // // private Sink sink; // // public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) { // this.templates = templates; // this.variables = variables; // this.sink = sink; // } // // public Context(Context parentContext, Map<String, Object> entity) { // parent = new Parent(entity, parentContext.getParent()); // templates = parentContext.getTemplates(); // variables = parentContext.getVariables(); // sink = parentContext.getSink(); // } // // public Parent getParent() { // return parent; // } // // public Map<String, Object> getVariables() { // return variables; // } // // public Sink getSink() { // return sink; // } // // public Map<String, Template> getTemplates() { // return templates; // } // // } // // Path: src/main/java/com/presidentio/testdatagenerator/context/Parent.java // public class Parent extends HashMap<String, Object> { // // private Parent parent; // // public Parent() { // } // // public Parent(Map<String, Object> entity, Parent parent) { // super(entity); // this.parent = parent; // } // // public Parent getParent() { // return parent; // } // // public void setParent(Parent parent) { // this.parent = parent; // } // } // // Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java // public class Field { // // private String name; // // private String type; // // private Provider provider; // // public Field() { // } // // public Field(String name, String type, Provider provider) { // this.name = name; // this.type = type; // this.provider = provider; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // public Provider getProvider() { // return provider; // } // // public void setProvider(Provider provider) { // this.provider = provider; // } // }
import com.presidentio.testdatagenerator.cons.PropConst; import com.presidentio.testdatagenerator.context.Context; import com.presidentio.testdatagenerator.context.Parent; import com.presidentio.testdatagenerator.model.Field; import java.util.Map;
/** * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.presidentio.testdatagenerator.provider; public class ParentProvider implements ValueProvider { private int depth = 1; private String field; @Override public void init(Map<String, String> props) { if (props.containsKey(PropConst.DEPTH)) { depth = Integer.valueOf(props.get(PropConst.DEPTH)); } field = props.get(PropConst.FIELD); if (field == null) { throw new IllegalArgumentException("Field does not specified or null"); } } @Override
// Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java // public class PropConst { // // public static final String TYPE = "type"; // public static final String VALUE = "value"; // public static final String SIZE = "size"; // public static final String DOMAIN = "domain"; // public static final String EXPR = "expr"; // public static final String FILE = "file"; // public static final String DELIMITER = "delimiter"; // public static final String ITEMS = "items"; // public static final String INDEX = "index"; // public static final String HOST = "host"; // public static final String PORT = "port"; // public static final String CLUSTER_NAME = "clusterName"; // public static final String CONNECTION_URL = "connectionUrl"; // public static final String JDBC_DRIVER = "jdbcDriver"; // public static final String DEPTH = "depth"; // public static final String FIELD = "field"; // public static final String VAR = "var"; // public static final String OP = "op"; // public static final String FORMAT = "format"; // public static final String HEADER = "header"; // public static final String SUFFIX = "suffix"; // public static final String PREFIX = "prefix"; // public static final String PATH_PROVIDER = "pathProvider"; // public static final String BROKER_LIST = "brokerList"; // public static final String GENDER = "gender"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java // public class Context { // // private Parent parent; // // private Map<String, Template> templates; // // private Map<String, Object> variables; // // private Sink sink; // // public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) { // this.templates = templates; // this.variables = variables; // this.sink = sink; // } // // public Context(Context parentContext, Map<String, Object> entity) { // parent = new Parent(entity, parentContext.getParent()); // templates = parentContext.getTemplates(); // variables = parentContext.getVariables(); // sink = parentContext.getSink(); // } // // public Parent getParent() { // return parent; // } // // public Map<String, Object> getVariables() { // return variables; // } // // public Sink getSink() { // return sink; // } // // public Map<String, Template> getTemplates() { // return templates; // } // // } // // Path: src/main/java/com/presidentio/testdatagenerator/context/Parent.java // public class Parent extends HashMap<String, Object> { // // private Parent parent; // // public Parent() { // } // // public Parent(Map<String, Object> entity, Parent parent) { // super(entity); // this.parent = parent; // } // // public Parent getParent() { // return parent; // } // // public void setParent(Parent parent) { // this.parent = parent; // } // } // // Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java // public class Field { // // private String name; // // private String type; // // private Provider provider; // // public Field() { // } // // public Field(String name, String type, Provider provider) { // this.name = name; // this.type = type; // this.provider = provider; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // public Provider getProvider() { // return provider; // } // // public void setProvider(Provider provider) { // this.provider = provider; // } // } // Path: src/main/java/com/presidentio/testdatagenerator/provider/ParentProvider.java import com.presidentio.testdatagenerator.cons.PropConst; import com.presidentio.testdatagenerator.context.Context; import com.presidentio.testdatagenerator.context.Parent; import com.presidentio.testdatagenerator.model.Field; import java.util.Map; /** * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.presidentio.testdatagenerator.provider; public class ParentProvider implements ValueProvider { private int depth = 1; private String field; @Override public void init(Map<String, String> props) { if (props.containsKey(PropConst.DEPTH)) { depth = Integer.valueOf(props.get(PropConst.DEPTH)); } field = props.get(PropConst.FIELD); if (field == null) { throw new IllegalArgumentException("Field does not specified or null"); } } @Override
public Object nextValue(Context context, Field field) {
presidentio/test-data-generator
src/main/java/com/presidentio/testdatagenerator/provider/ParentProvider.java
// Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java // public class PropConst { // // public static final String TYPE = "type"; // public static final String VALUE = "value"; // public static final String SIZE = "size"; // public static final String DOMAIN = "domain"; // public static final String EXPR = "expr"; // public static final String FILE = "file"; // public static final String DELIMITER = "delimiter"; // public static final String ITEMS = "items"; // public static final String INDEX = "index"; // public static final String HOST = "host"; // public static final String PORT = "port"; // public static final String CLUSTER_NAME = "clusterName"; // public static final String CONNECTION_URL = "connectionUrl"; // public static final String JDBC_DRIVER = "jdbcDriver"; // public static final String DEPTH = "depth"; // public static final String FIELD = "field"; // public static final String VAR = "var"; // public static final String OP = "op"; // public static final String FORMAT = "format"; // public static final String HEADER = "header"; // public static final String SUFFIX = "suffix"; // public static final String PREFIX = "prefix"; // public static final String PATH_PROVIDER = "pathProvider"; // public static final String BROKER_LIST = "brokerList"; // public static final String GENDER = "gender"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java // public class Context { // // private Parent parent; // // private Map<String, Template> templates; // // private Map<String, Object> variables; // // private Sink sink; // // public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) { // this.templates = templates; // this.variables = variables; // this.sink = sink; // } // // public Context(Context parentContext, Map<String, Object> entity) { // parent = new Parent(entity, parentContext.getParent()); // templates = parentContext.getTemplates(); // variables = parentContext.getVariables(); // sink = parentContext.getSink(); // } // // public Parent getParent() { // return parent; // } // // public Map<String, Object> getVariables() { // return variables; // } // // public Sink getSink() { // return sink; // } // // public Map<String, Template> getTemplates() { // return templates; // } // // } // // Path: src/main/java/com/presidentio/testdatagenerator/context/Parent.java // public class Parent extends HashMap<String, Object> { // // private Parent parent; // // public Parent() { // } // // public Parent(Map<String, Object> entity, Parent parent) { // super(entity); // this.parent = parent; // } // // public Parent getParent() { // return parent; // } // // public void setParent(Parent parent) { // this.parent = parent; // } // } // // Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java // public class Field { // // private String name; // // private String type; // // private Provider provider; // // public Field() { // } // // public Field(String name, String type, Provider provider) { // this.name = name; // this.type = type; // this.provider = provider; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // public Provider getProvider() { // return provider; // } // // public void setProvider(Provider provider) { // this.provider = provider; // } // }
import com.presidentio.testdatagenerator.cons.PropConst; import com.presidentio.testdatagenerator.context.Context; import com.presidentio.testdatagenerator.context.Parent; import com.presidentio.testdatagenerator.model.Field; import java.util.Map;
/** * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.presidentio.testdatagenerator.provider; public class ParentProvider implements ValueProvider { private int depth = 1; private String field; @Override public void init(Map<String, String> props) { if (props.containsKey(PropConst.DEPTH)) { depth = Integer.valueOf(props.get(PropConst.DEPTH)); } field = props.get(PropConst.FIELD); if (field == null) { throw new IllegalArgumentException("Field does not specified or null"); } } @Override public Object nextValue(Context context, Field field) {
// Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java // public class PropConst { // // public static final String TYPE = "type"; // public static final String VALUE = "value"; // public static final String SIZE = "size"; // public static final String DOMAIN = "domain"; // public static final String EXPR = "expr"; // public static final String FILE = "file"; // public static final String DELIMITER = "delimiter"; // public static final String ITEMS = "items"; // public static final String INDEX = "index"; // public static final String HOST = "host"; // public static final String PORT = "port"; // public static final String CLUSTER_NAME = "clusterName"; // public static final String CONNECTION_URL = "connectionUrl"; // public static final String JDBC_DRIVER = "jdbcDriver"; // public static final String DEPTH = "depth"; // public static final String FIELD = "field"; // public static final String VAR = "var"; // public static final String OP = "op"; // public static final String FORMAT = "format"; // public static final String HEADER = "header"; // public static final String SUFFIX = "suffix"; // public static final String PREFIX = "prefix"; // public static final String PATH_PROVIDER = "pathProvider"; // public static final String BROKER_LIST = "brokerList"; // public static final String GENDER = "gender"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java // public class Context { // // private Parent parent; // // private Map<String, Template> templates; // // private Map<String, Object> variables; // // private Sink sink; // // public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) { // this.templates = templates; // this.variables = variables; // this.sink = sink; // } // // public Context(Context parentContext, Map<String, Object> entity) { // parent = new Parent(entity, parentContext.getParent()); // templates = parentContext.getTemplates(); // variables = parentContext.getVariables(); // sink = parentContext.getSink(); // } // // public Parent getParent() { // return parent; // } // // public Map<String, Object> getVariables() { // return variables; // } // // public Sink getSink() { // return sink; // } // // public Map<String, Template> getTemplates() { // return templates; // } // // } // // Path: src/main/java/com/presidentio/testdatagenerator/context/Parent.java // public class Parent extends HashMap<String, Object> { // // private Parent parent; // // public Parent() { // } // // public Parent(Map<String, Object> entity, Parent parent) { // super(entity); // this.parent = parent; // } // // public Parent getParent() { // return parent; // } // // public void setParent(Parent parent) { // this.parent = parent; // } // } // // Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java // public class Field { // // private String name; // // private String type; // // private Provider provider; // // public Field() { // } // // public Field(String name, String type, Provider provider) { // this.name = name; // this.type = type; // this.provider = provider; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // public Provider getProvider() { // return provider; // } // // public void setProvider(Provider provider) { // this.provider = provider; // } // } // Path: src/main/java/com/presidentio/testdatagenerator/provider/ParentProvider.java import com.presidentio.testdatagenerator.cons.PropConst; import com.presidentio.testdatagenerator.context.Context; import com.presidentio.testdatagenerator.context.Parent; import com.presidentio.testdatagenerator.model.Field; import java.util.Map; /** * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.presidentio.testdatagenerator.provider; public class ParentProvider implements ValueProvider { private int depth = 1; private String field; @Override public void init(Map<String, String> props) { if (props.containsKey(PropConst.DEPTH)) { depth = Integer.valueOf(props.get(PropConst.DEPTH)); } field = props.get(PropConst.FIELD); if (field == null) { throw new IllegalArgumentException("Field does not specified or null"); } } @Override public Object nextValue(Context context, Field field) {
Parent parent = context.getParent();
presidentio/test-data-generator
src/main/java/com/presidentio/testdatagenerator/provider/SelectProvider.java
// Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java // public class PropConst { // // public static final String TYPE = "type"; // public static final String VALUE = "value"; // public static final String SIZE = "size"; // public static final String DOMAIN = "domain"; // public static final String EXPR = "expr"; // public static final String FILE = "file"; // public static final String DELIMITER = "delimiter"; // public static final String ITEMS = "items"; // public static final String INDEX = "index"; // public static final String HOST = "host"; // public static final String PORT = "port"; // public static final String CLUSTER_NAME = "clusterName"; // public static final String CONNECTION_URL = "connectionUrl"; // public static final String JDBC_DRIVER = "jdbcDriver"; // public static final String DEPTH = "depth"; // public static final String FIELD = "field"; // public static final String VAR = "var"; // public static final String OP = "op"; // public static final String FORMAT = "format"; // public static final String HEADER = "header"; // public static final String SUFFIX = "suffix"; // public static final String PREFIX = "prefix"; // public static final String PATH_PROVIDER = "pathProvider"; // public static final String BROKER_LIST = "brokerList"; // public static final String GENDER = "gender"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java // public class Context { // // private Parent parent; // // private Map<String, Template> templates; // // private Map<String, Object> variables; // // private Sink sink; // // public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) { // this.templates = templates; // this.variables = variables; // this.sink = sink; // } // // public Context(Context parentContext, Map<String, Object> entity) { // parent = new Parent(entity, parentContext.getParent()); // templates = parentContext.getTemplates(); // variables = parentContext.getVariables(); // sink = parentContext.getSink(); // } // // public Parent getParent() { // return parent; // } // // public Map<String, Object> getVariables() { // return variables; // } // // public Sink getSink() { // return sink; // } // // public Map<String, Template> getTemplates() { // return templates; // } // // } // // Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java // public class Field { // // private String name; // // private String type; // // private Provider provider; // // public Field() { // } // // public Field(String name, String type, Provider provider) { // this.name = name; // this.type = type; // this.provider = provider; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // public Provider getProvider() { // return provider; // } // // public void setProvider(Provider provider) { // this.provider = provider; // } // }
import com.presidentio.testdatagenerator.cons.PropConst; import com.presidentio.testdatagenerator.context.Context; import com.presidentio.testdatagenerator.model.Field; import java.util.HashMap; import java.util.Map; import java.util.Random;
/** * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.presidentio.testdatagenerator.provider; public class SelectProvider implements ValueProvider { private String[] items; private String delimiter = ","; private Random random = new Random(); @Override public void init(Map<String, String> props) { Map<String, String> propsCopy = new HashMap<>(props);
// Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java // public class PropConst { // // public static final String TYPE = "type"; // public static final String VALUE = "value"; // public static final String SIZE = "size"; // public static final String DOMAIN = "domain"; // public static final String EXPR = "expr"; // public static final String FILE = "file"; // public static final String DELIMITER = "delimiter"; // public static final String ITEMS = "items"; // public static final String INDEX = "index"; // public static final String HOST = "host"; // public static final String PORT = "port"; // public static final String CLUSTER_NAME = "clusterName"; // public static final String CONNECTION_URL = "connectionUrl"; // public static final String JDBC_DRIVER = "jdbcDriver"; // public static final String DEPTH = "depth"; // public static final String FIELD = "field"; // public static final String VAR = "var"; // public static final String OP = "op"; // public static final String FORMAT = "format"; // public static final String HEADER = "header"; // public static final String SUFFIX = "suffix"; // public static final String PREFIX = "prefix"; // public static final String PATH_PROVIDER = "pathProvider"; // public static final String BROKER_LIST = "brokerList"; // public static final String GENDER = "gender"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java // public class Context { // // private Parent parent; // // private Map<String, Template> templates; // // private Map<String, Object> variables; // // private Sink sink; // // public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) { // this.templates = templates; // this.variables = variables; // this.sink = sink; // } // // public Context(Context parentContext, Map<String, Object> entity) { // parent = new Parent(entity, parentContext.getParent()); // templates = parentContext.getTemplates(); // variables = parentContext.getVariables(); // sink = parentContext.getSink(); // } // // public Parent getParent() { // return parent; // } // // public Map<String, Object> getVariables() { // return variables; // } // // public Sink getSink() { // return sink; // } // // public Map<String, Template> getTemplates() { // return templates; // } // // } // // Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java // public class Field { // // private String name; // // private String type; // // private Provider provider; // // public Field() { // } // // public Field(String name, String type, Provider provider) { // this.name = name; // this.type = type; // this.provider = provider; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // public Provider getProvider() { // return provider; // } // // public void setProvider(Provider provider) { // this.provider = provider; // } // } // Path: src/main/java/com/presidentio/testdatagenerator/provider/SelectProvider.java import com.presidentio.testdatagenerator.cons.PropConst; import com.presidentio.testdatagenerator.context.Context; import com.presidentio.testdatagenerator.model.Field; import java.util.HashMap; import java.util.Map; import java.util.Random; /** * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.presidentio.testdatagenerator.provider; public class SelectProvider implements ValueProvider { private String[] items; private String delimiter = ","; private Random random = new Random(); @Override public void init(Map<String, String> props) { Map<String, String> propsCopy = new HashMap<>(props);
if (propsCopy.containsKey(PropConst.DELIMITER)) {
presidentio/test-data-generator
src/main/java/com/presidentio/testdatagenerator/provider/SelectProvider.java
// Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java // public class PropConst { // // public static final String TYPE = "type"; // public static final String VALUE = "value"; // public static final String SIZE = "size"; // public static final String DOMAIN = "domain"; // public static final String EXPR = "expr"; // public static final String FILE = "file"; // public static final String DELIMITER = "delimiter"; // public static final String ITEMS = "items"; // public static final String INDEX = "index"; // public static final String HOST = "host"; // public static final String PORT = "port"; // public static final String CLUSTER_NAME = "clusterName"; // public static final String CONNECTION_URL = "connectionUrl"; // public static final String JDBC_DRIVER = "jdbcDriver"; // public static final String DEPTH = "depth"; // public static final String FIELD = "field"; // public static final String VAR = "var"; // public static final String OP = "op"; // public static final String FORMAT = "format"; // public static final String HEADER = "header"; // public static final String SUFFIX = "suffix"; // public static final String PREFIX = "prefix"; // public static final String PATH_PROVIDER = "pathProvider"; // public static final String BROKER_LIST = "brokerList"; // public static final String GENDER = "gender"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java // public class Context { // // private Parent parent; // // private Map<String, Template> templates; // // private Map<String, Object> variables; // // private Sink sink; // // public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) { // this.templates = templates; // this.variables = variables; // this.sink = sink; // } // // public Context(Context parentContext, Map<String, Object> entity) { // parent = new Parent(entity, parentContext.getParent()); // templates = parentContext.getTemplates(); // variables = parentContext.getVariables(); // sink = parentContext.getSink(); // } // // public Parent getParent() { // return parent; // } // // public Map<String, Object> getVariables() { // return variables; // } // // public Sink getSink() { // return sink; // } // // public Map<String, Template> getTemplates() { // return templates; // } // // } // // Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java // public class Field { // // private String name; // // private String type; // // private Provider provider; // // public Field() { // } // // public Field(String name, String type, Provider provider) { // this.name = name; // this.type = type; // this.provider = provider; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // public Provider getProvider() { // return provider; // } // // public void setProvider(Provider provider) { // this.provider = provider; // } // }
import com.presidentio.testdatagenerator.cons.PropConst; import com.presidentio.testdatagenerator.context.Context; import com.presidentio.testdatagenerator.model.Field; import java.util.HashMap; import java.util.Map; import java.util.Random;
/** * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.presidentio.testdatagenerator.provider; public class SelectProvider implements ValueProvider { private String[] items; private String delimiter = ","; private Random random = new Random(); @Override public void init(Map<String, String> props) { Map<String, String> propsCopy = new HashMap<>(props); if (propsCopy.containsKey(PropConst.DELIMITER)) { delimiter = propsCopy.remove(PropConst.DELIMITER); } String items = propsCopy.remove(PropConst.ITEMS); if (items == null) { throw new IllegalArgumentException("Items does not specified or null"); } this.items = items.split(delimiter); if (this.items.length <= 0) { throw new IllegalArgumentException("Items are empty"); } if (!propsCopy.isEmpty()) { throw new IllegalArgumentException("Redundant props for RandomProvider: " + propsCopy); } } @Override
// Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java // public class PropConst { // // public static final String TYPE = "type"; // public static final String VALUE = "value"; // public static final String SIZE = "size"; // public static final String DOMAIN = "domain"; // public static final String EXPR = "expr"; // public static final String FILE = "file"; // public static final String DELIMITER = "delimiter"; // public static final String ITEMS = "items"; // public static final String INDEX = "index"; // public static final String HOST = "host"; // public static final String PORT = "port"; // public static final String CLUSTER_NAME = "clusterName"; // public static final String CONNECTION_URL = "connectionUrl"; // public static final String JDBC_DRIVER = "jdbcDriver"; // public static final String DEPTH = "depth"; // public static final String FIELD = "field"; // public static final String VAR = "var"; // public static final String OP = "op"; // public static final String FORMAT = "format"; // public static final String HEADER = "header"; // public static final String SUFFIX = "suffix"; // public static final String PREFIX = "prefix"; // public static final String PATH_PROVIDER = "pathProvider"; // public static final String BROKER_LIST = "brokerList"; // public static final String GENDER = "gender"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java // public class Context { // // private Parent parent; // // private Map<String, Template> templates; // // private Map<String, Object> variables; // // private Sink sink; // // public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) { // this.templates = templates; // this.variables = variables; // this.sink = sink; // } // // public Context(Context parentContext, Map<String, Object> entity) { // parent = new Parent(entity, parentContext.getParent()); // templates = parentContext.getTemplates(); // variables = parentContext.getVariables(); // sink = parentContext.getSink(); // } // // public Parent getParent() { // return parent; // } // // public Map<String, Object> getVariables() { // return variables; // } // // public Sink getSink() { // return sink; // } // // public Map<String, Template> getTemplates() { // return templates; // } // // } // // Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java // public class Field { // // private String name; // // private String type; // // private Provider provider; // // public Field() { // } // // public Field(String name, String type, Provider provider) { // this.name = name; // this.type = type; // this.provider = provider; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // public Provider getProvider() { // return provider; // } // // public void setProvider(Provider provider) { // this.provider = provider; // } // } // Path: src/main/java/com/presidentio/testdatagenerator/provider/SelectProvider.java import com.presidentio.testdatagenerator.cons.PropConst; import com.presidentio.testdatagenerator.context.Context; import com.presidentio.testdatagenerator.model.Field; import java.util.HashMap; import java.util.Map; import java.util.Random; /** * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.presidentio.testdatagenerator.provider; public class SelectProvider implements ValueProvider { private String[] items; private String delimiter = ","; private Random random = new Random(); @Override public void init(Map<String, String> props) { Map<String, String> propsCopy = new HashMap<>(props); if (propsCopy.containsKey(PropConst.DELIMITER)) { delimiter = propsCopy.remove(PropConst.DELIMITER); } String items = propsCopy.remove(PropConst.ITEMS); if (items == null) { throw new IllegalArgumentException("Items does not specified or null"); } this.items = items.split(delimiter); if (this.items.length <= 0) { throw new IllegalArgumentException("Items are empty"); } if (!propsCopy.isEmpty()) { throw new IllegalArgumentException("Redundant props for RandomProvider: " + propsCopy); } } @Override
public Object nextValue(Context context, Field field) {
presidentio/test-data-generator
src/main/java/com/presidentio/testdatagenerator/provider/SelectProvider.java
// Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java // public class PropConst { // // public static final String TYPE = "type"; // public static final String VALUE = "value"; // public static final String SIZE = "size"; // public static final String DOMAIN = "domain"; // public static final String EXPR = "expr"; // public static final String FILE = "file"; // public static final String DELIMITER = "delimiter"; // public static final String ITEMS = "items"; // public static final String INDEX = "index"; // public static final String HOST = "host"; // public static final String PORT = "port"; // public static final String CLUSTER_NAME = "clusterName"; // public static final String CONNECTION_URL = "connectionUrl"; // public static final String JDBC_DRIVER = "jdbcDriver"; // public static final String DEPTH = "depth"; // public static final String FIELD = "field"; // public static final String VAR = "var"; // public static final String OP = "op"; // public static final String FORMAT = "format"; // public static final String HEADER = "header"; // public static final String SUFFIX = "suffix"; // public static final String PREFIX = "prefix"; // public static final String PATH_PROVIDER = "pathProvider"; // public static final String BROKER_LIST = "brokerList"; // public static final String GENDER = "gender"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java // public class Context { // // private Parent parent; // // private Map<String, Template> templates; // // private Map<String, Object> variables; // // private Sink sink; // // public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) { // this.templates = templates; // this.variables = variables; // this.sink = sink; // } // // public Context(Context parentContext, Map<String, Object> entity) { // parent = new Parent(entity, parentContext.getParent()); // templates = parentContext.getTemplates(); // variables = parentContext.getVariables(); // sink = parentContext.getSink(); // } // // public Parent getParent() { // return parent; // } // // public Map<String, Object> getVariables() { // return variables; // } // // public Sink getSink() { // return sink; // } // // public Map<String, Template> getTemplates() { // return templates; // } // // } // // Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java // public class Field { // // private String name; // // private String type; // // private Provider provider; // // public Field() { // } // // public Field(String name, String type, Provider provider) { // this.name = name; // this.type = type; // this.provider = provider; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // public Provider getProvider() { // return provider; // } // // public void setProvider(Provider provider) { // this.provider = provider; // } // }
import com.presidentio.testdatagenerator.cons.PropConst; import com.presidentio.testdatagenerator.context.Context; import com.presidentio.testdatagenerator.model.Field; import java.util.HashMap; import java.util.Map; import java.util.Random;
/** * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.presidentio.testdatagenerator.provider; public class SelectProvider implements ValueProvider { private String[] items; private String delimiter = ","; private Random random = new Random(); @Override public void init(Map<String, String> props) { Map<String, String> propsCopy = new HashMap<>(props); if (propsCopy.containsKey(PropConst.DELIMITER)) { delimiter = propsCopy.remove(PropConst.DELIMITER); } String items = propsCopy.remove(PropConst.ITEMS); if (items == null) { throw new IllegalArgumentException("Items does not specified or null"); } this.items = items.split(delimiter); if (this.items.length <= 0) { throw new IllegalArgumentException("Items are empty"); } if (!propsCopy.isEmpty()) { throw new IllegalArgumentException("Redundant props for RandomProvider: " + propsCopy); } } @Override
// Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java // public class PropConst { // // public static final String TYPE = "type"; // public static final String VALUE = "value"; // public static final String SIZE = "size"; // public static final String DOMAIN = "domain"; // public static final String EXPR = "expr"; // public static final String FILE = "file"; // public static final String DELIMITER = "delimiter"; // public static final String ITEMS = "items"; // public static final String INDEX = "index"; // public static final String HOST = "host"; // public static final String PORT = "port"; // public static final String CLUSTER_NAME = "clusterName"; // public static final String CONNECTION_URL = "connectionUrl"; // public static final String JDBC_DRIVER = "jdbcDriver"; // public static final String DEPTH = "depth"; // public static final String FIELD = "field"; // public static final String VAR = "var"; // public static final String OP = "op"; // public static final String FORMAT = "format"; // public static final String HEADER = "header"; // public static final String SUFFIX = "suffix"; // public static final String PREFIX = "prefix"; // public static final String PATH_PROVIDER = "pathProvider"; // public static final String BROKER_LIST = "brokerList"; // public static final String GENDER = "gender"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java // public class Context { // // private Parent parent; // // private Map<String, Template> templates; // // private Map<String, Object> variables; // // private Sink sink; // // public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) { // this.templates = templates; // this.variables = variables; // this.sink = sink; // } // // public Context(Context parentContext, Map<String, Object> entity) { // parent = new Parent(entity, parentContext.getParent()); // templates = parentContext.getTemplates(); // variables = parentContext.getVariables(); // sink = parentContext.getSink(); // } // // public Parent getParent() { // return parent; // } // // public Map<String, Object> getVariables() { // return variables; // } // // public Sink getSink() { // return sink; // } // // public Map<String, Template> getTemplates() { // return templates; // } // // } // // Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java // public class Field { // // private String name; // // private String type; // // private Provider provider; // // public Field() { // } // // public Field(String name, String type, Provider provider) { // this.name = name; // this.type = type; // this.provider = provider; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // public Provider getProvider() { // return provider; // } // // public void setProvider(Provider provider) { // this.provider = provider; // } // } // Path: src/main/java/com/presidentio/testdatagenerator/provider/SelectProvider.java import com.presidentio.testdatagenerator.cons.PropConst; import com.presidentio.testdatagenerator.context.Context; import com.presidentio.testdatagenerator.model.Field; import java.util.HashMap; import java.util.Map; import java.util.Random; /** * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.presidentio.testdatagenerator.provider; public class SelectProvider implements ValueProvider { private String[] items; private String delimiter = ","; private Random random = new Random(); @Override public void init(Map<String, String> props) { Map<String, String> propsCopy = new HashMap<>(props); if (propsCopy.containsKey(PropConst.DELIMITER)) { delimiter = propsCopy.remove(PropConst.DELIMITER); } String items = propsCopy.remove(PropConst.ITEMS); if (items == null) { throw new IllegalArgumentException("Items does not specified or null"); } this.items = items.split(delimiter); if (this.items.length <= 0) { throw new IllegalArgumentException("Items are empty"); } if (!propsCopy.isEmpty()) { throw new IllegalArgumentException("Redundant props for RandomProvider: " + propsCopy); } } @Override
public Object nextValue(Context context, Field field) {
presidentio/test-data-generator
src/test/java/com/presidentio/testdatagenerator/CsvFileTest.java
// Path: src/main/java/com/presidentio/testdatagenerator/model/Output.java // public class Output { // // private String type; // // @JsonDeserialize(contentUsing = StringDeserializer.class) // private Map<String, String> props; // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // public Map<String, String> getProps() { // return props; // } // // public void setProps(Map<String, String> props) { // this.props = props; // } // }
import com.presidentio.testdatagenerator.model.Output; import org.apache.commons.io.IOUtils; import org.junit.Assert; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.util.Arrays; import java.util.List;
/** * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * <p> * http://www.apache.org/licenses/LICENSE-2.0 * <p> * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.presidentio.testdatagenerator; public class CsvFileTest extends AbstractGeneratorTest { @Override protected List<String> getSchemaResource() { return Arrays.asList("test-csv-file-schema.json"); } @Override
// Path: src/main/java/com/presidentio/testdatagenerator/model/Output.java // public class Output { // // private String type; // // @JsonDeserialize(contentUsing = StringDeserializer.class) // private Map<String, String> props; // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // public Map<String, String> getProps() { // return props; // } // // public void setProps(Map<String, String> props) { // this.props = props; // } // } // Path: src/test/java/com/presidentio/testdatagenerator/CsvFileTest.java import com.presidentio.testdatagenerator.model.Output; import org.apache.commons.io.IOUtils; import org.junit.Assert; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.util.Arrays; import java.util.List; /** * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * <p> * http://www.apache.org/licenses/LICENSE-2.0 * <p> * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.presidentio.testdatagenerator; public class CsvFileTest extends AbstractGeneratorTest { @Override protected List<String> getSchemaResource() { return Arrays.asList("test-csv-file-schema.json"); } @Override
protected void testResult(Output output) {
presidentio/test-data-generator
src/main/java/com/presidentio/testdatagenerator/output/formatter/Formatter.java
// Path: src/main/java/com/presidentio/testdatagenerator/model/Template.java // public class Template { // // private String id; // // private String extend; // // @JsonIgnore // private Template extendTemplate; // // private Integer count; // // private String name; // // private List<Field> fields; // // private List<String> childs = new ArrayList<>(); // // public String getId() { // return id; // } // // public void setId(String id) { // this.id = id; // } // // public String getExtend() { // return extend; // } // // public void setExtend(String extend) { // this.extend = extend; // } // // public Template getExtendTemplate() { // return extendTemplate; // } // // public void setExtendTemplate(Template extendTemplate) { // this.extendTemplate = extendTemplate; // } // // public Integer getCount() { // if (count == null && extendTemplate != null) { // return extendTemplate.getCount(); // } // return count; // } // // public void setCount(Integer count) { // this.count = count; // } // // public String getName() { // if (name == null && extendTemplate != null) { // return extendTemplate.getName(); // } // return name; // } // // public void setName(String name) { // this.name = name; // } // // public List<Field> getFields() { // List<Field> result = new ArrayList<>(); // if (extendTemplate != null && extendTemplate.getFields() != null) { // result.addAll(extendTemplate.getFields()); // } // if (fields != null) { // result.addAll(fields); // } // return result; // } // // public void setFields(List<Field> fields) { // this.fields = fields; // } // // public List<String> getChilds() { // List<String> result = new ArrayList<>(); // if (extendTemplate != null && extendTemplate.getChilds() != null) { // result.addAll(extendTemplate.getChilds()); // } // if (childs != null) { // result.addAll(childs); // } // return result; // } // // public void setChilds(List<String> childs) { // this.childs = childs; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // Template template = (Template) o; // // if (name != null ? !name.equals(template.name) : template.name != null) return false; // // return true; // } // // @Override // public int hashCode() { // return name != null ? name.hashCode() : 0; // } // }
import java.util.List; import java.util.Map; import com.presidentio.testdatagenerator.model.Template;
/** * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.presidentio.testdatagenerator.output.formatter; public interface Formatter { void init(Map<String, String> props);
// Path: src/main/java/com/presidentio/testdatagenerator/model/Template.java // public class Template { // // private String id; // // private String extend; // // @JsonIgnore // private Template extendTemplate; // // private Integer count; // // private String name; // // private List<Field> fields; // // private List<String> childs = new ArrayList<>(); // // public String getId() { // return id; // } // // public void setId(String id) { // this.id = id; // } // // public String getExtend() { // return extend; // } // // public void setExtend(String extend) { // this.extend = extend; // } // // public Template getExtendTemplate() { // return extendTemplate; // } // // public void setExtendTemplate(Template extendTemplate) { // this.extendTemplate = extendTemplate; // } // // public Integer getCount() { // if (count == null && extendTemplate != null) { // return extendTemplate.getCount(); // } // return count; // } // // public void setCount(Integer count) { // this.count = count; // } // // public String getName() { // if (name == null && extendTemplate != null) { // return extendTemplate.getName(); // } // return name; // } // // public void setName(String name) { // this.name = name; // } // // public List<Field> getFields() { // List<Field> result = new ArrayList<>(); // if (extendTemplate != null && extendTemplate.getFields() != null) { // result.addAll(extendTemplate.getFields()); // } // if (fields != null) { // result.addAll(fields); // } // return result; // } // // public void setFields(List<Field> fields) { // this.fields = fields; // } // // public List<String> getChilds() { // List<String> result = new ArrayList<>(); // if (extendTemplate != null && extendTemplate.getChilds() != null) { // result.addAll(extendTemplate.getChilds()); // } // if (childs != null) { // result.addAll(childs); // } // return result; // } // // public void setChilds(List<String> childs) { // this.childs = childs; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // Template template = (Template) o; // // if (name != null ? !name.equals(template.name) : template.name != null) return false; // // return true; // } // // @Override // public int hashCode() { // return name != null ? name.hashCode() : 0; // } // } // Path: src/main/java/com/presidentio/testdatagenerator/output/formatter/Formatter.java import java.util.List; import java.util.Map; import com.presidentio.testdatagenerator.model.Template; /** * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.presidentio.testdatagenerator.output.formatter; public interface Formatter { void init(Map<String, String> props);
String format(Map<String, Object> map, Template template);
presidentio/test-data-generator
src/main/java/com/presidentio/testdatagenerator/provider/TimeProvider.java
// Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java // public class Context { // // private Parent parent; // // private Map<String, Template> templates; // // private Map<String, Object> variables; // // private Sink sink; // // public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) { // this.templates = templates; // this.variables = variables; // this.sink = sink; // } // // public Context(Context parentContext, Map<String, Object> entity) { // parent = new Parent(entity, parentContext.getParent()); // templates = parentContext.getTemplates(); // variables = parentContext.getVariables(); // sink = parentContext.getSink(); // } // // public Parent getParent() { // return parent; // } // // public Map<String, Object> getVariables() { // return variables; // } // // public Sink getSink() { // return sink; // } // // public Map<String, Template> getTemplates() { // return templates; // } // // } // // Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java // public class Field { // // private String name; // // private String type; // // private Provider provider; // // public Field() { // } // // public Field(String name, String type, Provider provider) { // this.name = name; // this.type = type; // this.provider = provider; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // public Provider getProvider() { // return provider; // } // // public void setProvider(Provider provider) { // this.provider = provider; // } // }
import com.presidentio.testdatagenerator.context.Context; import com.presidentio.testdatagenerator.model.Field; import java.util.Map;
package com.presidentio.testdatagenerator.provider; /** * Created by Vitaliy on 23.04.2015. */ public class TimeProvider implements ValueProvider { @Override public void init(Map<String, String> props) { } @Override
// Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java // public class Context { // // private Parent parent; // // private Map<String, Template> templates; // // private Map<String, Object> variables; // // private Sink sink; // // public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) { // this.templates = templates; // this.variables = variables; // this.sink = sink; // } // // public Context(Context parentContext, Map<String, Object> entity) { // parent = new Parent(entity, parentContext.getParent()); // templates = parentContext.getTemplates(); // variables = parentContext.getVariables(); // sink = parentContext.getSink(); // } // // public Parent getParent() { // return parent; // } // // public Map<String, Object> getVariables() { // return variables; // } // // public Sink getSink() { // return sink; // } // // public Map<String, Template> getTemplates() { // return templates; // } // // } // // Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java // public class Field { // // private String name; // // private String type; // // private Provider provider; // // public Field() { // } // // public Field(String name, String type, Provider provider) { // this.name = name; // this.type = type; // this.provider = provider; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // public Provider getProvider() { // return provider; // } // // public void setProvider(Provider provider) { // this.provider = provider; // } // } // Path: src/main/java/com/presidentio/testdatagenerator/provider/TimeProvider.java import com.presidentio.testdatagenerator.context.Context; import com.presidentio.testdatagenerator.model.Field; import java.util.Map; package com.presidentio.testdatagenerator.provider; /** * Created by Vitaliy on 23.04.2015. */ public class TimeProvider implements ValueProvider { @Override public void init(Map<String, String> props) { } @Override
public Object nextValue(Context context, Field field) {
presidentio/test-data-generator
src/main/java/com/presidentio/testdatagenerator/provider/TimeProvider.java
// Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java // public class Context { // // private Parent parent; // // private Map<String, Template> templates; // // private Map<String, Object> variables; // // private Sink sink; // // public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) { // this.templates = templates; // this.variables = variables; // this.sink = sink; // } // // public Context(Context parentContext, Map<String, Object> entity) { // parent = new Parent(entity, parentContext.getParent()); // templates = parentContext.getTemplates(); // variables = parentContext.getVariables(); // sink = parentContext.getSink(); // } // // public Parent getParent() { // return parent; // } // // public Map<String, Object> getVariables() { // return variables; // } // // public Sink getSink() { // return sink; // } // // public Map<String, Template> getTemplates() { // return templates; // } // // } // // Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java // public class Field { // // private String name; // // private String type; // // private Provider provider; // // public Field() { // } // // public Field(String name, String type, Provider provider) { // this.name = name; // this.type = type; // this.provider = provider; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // public Provider getProvider() { // return provider; // } // // public void setProvider(Provider provider) { // this.provider = provider; // } // }
import com.presidentio.testdatagenerator.context.Context; import com.presidentio.testdatagenerator.model.Field; import java.util.Map;
package com.presidentio.testdatagenerator.provider; /** * Created by Vitaliy on 23.04.2015. */ public class TimeProvider implements ValueProvider { @Override public void init(Map<String, String> props) { } @Override
// Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java // public class Context { // // private Parent parent; // // private Map<String, Template> templates; // // private Map<String, Object> variables; // // private Sink sink; // // public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) { // this.templates = templates; // this.variables = variables; // this.sink = sink; // } // // public Context(Context parentContext, Map<String, Object> entity) { // parent = new Parent(entity, parentContext.getParent()); // templates = parentContext.getTemplates(); // variables = parentContext.getVariables(); // sink = parentContext.getSink(); // } // // public Parent getParent() { // return parent; // } // // public Map<String, Object> getVariables() { // return variables; // } // // public Sink getSink() { // return sink; // } // // public Map<String, Template> getTemplates() { // return templates; // } // // } // // Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java // public class Field { // // private String name; // // private String type; // // private Provider provider; // // public Field() { // } // // public Field(String name, String type, Provider provider) { // this.name = name; // this.type = type; // this.provider = provider; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // public Provider getProvider() { // return provider; // } // // public void setProvider(Provider provider) { // this.provider = provider; // } // } // Path: src/main/java/com/presidentio/testdatagenerator/provider/TimeProvider.java import com.presidentio.testdatagenerator.context.Context; import com.presidentio.testdatagenerator.model.Field; import java.util.Map; package com.presidentio.testdatagenerator.provider; /** * Created by Vitaliy on 23.04.2015. */ public class TimeProvider implements ValueProvider { @Override public void init(Map<String, String> props) { } @Override
public Object nextValue(Context context, Field field) {
presidentio/test-data-generator
src/main/java/com/presidentio/testdatagenerator/provider/EmailProvider.java
// Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java // public class PropConst { // // public static final String TYPE = "type"; // public static final String VALUE = "value"; // public static final String SIZE = "size"; // public static final String DOMAIN = "domain"; // public static final String EXPR = "expr"; // public static final String FILE = "file"; // public static final String DELIMITER = "delimiter"; // public static final String ITEMS = "items"; // public static final String INDEX = "index"; // public static final String HOST = "host"; // public static final String PORT = "port"; // public static final String CLUSTER_NAME = "clusterName"; // public static final String CONNECTION_URL = "connectionUrl"; // public static final String JDBC_DRIVER = "jdbcDriver"; // public static final String DEPTH = "depth"; // public static final String FIELD = "field"; // public static final String VAR = "var"; // public static final String OP = "op"; // public static final String FORMAT = "format"; // public static final String HEADER = "header"; // public static final String SUFFIX = "suffix"; // public static final String PREFIX = "prefix"; // public static final String PATH_PROVIDER = "pathProvider"; // public static final String BROKER_LIST = "brokerList"; // public static final String GENDER = "gender"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/cons/TypeConst.java // public class TypeConst { // // public static final String STRING = "string"; // public static final String LONG = "long"; // public static final String INT = "int"; // public static final String BOOLEAN = "boolean"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java // public class Context { // // private Parent parent; // // private Map<String, Template> templates; // // private Map<String, Object> variables; // // private Sink sink; // // public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) { // this.templates = templates; // this.variables = variables; // this.sink = sink; // } // // public Context(Context parentContext, Map<String, Object> entity) { // parent = new Parent(entity, parentContext.getParent()); // templates = parentContext.getTemplates(); // variables = parentContext.getVariables(); // sink = parentContext.getSink(); // } // // public Parent getParent() { // return parent; // } // // public Map<String, Object> getVariables() { // return variables; // } // // public Sink getSink() { // return sink; // } // // public Map<String, Template> getTemplates() { // return templates; // } // // } // // Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java // public class Field { // // private String name; // // private String type; // // private Provider provider; // // public Field() { // } // // public Field(String name, String type, Provider provider) { // this.name = name; // this.type = type; // this.provider = provider; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // public Provider getProvider() { // return provider; // } // // public void setProvider(Provider provider) { // this.provider = provider; // } // }
import com.presidentio.testdatagenerator.cons.PropConst; import com.presidentio.testdatagenerator.cons.TypeConst; import com.presidentio.testdatagenerator.context.Context; import com.presidentio.testdatagenerator.model.Field; import java.util.Collections; import java.util.HashMap; import java.util.Map;
/** * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.presidentio.testdatagenerator.provider; public class EmailProvider implements ValueProvider { private RandomProvider randomProvider; private String domain = "email.com"; @Override public void init(Map<String, String> props) { Map<String, String> propsCopy = new HashMap<>(props);
// Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java // public class PropConst { // // public static final String TYPE = "type"; // public static final String VALUE = "value"; // public static final String SIZE = "size"; // public static final String DOMAIN = "domain"; // public static final String EXPR = "expr"; // public static final String FILE = "file"; // public static final String DELIMITER = "delimiter"; // public static final String ITEMS = "items"; // public static final String INDEX = "index"; // public static final String HOST = "host"; // public static final String PORT = "port"; // public static final String CLUSTER_NAME = "clusterName"; // public static final String CONNECTION_URL = "connectionUrl"; // public static final String JDBC_DRIVER = "jdbcDriver"; // public static final String DEPTH = "depth"; // public static final String FIELD = "field"; // public static final String VAR = "var"; // public static final String OP = "op"; // public static final String FORMAT = "format"; // public static final String HEADER = "header"; // public static final String SUFFIX = "suffix"; // public static final String PREFIX = "prefix"; // public static final String PATH_PROVIDER = "pathProvider"; // public static final String BROKER_LIST = "brokerList"; // public static final String GENDER = "gender"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/cons/TypeConst.java // public class TypeConst { // // public static final String STRING = "string"; // public static final String LONG = "long"; // public static final String INT = "int"; // public static final String BOOLEAN = "boolean"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java // public class Context { // // private Parent parent; // // private Map<String, Template> templates; // // private Map<String, Object> variables; // // private Sink sink; // // public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) { // this.templates = templates; // this.variables = variables; // this.sink = sink; // } // // public Context(Context parentContext, Map<String, Object> entity) { // parent = new Parent(entity, parentContext.getParent()); // templates = parentContext.getTemplates(); // variables = parentContext.getVariables(); // sink = parentContext.getSink(); // } // // public Parent getParent() { // return parent; // } // // public Map<String, Object> getVariables() { // return variables; // } // // public Sink getSink() { // return sink; // } // // public Map<String, Template> getTemplates() { // return templates; // } // // } // // Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java // public class Field { // // private String name; // // private String type; // // private Provider provider; // // public Field() { // } // // public Field(String name, String type, Provider provider) { // this.name = name; // this.type = type; // this.provider = provider; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // public Provider getProvider() { // return provider; // } // // public void setProvider(Provider provider) { // this.provider = provider; // } // } // Path: src/main/java/com/presidentio/testdatagenerator/provider/EmailProvider.java import com.presidentio.testdatagenerator.cons.PropConst; import com.presidentio.testdatagenerator.cons.TypeConst; import com.presidentio.testdatagenerator.context.Context; import com.presidentio.testdatagenerator.model.Field; import java.util.Collections; import java.util.HashMap; import java.util.Map; /** * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.presidentio.testdatagenerator.provider; public class EmailProvider implements ValueProvider { private RandomProvider randomProvider; private String domain = "email.com"; @Override public void init(Map<String, String> props) { Map<String, String> propsCopy = new HashMap<>(props);
if (propsCopy.containsKey(PropConst.DOMAIN)) {
presidentio/test-data-generator
src/main/java/com/presidentio/testdatagenerator/provider/EmailProvider.java
// Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java // public class PropConst { // // public static final String TYPE = "type"; // public static final String VALUE = "value"; // public static final String SIZE = "size"; // public static final String DOMAIN = "domain"; // public static final String EXPR = "expr"; // public static final String FILE = "file"; // public static final String DELIMITER = "delimiter"; // public static final String ITEMS = "items"; // public static final String INDEX = "index"; // public static final String HOST = "host"; // public static final String PORT = "port"; // public static final String CLUSTER_NAME = "clusterName"; // public static final String CONNECTION_URL = "connectionUrl"; // public static final String JDBC_DRIVER = "jdbcDriver"; // public static final String DEPTH = "depth"; // public static final String FIELD = "field"; // public static final String VAR = "var"; // public static final String OP = "op"; // public static final String FORMAT = "format"; // public static final String HEADER = "header"; // public static final String SUFFIX = "suffix"; // public static final String PREFIX = "prefix"; // public static final String PATH_PROVIDER = "pathProvider"; // public static final String BROKER_LIST = "brokerList"; // public static final String GENDER = "gender"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/cons/TypeConst.java // public class TypeConst { // // public static final String STRING = "string"; // public static final String LONG = "long"; // public static final String INT = "int"; // public static final String BOOLEAN = "boolean"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java // public class Context { // // private Parent parent; // // private Map<String, Template> templates; // // private Map<String, Object> variables; // // private Sink sink; // // public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) { // this.templates = templates; // this.variables = variables; // this.sink = sink; // } // // public Context(Context parentContext, Map<String, Object> entity) { // parent = new Parent(entity, parentContext.getParent()); // templates = parentContext.getTemplates(); // variables = parentContext.getVariables(); // sink = parentContext.getSink(); // } // // public Parent getParent() { // return parent; // } // // public Map<String, Object> getVariables() { // return variables; // } // // public Sink getSink() { // return sink; // } // // public Map<String, Template> getTemplates() { // return templates; // } // // } // // Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java // public class Field { // // private String name; // // private String type; // // private Provider provider; // // public Field() { // } // // public Field(String name, String type, Provider provider) { // this.name = name; // this.type = type; // this.provider = provider; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // public Provider getProvider() { // return provider; // } // // public void setProvider(Provider provider) { // this.provider = provider; // } // }
import com.presidentio.testdatagenerator.cons.PropConst; import com.presidentio.testdatagenerator.cons.TypeConst; import com.presidentio.testdatagenerator.context.Context; import com.presidentio.testdatagenerator.model.Field; import java.util.Collections; import java.util.HashMap; import java.util.Map;
/** * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.presidentio.testdatagenerator.provider; public class EmailProvider implements ValueProvider { private RandomProvider randomProvider; private String domain = "email.com"; @Override public void init(Map<String, String> props) { Map<String, String> propsCopy = new HashMap<>(props); if (propsCopy.containsKey(PropConst.DOMAIN)) { domain = propsCopy.remove(PropConst.DOMAIN); } if (!propsCopy.isEmpty()) { throw new IllegalArgumentException("Redundant props for " + getClass().getName() + ": " + propsCopy); } randomProvider = new RandomProvider(); randomProvider.init(Collections.<String, String>emptyMap()); } @Override
// Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java // public class PropConst { // // public static final String TYPE = "type"; // public static final String VALUE = "value"; // public static final String SIZE = "size"; // public static final String DOMAIN = "domain"; // public static final String EXPR = "expr"; // public static final String FILE = "file"; // public static final String DELIMITER = "delimiter"; // public static final String ITEMS = "items"; // public static final String INDEX = "index"; // public static final String HOST = "host"; // public static final String PORT = "port"; // public static final String CLUSTER_NAME = "clusterName"; // public static final String CONNECTION_URL = "connectionUrl"; // public static final String JDBC_DRIVER = "jdbcDriver"; // public static final String DEPTH = "depth"; // public static final String FIELD = "field"; // public static final String VAR = "var"; // public static final String OP = "op"; // public static final String FORMAT = "format"; // public static final String HEADER = "header"; // public static final String SUFFIX = "suffix"; // public static final String PREFIX = "prefix"; // public static final String PATH_PROVIDER = "pathProvider"; // public static final String BROKER_LIST = "brokerList"; // public static final String GENDER = "gender"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/cons/TypeConst.java // public class TypeConst { // // public static final String STRING = "string"; // public static final String LONG = "long"; // public static final String INT = "int"; // public static final String BOOLEAN = "boolean"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java // public class Context { // // private Parent parent; // // private Map<String, Template> templates; // // private Map<String, Object> variables; // // private Sink sink; // // public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) { // this.templates = templates; // this.variables = variables; // this.sink = sink; // } // // public Context(Context parentContext, Map<String, Object> entity) { // parent = new Parent(entity, parentContext.getParent()); // templates = parentContext.getTemplates(); // variables = parentContext.getVariables(); // sink = parentContext.getSink(); // } // // public Parent getParent() { // return parent; // } // // public Map<String, Object> getVariables() { // return variables; // } // // public Sink getSink() { // return sink; // } // // public Map<String, Template> getTemplates() { // return templates; // } // // } // // Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java // public class Field { // // private String name; // // private String type; // // private Provider provider; // // public Field() { // } // // public Field(String name, String type, Provider provider) { // this.name = name; // this.type = type; // this.provider = provider; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // public Provider getProvider() { // return provider; // } // // public void setProvider(Provider provider) { // this.provider = provider; // } // } // Path: src/main/java/com/presidentio/testdatagenerator/provider/EmailProvider.java import com.presidentio.testdatagenerator.cons.PropConst; import com.presidentio.testdatagenerator.cons.TypeConst; import com.presidentio.testdatagenerator.context.Context; import com.presidentio.testdatagenerator.model.Field; import java.util.Collections; import java.util.HashMap; import java.util.Map; /** * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.presidentio.testdatagenerator.provider; public class EmailProvider implements ValueProvider { private RandomProvider randomProvider; private String domain = "email.com"; @Override public void init(Map<String, String> props) { Map<String, String> propsCopy = new HashMap<>(props); if (propsCopy.containsKey(PropConst.DOMAIN)) { domain = propsCopy.remove(PropConst.DOMAIN); } if (!propsCopy.isEmpty()) { throw new IllegalArgumentException("Redundant props for " + getClass().getName() + ": " + propsCopy); } randomProvider = new RandomProvider(); randomProvider.init(Collections.<String, String>emptyMap()); } @Override
public String nextValue(Context context, Field field) {
presidentio/test-data-generator
src/main/java/com/presidentio/testdatagenerator/provider/EmailProvider.java
// Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java // public class PropConst { // // public static final String TYPE = "type"; // public static final String VALUE = "value"; // public static final String SIZE = "size"; // public static final String DOMAIN = "domain"; // public static final String EXPR = "expr"; // public static final String FILE = "file"; // public static final String DELIMITER = "delimiter"; // public static final String ITEMS = "items"; // public static final String INDEX = "index"; // public static final String HOST = "host"; // public static final String PORT = "port"; // public static final String CLUSTER_NAME = "clusterName"; // public static final String CONNECTION_URL = "connectionUrl"; // public static final String JDBC_DRIVER = "jdbcDriver"; // public static final String DEPTH = "depth"; // public static final String FIELD = "field"; // public static final String VAR = "var"; // public static final String OP = "op"; // public static final String FORMAT = "format"; // public static final String HEADER = "header"; // public static final String SUFFIX = "suffix"; // public static final String PREFIX = "prefix"; // public static final String PATH_PROVIDER = "pathProvider"; // public static final String BROKER_LIST = "brokerList"; // public static final String GENDER = "gender"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/cons/TypeConst.java // public class TypeConst { // // public static final String STRING = "string"; // public static final String LONG = "long"; // public static final String INT = "int"; // public static final String BOOLEAN = "boolean"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java // public class Context { // // private Parent parent; // // private Map<String, Template> templates; // // private Map<String, Object> variables; // // private Sink sink; // // public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) { // this.templates = templates; // this.variables = variables; // this.sink = sink; // } // // public Context(Context parentContext, Map<String, Object> entity) { // parent = new Parent(entity, parentContext.getParent()); // templates = parentContext.getTemplates(); // variables = parentContext.getVariables(); // sink = parentContext.getSink(); // } // // public Parent getParent() { // return parent; // } // // public Map<String, Object> getVariables() { // return variables; // } // // public Sink getSink() { // return sink; // } // // public Map<String, Template> getTemplates() { // return templates; // } // // } // // Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java // public class Field { // // private String name; // // private String type; // // private Provider provider; // // public Field() { // } // // public Field(String name, String type, Provider provider) { // this.name = name; // this.type = type; // this.provider = provider; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // public Provider getProvider() { // return provider; // } // // public void setProvider(Provider provider) { // this.provider = provider; // } // }
import com.presidentio.testdatagenerator.cons.PropConst; import com.presidentio.testdatagenerator.cons.TypeConst; import com.presidentio.testdatagenerator.context.Context; import com.presidentio.testdatagenerator.model.Field; import java.util.Collections; import java.util.HashMap; import java.util.Map;
/** * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.presidentio.testdatagenerator.provider; public class EmailProvider implements ValueProvider { private RandomProvider randomProvider; private String domain = "email.com"; @Override public void init(Map<String, String> props) { Map<String, String> propsCopy = new HashMap<>(props); if (propsCopy.containsKey(PropConst.DOMAIN)) { domain = propsCopy.remove(PropConst.DOMAIN); } if (!propsCopy.isEmpty()) { throw new IllegalArgumentException("Redundant props for " + getClass().getName() + ": " + propsCopy); } randomProvider = new RandomProvider(); randomProvider.init(Collections.<String, String>emptyMap()); } @Override
// Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java // public class PropConst { // // public static final String TYPE = "type"; // public static final String VALUE = "value"; // public static final String SIZE = "size"; // public static final String DOMAIN = "domain"; // public static final String EXPR = "expr"; // public static final String FILE = "file"; // public static final String DELIMITER = "delimiter"; // public static final String ITEMS = "items"; // public static final String INDEX = "index"; // public static final String HOST = "host"; // public static final String PORT = "port"; // public static final String CLUSTER_NAME = "clusterName"; // public static final String CONNECTION_URL = "connectionUrl"; // public static final String JDBC_DRIVER = "jdbcDriver"; // public static final String DEPTH = "depth"; // public static final String FIELD = "field"; // public static final String VAR = "var"; // public static final String OP = "op"; // public static final String FORMAT = "format"; // public static final String HEADER = "header"; // public static final String SUFFIX = "suffix"; // public static final String PREFIX = "prefix"; // public static final String PATH_PROVIDER = "pathProvider"; // public static final String BROKER_LIST = "brokerList"; // public static final String GENDER = "gender"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/cons/TypeConst.java // public class TypeConst { // // public static final String STRING = "string"; // public static final String LONG = "long"; // public static final String INT = "int"; // public static final String BOOLEAN = "boolean"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java // public class Context { // // private Parent parent; // // private Map<String, Template> templates; // // private Map<String, Object> variables; // // private Sink sink; // // public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) { // this.templates = templates; // this.variables = variables; // this.sink = sink; // } // // public Context(Context parentContext, Map<String, Object> entity) { // parent = new Parent(entity, parentContext.getParent()); // templates = parentContext.getTemplates(); // variables = parentContext.getVariables(); // sink = parentContext.getSink(); // } // // public Parent getParent() { // return parent; // } // // public Map<String, Object> getVariables() { // return variables; // } // // public Sink getSink() { // return sink; // } // // public Map<String, Template> getTemplates() { // return templates; // } // // } // // Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java // public class Field { // // private String name; // // private String type; // // private Provider provider; // // public Field() { // } // // public Field(String name, String type, Provider provider) { // this.name = name; // this.type = type; // this.provider = provider; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // public Provider getProvider() { // return provider; // } // // public void setProvider(Provider provider) { // this.provider = provider; // } // } // Path: src/main/java/com/presidentio/testdatagenerator/provider/EmailProvider.java import com.presidentio.testdatagenerator.cons.PropConst; import com.presidentio.testdatagenerator.cons.TypeConst; import com.presidentio.testdatagenerator.context.Context; import com.presidentio.testdatagenerator.model.Field; import java.util.Collections; import java.util.HashMap; import java.util.Map; /** * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.presidentio.testdatagenerator.provider; public class EmailProvider implements ValueProvider { private RandomProvider randomProvider; private String domain = "email.com"; @Override public void init(Map<String, String> props) { Map<String, String> propsCopy = new HashMap<>(props); if (propsCopy.containsKey(PropConst.DOMAIN)) { domain = propsCopy.remove(PropConst.DOMAIN); } if (!propsCopy.isEmpty()) { throw new IllegalArgumentException("Redundant props for " + getClass().getName() + ": " + propsCopy); } randomProvider = new RandomProvider(); randomProvider.init(Collections.<String, String>emptyMap()); } @Override
public String nextValue(Context context, Field field) {
presidentio/test-data-generator
src/main/java/com/presidentio/testdatagenerator/provider/EmailProvider.java
// Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java // public class PropConst { // // public static final String TYPE = "type"; // public static final String VALUE = "value"; // public static final String SIZE = "size"; // public static final String DOMAIN = "domain"; // public static final String EXPR = "expr"; // public static final String FILE = "file"; // public static final String DELIMITER = "delimiter"; // public static final String ITEMS = "items"; // public static final String INDEX = "index"; // public static final String HOST = "host"; // public static final String PORT = "port"; // public static final String CLUSTER_NAME = "clusterName"; // public static final String CONNECTION_URL = "connectionUrl"; // public static final String JDBC_DRIVER = "jdbcDriver"; // public static final String DEPTH = "depth"; // public static final String FIELD = "field"; // public static final String VAR = "var"; // public static final String OP = "op"; // public static final String FORMAT = "format"; // public static final String HEADER = "header"; // public static final String SUFFIX = "suffix"; // public static final String PREFIX = "prefix"; // public static final String PATH_PROVIDER = "pathProvider"; // public static final String BROKER_LIST = "brokerList"; // public static final String GENDER = "gender"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/cons/TypeConst.java // public class TypeConst { // // public static final String STRING = "string"; // public static final String LONG = "long"; // public static final String INT = "int"; // public static final String BOOLEAN = "boolean"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java // public class Context { // // private Parent parent; // // private Map<String, Template> templates; // // private Map<String, Object> variables; // // private Sink sink; // // public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) { // this.templates = templates; // this.variables = variables; // this.sink = sink; // } // // public Context(Context parentContext, Map<String, Object> entity) { // parent = new Parent(entity, parentContext.getParent()); // templates = parentContext.getTemplates(); // variables = parentContext.getVariables(); // sink = parentContext.getSink(); // } // // public Parent getParent() { // return parent; // } // // public Map<String, Object> getVariables() { // return variables; // } // // public Sink getSink() { // return sink; // } // // public Map<String, Template> getTemplates() { // return templates; // } // // } // // Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java // public class Field { // // private String name; // // private String type; // // private Provider provider; // // public Field() { // } // // public Field(String name, String type, Provider provider) { // this.name = name; // this.type = type; // this.provider = provider; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // public Provider getProvider() { // return provider; // } // // public void setProvider(Provider provider) { // this.provider = provider; // } // }
import com.presidentio.testdatagenerator.cons.PropConst; import com.presidentio.testdatagenerator.cons.TypeConst; import com.presidentio.testdatagenerator.context.Context; import com.presidentio.testdatagenerator.model.Field; import java.util.Collections; import java.util.HashMap; import java.util.Map;
/** * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.presidentio.testdatagenerator.provider; public class EmailProvider implements ValueProvider { private RandomProvider randomProvider; private String domain = "email.com"; @Override public void init(Map<String, String> props) { Map<String, String> propsCopy = new HashMap<>(props); if (propsCopy.containsKey(PropConst.DOMAIN)) { domain = propsCopy.remove(PropConst.DOMAIN); } if (!propsCopy.isEmpty()) { throw new IllegalArgumentException("Redundant props for " + getClass().getName() + ": " + propsCopy); } randomProvider = new RandomProvider(); randomProvider.init(Collections.<String, String>emptyMap()); } @Override public String nextValue(Context context, Field field) {
// Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java // public class PropConst { // // public static final String TYPE = "type"; // public static final String VALUE = "value"; // public static final String SIZE = "size"; // public static final String DOMAIN = "domain"; // public static final String EXPR = "expr"; // public static final String FILE = "file"; // public static final String DELIMITER = "delimiter"; // public static final String ITEMS = "items"; // public static final String INDEX = "index"; // public static final String HOST = "host"; // public static final String PORT = "port"; // public static final String CLUSTER_NAME = "clusterName"; // public static final String CONNECTION_URL = "connectionUrl"; // public static final String JDBC_DRIVER = "jdbcDriver"; // public static final String DEPTH = "depth"; // public static final String FIELD = "field"; // public static final String VAR = "var"; // public static final String OP = "op"; // public static final String FORMAT = "format"; // public static final String HEADER = "header"; // public static final String SUFFIX = "suffix"; // public static final String PREFIX = "prefix"; // public static final String PATH_PROVIDER = "pathProvider"; // public static final String BROKER_LIST = "brokerList"; // public static final String GENDER = "gender"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/cons/TypeConst.java // public class TypeConst { // // public static final String STRING = "string"; // public static final String LONG = "long"; // public static final String INT = "int"; // public static final String BOOLEAN = "boolean"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java // public class Context { // // private Parent parent; // // private Map<String, Template> templates; // // private Map<String, Object> variables; // // private Sink sink; // // public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) { // this.templates = templates; // this.variables = variables; // this.sink = sink; // } // // public Context(Context parentContext, Map<String, Object> entity) { // parent = new Parent(entity, parentContext.getParent()); // templates = parentContext.getTemplates(); // variables = parentContext.getVariables(); // sink = parentContext.getSink(); // } // // public Parent getParent() { // return parent; // } // // public Map<String, Object> getVariables() { // return variables; // } // // public Sink getSink() { // return sink; // } // // public Map<String, Template> getTemplates() { // return templates; // } // // } // // Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java // public class Field { // // private String name; // // private String type; // // private Provider provider; // // public Field() { // } // // public Field(String name, String type, Provider provider) { // this.name = name; // this.type = type; // this.provider = provider; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // public Provider getProvider() { // return provider; // } // // public void setProvider(Provider provider) { // this.provider = provider; // } // } // Path: src/main/java/com/presidentio/testdatagenerator/provider/EmailProvider.java import com.presidentio.testdatagenerator.cons.PropConst; import com.presidentio.testdatagenerator.cons.TypeConst; import com.presidentio.testdatagenerator.context.Context; import com.presidentio.testdatagenerator.model.Field; import java.util.Collections; import java.util.HashMap; import java.util.Map; /** * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.presidentio.testdatagenerator.provider; public class EmailProvider implements ValueProvider { private RandomProvider randomProvider; private String domain = "email.com"; @Override public void init(Map<String, String> props) { Map<String, String> propsCopy = new HashMap<>(props); if (propsCopy.containsKey(PropConst.DOMAIN)) { domain = propsCopy.remove(PropConst.DOMAIN); } if (!propsCopy.isEmpty()) { throw new IllegalArgumentException("Redundant props for " + getClass().getName() + ": " + propsCopy); } randomProvider = new RandomProvider(); randomProvider.init(Collections.<String, String>emptyMap()); } @Override public String nextValue(Context context, Field field) {
if (!field.getType().equals(TypeConst.STRING)) {
presidentio/test-data-generator
src/main/java/com/presidentio/testdatagenerator/output/EsDirectSink.java
// Path: src/main/java/com/presidentio/testdatagenerator/output/formatter/EsFormatter.java // public class EsFormatter implements Formatter { // // private static final String INDEX = "{ \"index\" : { \"_index\" : \"%s\", \"_type\" : \"%s\"} }"; // // private ObjectMapper objectMapper = new ObjectMapper(); // // private String index; // // @Override // public void init(Map<String, String> props) { // index = props.get(PropConst.INDEX); // if (index == null) { // throw new IllegalArgumentException(PropConst.INDEX + " does not specified or null"); // } // // } // // @Override // public String format(Map<String, Object> map, Template template) { // String result = String.format(INDEX, index, template.getName()); // result += DelimiterConst.NEW_LINE; // try { // result += objectMapper.writeValueAsString(map); // result += DelimiterConst.NEW_LINE; // } catch (IOException e) { // throw new IllegalArgumentException(e); // } // return result; // } // // @Override // public String format(List<Map<String, Object>> maps, Template template) { // StringBuilder stringBuilder = new StringBuilder(); // for (Map<String, Object> map : maps) { // stringBuilder.append(format(map, template)); // } // return stringBuilder.toString(); // } // // @Override // public boolean supportMultiInsert() { // return true; // } // } // // Path: src/main/java/com/presidentio/testdatagenerator/output/formatter/Formatter.java // public interface Formatter { // // void init(Map<String, String> props); // // String format(Map<String, Object> map, Template template); // // String format(List<Map<String, Object>> maps, Template template); // // boolean supportMultiInsert(); // // }
import com.presidentio.testdatagenerator.output.formatter.Formatter; import java.util.Map; import com.presidentio.testdatagenerator.output.formatter.EsFormatter;
/** * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.presidentio.testdatagenerator.output; public class EsDirectSink extends AbstractEsSink { @Override public void init(Map<String, String> props) { super.init(props);
// Path: src/main/java/com/presidentio/testdatagenerator/output/formatter/EsFormatter.java // public class EsFormatter implements Formatter { // // private static final String INDEX = "{ \"index\" : { \"_index\" : \"%s\", \"_type\" : \"%s\"} }"; // // private ObjectMapper objectMapper = new ObjectMapper(); // // private String index; // // @Override // public void init(Map<String, String> props) { // index = props.get(PropConst.INDEX); // if (index == null) { // throw new IllegalArgumentException(PropConst.INDEX + " does not specified or null"); // } // // } // // @Override // public String format(Map<String, Object> map, Template template) { // String result = String.format(INDEX, index, template.getName()); // result += DelimiterConst.NEW_LINE; // try { // result += objectMapper.writeValueAsString(map); // result += DelimiterConst.NEW_LINE; // } catch (IOException e) { // throw new IllegalArgumentException(e); // } // return result; // } // // @Override // public String format(List<Map<String, Object>> maps, Template template) { // StringBuilder stringBuilder = new StringBuilder(); // for (Map<String, Object> map : maps) { // stringBuilder.append(format(map, template)); // } // return stringBuilder.toString(); // } // // @Override // public boolean supportMultiInsert() { // return true; // } // } // // Path: src/main/java/com/presidentio/testdatagenerator/output/formatter/Formatter.java // public interface Formatter { // // void init(Map<String, String> props); // // String format(Map<String, Object> map, Template template); // // String format(List<Map<String, Object>> maps, Template template); // // boolean supportMultiInsert(); // // } // Path: src/main/java/com/presidentio/testdatagenerator/output/EsDirectSink.java import com.presidentio.testdatagenerator.output.formatter.Formatter; import java.util.Map; import com.presidentio.testdatagenerator.output.formatter.EsFormatter; /** * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.presidentio.testdatagenerator.output; public class EsDirectSink extends AbstractEsSink { @Override public void init(Map<String, String> props) { super.init(props);
Formatter formatter = new EsFormatter();
presidentio/test-data-generator
src/main/java/com/presidentio/testdatagenerator/output/EsDirectSink.java
// Path: src/main/java/com/presidentio/testdatagenerator/output/formatter/EsFormatter.java // public class EsFormatter implements Formatter { // // private static final String INDEX = "{ \"index\" : { \"_index\" : \"%s\", \"_type\" : \"%s\"} }"; // // private ObjectMapper objectMapper = new ObjectMapper(); // // private String index; // // @Override // public void init(Map<String, String> props) { // index = props.get(PropConst.INDEX); // if (index == null) { // throw new IllegalArgumentException(PropConst.INDEX + " does not specified or null"); // } // // } // // @Override // public String format(Map<String, Object> map, Template template) { // String result = String.format(INDEX, index, template.getName()); // result += DelimiterConst.NEW_LINE; // try { // result += objectMapper.writeValueAsString(map); // result += DelimiterConst.NEW_LINE; // } catch (IOException e) { // throw new IllegalArgumentException(e); // } // return result; // } // // @Override // public String format(List<Map<String, Object>> maps, Template template) { // StringBuilder stringBuilder = new StringBuilder(); // for (Map<String, Object> map : maps) { // stringBuilder.append(format(map, template)); // } // return stringBuilder.toString(); // } // // @Override // public boolean supportMultiInsert() { // return true; // } // } // // Path: src/main/java/com/presidentio/testdatagenerator/output/formatter/Formatter.java // public interface Formatter { // // void init(Map<String, String> props); // // String format(Map<String, Object> map, Template template); // // String format(List<Map<String, Object>> maps, Template template); // // boolean supportMultiInsert(); // // }
import com.presidentio.testdatagenerator.output.formatter.Formatter; import java.util.Map; import com.presidentio.testdatagenerator.output.formatter.EsFormatter;
/** * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.presidentio.testdatagenerator.output; public class EsDirectSink extends AbstractEsSink { @Override public void init(Map<String, String> props) { super.init(props);
// Path: src/main/java/com/presidentio/testdatagenerator/output/formatter/EsFormatter.java // public class EsFormatter implements Formatter { // // private static final String INDEX = "{ \"index\" : { \"_index\" : \"%s\", \"_type\" : \"%s\"} }"; // // private ObjectMapper objectMapper = new ObjectMapper(); // // private String index; // // @Override // public void init(Map<String, String> props) { // index = props.get(PropConst.INDEX); // if (index == null) { // throw new IllegalArgumentException(PropConst.INDEX + " does not specified or null"); // } // // } // // @Override // public String format(Map<String, Object> map, Template template) { // String result = String.format(INDEX, index, template.getName()); // result += DelimiterConst.NEW_LINE; // try { // result += objectMapper.writeValueAsString(map); // result += DelimiterConst.NEW_LINE; // } catch (IOException e) { // throw new IllegalArgumentException(e); // } // return result; // } // // @Override // public String format(List<Map<String, Object>> maps, Template template) { // StringBuilder stringBuilder = new StringBuilder(); // for (Map<String, Object> map : maps) { // stringBuilder.append(format(map, template)); // } // return stringBuilder.toString(); // } // // @Override // public boolean supportMultiInsert() { // return true; // } // } // // Path: src/main/java/com/presidentio/testdatagenerator/output/formatter/Formatter.java // public interface Formatter { // // void init(Map<String, String> props); // // String format(Map<String, Object> map, Template template); // // String format(List<Map<String, Object>> maps, Template template); // // boolean supportMultiInsert(); // // } // Path: src/main/java/com/presidentio/testdatagenerator/output/EsDirectSink.java import com.presidentio.testdatagenerator.output.formatter.Formatter; import java.util.Map; import com.presidentio.testdatagenerator.output.formatter.EsFormatter; /** * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.presidentio.testdatagenerator.output; public class EsDirectSink extends AbstractEsSink { @Override public void init(Map<String, String> props) { super.init(props);
Formatter formatter = new EsFormatter();
presidentio/test-data-generator
src/test/java/com/presidentio/testdatagenerator/provider/ExpressionProviderTest.java
// Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java // public class PropConst { // // public static final String TYPE = "type"; // public static final String VALUE = "value"; // public static final String SIZE = "size"; // public static final String DOMAIN = "domain"; // public static final String EXPR = "expr"; // public static final String FILE = "file"; // public static final String DELIMITER = "delimiter"; // public static final String ITEMS = "items"; // public static final String INDEX = "index"; // public static final String HOST = "host"; // public static final String PORT = "port"; // public static final String CLUSTER_NAME = "clusterName"; // public static final String CONNECTION_URL = "connectionUrl"; // public static final String JDBC_DRIVER = "jdbcDriver"; // public static final String DEPTH = "depth"; // public static final String FIELD = "field"; // public static final String VAR = "var"; // public static final String OP = "op"; // public static final String FORMAT = "format"; // public static final String HEADER = "header"; // public static final String SUFFIX = "suffix"; // public static final String PREFIX = "prefix"; // public static final String PATH_PROVIDER = "pathProvider"; // public static final String BROKER_LIST = "brokerList"; // public static final String GENDER = "gender"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/cons/TypeConst.java // public class TypeConst { // // public static final String STRING = "string"; // public static final String LONG = "long"; // public static final String INT = "int"; // public static final String BOOLEAN = "boolean"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java // public class Context { // // private Parent parent; // // private Map<String, Template> templates; // // private Map<String, Object> variables; // // private Sink sink; // // public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) { // this.templates = templates; // this.variables = variables; // this.sink = sink; // } // // public Context(Context parentContext, Map<String, Object> entity) { // parent = new Parent(entity, parentContext.getParent()); // templates = parentContext.getTemplates(); // variables = parentContext.getVariables(); // sink = parentContext.getSink(); // } // // public Parent getParent() { // return parent; // } // // public Map<String, Object> getVariables() { // return variables; // } // // public Sink getSink() { // return sink; // } // // public Map<String, Template> getTemplates() { // return templates; // } // // } // // Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java // public class Field { // // private String name; // // private String type; // // private Provider provider; // // public Field() { // } // // public Field(String name, String type, Provider provider) { // this.name = name; // this.type = type; // this.provider = provider; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // public Provider getProvider() { // return provider; // } // // public void setProvider(Provider provider) { // this.provider = provider; // } // }
import com.presidentio.testdatagenerator.cons.PropConst; import com.presidentio.testdatagenerator.cons.TypeConst; import com.presidentio.testdatagenerator.context.Context; import com.presidentio.testdatagenerator.model.Field; import org.junit.Assert; import org.junit.Test; import java.util.HashMap; import java.util.Map;
/** * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.presidentio.testdatagenerator.provider; public class ExpressionProviderTest { @Test public void testNextValueSimpleMath() throws Exception { Map<String, String> props = new HashMap<>(); String propExpr = "2 + 10";
// Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java // public class PropConst { // // public static final String TYPE = "type"; // public static final String VALUE = "value"; // public static final String SIZE = "size"; // public static final String DOMAIN = "domain"; // public static final String EXPR = "expr"; // public static final String FILE = "file"; // public static final String DELIMITER = "delimiter"; // public static final String ITEMS = "items"; // public static final String INDEX = "index"; // public static final String HOST = "host"; // public static final String PORT = "port"; // public static final String CLUSTER_NAME = "clusterName"; // public static final String CONNECTION_URL = "connectionUrl"; // public static final String JDBC_DRIVER = "jdbcDriver"; // public static final String DEPTH = "depth"; // public static final String FIELD = "field"; // public static final String VAR = "var"; // public static final String OP = "op"; // public static final String FORMAT = "format"; // public static final String HEADER = "header"; // public static final String SUFFIX = "suffix"; // public static final String PREFIX = "prefix"; // public static final String PATH_PROVIDER = "pathProvider"; // public static final String BROKER_LIST = "brokerList"; // public static final String GENDER = "gender"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/cons/TypeConst.java // public class TypeConst { // // public static final String STRING = "string"; // public static final String LONG = "long"; // public static final String INT = "int"; // public static final String BOOLEAN = "boolean"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java // public class Context { // // private Parent parent; // // private Map<String, Template> templates; // // private Map<String, Object> variables; // // private Sink sink; // // public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) { // this.templates = templates; // this.variables = variables; // this.sink = sink; // } // // public Context(Context parentContext, Map<String, Object> entity) { // parent = new Parent(entity, parentContext.getParent()); // templates = parentContext.getTemplates(); // variables = parentContext.getVariables(); // sink = parentContext.getSink(); // } // // public Parent getParent() { // return parent; // } // // public Map<String, Object> getVariables() { // return variables; // } // // public Sink getSink() { // return sink; // } // // public Map<String, Template> getTemplates() { // return templates; // } // // } // // Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java // public class Field { // // private String name; // // private String type; // // private Provider provider; // // public Field() { // } // // public Field(String name, String type, Provider provider) { // this.name = name; // this.type = type; // this.provider = provider; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // public Provider getProvider() { // return provider; // } // // public void setProvider(Provider provider) { // this.provider = provider; // } // } // Path: src/test/java/com/presidentio/testdatagenerator/provider/ExpressionProviderTest.java import com.presidentio.testdatagenerator.cons.PropConst; import com.presidentio.testdatagenerator.cons.TypeConst; import com.presidentio.testdatagenerator.context.Context; import com.presidentio.testdatagenerator.model.Field; import org.junit.Assert; import org.junit.Test; import java.util.HashMap; import java.util.Map; /** * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.presidentio.testdatagenerator.provider; public class ExpressionProviderTest { @Test public void testNextValueSimpleMath() throws Exception { Map<String, String> props = new HashMap<>(); String propExpr = "2 + 10";
props.put(PropConst.EXPR, propExpr);
presidentio/test-data-generator
src/test/java/com/presidentio/testdatagenerator/provider/ExpressionProviderTest.java
// Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java // public class PropConst { // // public static final String TYPE = "type"; // public static final String VALUE = "value"; // public static final String SIZE = "size"; // public static final String DOMAIN = "domain"; // public static final String EXPR = "expr"; // public static final String FILE = "file"; // public static final String DELIMITER = "delimiter"; // public static final String ITEMS = "items"; // public static final String INDEX = "index"; // public static final String HOST = "host"; // public static final String PORT = "port"; // public static final String CLUSTER_NAME = "clusterName"; // public static final String CONNECTION_URL = "connectionUrl"; // public static final String JDBC_DRIVER = "jdbcDriver"; // public static final String DEPTH = "depth"; // public static final String FIELD = "field"; // public static final String VAR = "var"; // public static final String OP = "op"; // public static final String FORMAT = "format"; // public static final String HEADER = "header"; // public static final String SUFFIX = "suffix"; // public static final String PREFIX = "prefix"; // public static final String PATH_PROVIDER = "pathProvider"; // public static final String BROKER_LIST = "brokerList"; // public static final String GENDER = "gender"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/cons/TypeConst.java // public class TypeConst { // // public static final String STRING = "string"; // public static final String LONG = "long"; // public static final String INT = "int"; // public static final String BOOLEAN = "boolean"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java // public class Context { // // private Parent parent; // // private Map<String, Template> templates; // // private Map<String, Object> variables; // // private Sink sink; // // public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) { // this.templates = templates; // this.variables = variables; // this.sink = sink; // } // // public Context(Context parentContext, Map<String, Object> entity) { // parent = new Parent(entity, parentContext.getParent()); // templates = parentContext.getTemplates(); // variables = parentContext.getVariables(); // sink = parentContext.getSink(); // } // // public Parent getParent() { // return parent; // } // // public Map<String, Object> getVariables() { // return variables; // } // // public Sink getSink() { // return sink; // } // // public Map<String, Template> getTemplates() { // return templates; // } // // } // // Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java // public class Field { // // private String name; // // private String type; // // private Provider provider; // // public Field() { // } // // public Field(String name, String type, Provider provider) { // this.name = name; // this.type = type; // this.provider = provider; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // public Provider getProvider() { // return provider; // } // // public void setProvider(Provider provider) { // this.provider = provider; // } // }
import com.presidentio.testdatagenerator.cons.PropConst; import com.presidentio.testdatagenerator.cons.TypeConst; import com.presidentio.testdatagenerator.context.Context; import com.presidentio.testdatagenerator.model.Field; import org.junit.Assert; import org.junit.Test; import java.util.HashMap; import java.util.Map;
/** * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.presidentio.testdatagenerator.provider; public class ExpressionProviderTest { @Test public void testNextValueSimpleMath() throws Exception { Map<String, String> props = new HashMap<>(); String propExpr = "2 + 10"; props.put(PropConst.EXPR, propExpr); ExpressionProvider expressionProvider = new ExpressionProvider(); expressionProvider.init(props);
// Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java // public class PropConst { // // public static final String TYPE = "type"; // public static final String VALUE = "value"; // public static final String SIZE = "size"; // public static final String DOMAIN = "domain"; // public static final String EXPR = "expr"; // public static final String FILE = "file"; // public static final String DELIMITER = "delimiter"; // public static final String ITEMS = "items"; // public static final String INDEX = "index"; // public static final String HOST = "host"; // public static final String PORT = "port"; // public static final String CLUSTER_NAME = "clusterName"; // public static final String CONNECTION_URL = "connectionUrl"; // public static final String JDBC_DRIVER = "jdbcDriver"; // public static final String DEPTH = "depth"; // public static final String FIELD = "field"; // public static final String VAR = "var"; // public static final String OP = "op"; // public static final String FORMAT = "format"; // public static final String HEADER = "header"; // public static final String SUFFIX = "suffix"; // public static final String PREFIX = "prefix"; // public static final String PATH_PROVIDER = "pathProvider"; // public static final String BROKER_LIST = "brokerList"; // public static final String GENDER = "gender"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/cons/TypeConst.java // public class TypeConst { // // public static final String STRING = "string"; // public static final String LONG = "long"; // public static final String INT = "int"; // public static final String BOOLEAN = "boolean"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java // public class Context { // // private Parent parent; // // private Map<String, Template> templates; // // private Map<String, Object> variables; // // private Sink sink; // // public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) { // this.templates = templates; // this.variables = variables; // this.sink = sink; // } // // public Context(Context parentContext, Map<String, Object> entity) { // parent = new Parent(entity, parentContext.getParent()); // templates = parentContext.getTemplates(); // variables = parentContext.getVariables(); // sink = parentContext.getSink(); // } // // public Parent getParent() { // return parent; // } // // public Map<String, Object> getVariables() { // return variables; // } // // public Sink getSink() { // return sink; // } // // public Map<String, Template> getTemplates() { // return templates; // } // // } // // Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java // public class Field { // // private String name; // // private String type; // // private Provider provider; // // public Field() { // } // // public Field(String name, String type, Provider provider) { // this.name = name; // this.type = type; // this.provider = provider; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // public Provider getProvider() { // return provider; // } // // public void setProvider(Provider provider) { // this.provider = provider; // } // } // Path: src/test/java/com/presidentio/testdatagenerator/provider/ExpressionProviderTest.java import com.presidentio.testdatagenerator.cons.PropConst; import com.presidentio.testdatagenerator.cons.TypeConst; import com.presidentio.testdatagenerator.context.Context; import com.presidentio.testdatagenerator.model.Field; import org.junit.Assert; import org.junit.Test; import java.util.HashMap; import java.util.Map; /** * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.presidentio.testdatagenerator.provider; public class ExpressionProviderTest { @Test public void testNextValueSimpleMath() throws Exception { Map<String, String> props = new HashMap<>(); String propExpr = "2 + 10"; props.put(PropConst.EXPR, propExpr); ExpressionProvider expressionProvider = new ExpressionProvider(); expressionProvider.init(props);
Context context = new Context(null, new HashMap<String, Object>(), null);
presidentio/test-data-generator
src/test/java/com/presidentio/testdatagenerator/provider/ExpressionProviderTest.java
// Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java // public class PropConst { // // public static final String TYPE = "type"; // public static final String VALUE = "value"; // public static final String SIZE = "size"; // public static final String DOMAIN = "domain"; // public static final String EXPR = "expr"; // public static final String FILE = "file"; // public static final String DELIMITER = "delimiter"; // public static final String ITEMS = "items"; // public static final String INDEX = "index"; // public static final String HOST = "host"; // public static final String PORT = "port"; // public static final String CLUSTER_NAME = "clusterName"; // public static final String CONNECTION_URL = "connectionUrl"; // public static final String JDBC_DRIVER = "jdbcDriver"; // public static final String DEPTH = "depth"; // public static final String FIELD = "field"; // public static final String VAR = "var"; // public static final String OP = "op"; // public static final String FORMAT = "format"; // public static final String HEADER = "header"; // public static final String SUFFIX = "suffix"; // public static final String PREFIX = "prefix"; // public static final String PATH_PROVIDER = "pathProvider"; // public static final String BROKER_LIST = "brokerList"; // public static final String GENDER = "gender"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/cons/TypeConst.java // public class TypeConst { // // public static final String STRING = "string"; // public static final String LONG = "long"; // public static final String INT = "int"; // public static final String BOOLEAN = "boolean"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java // public class Context { // // private Parent parent; // // private Map<String, Template> templates; // // private Map<String, Object> variables; // // private Sink sink; // // public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) { // this.templates = templates; // this.variables = variables; // this.sink = sink; // } // // public Context(Context parentContext, Map<String, Object> entity) { // parent = new Parent(entity, parentContext.getParent()); // templates = parentContext.getTemplates(); // variables = parentContext.getVariables(); // sink = parentContext.getSink(); // } // // public Parent getParent() { // return parent; // } // // public Map<String, Object> getVariables() { // return variables; // } // // public Sink getSink() { // return sink; // } // // public Map<String, Template> getTemplates() { // return templates; // } // // } // // Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java // public class Field { // // private String name; // // private String type; // // private Provider provider; // // public Field() { // } // // public Field(String name, String type, Provider provider) { // this.name = name; // this.type = type; // this.provider = provider; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // public Provider getProvider() { // return provider; // } // // public void setProvider(Provider provider) { // this.provider = provider; // } // }
import com.presidentio.testdatagenerator.cons.PropConst; import com.presidentio.testdatagenerator.cons.TypeConst; import com.presidentio.testdatagenerator.context.Context; import com.presidentio.testdatagenerator.model.Field; import org.junit.Assert; import org.junit.Test; import java.util.HashMap; import java.util.Map;
/** * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.presidentio.testdatagenerator.provider; public class ExpressionProviderTest { @Test public void testNextValueSimpleMath() throws Exception { Map<String, String> props = new HashMap<>(); String propExpr = "2 + 10"; props.put(PropConst.EXPR, propExpr); ExpressionProvider expressionProvider = new ExpressionProvider(); expressionProvider.init(props); Context context = new Context(null, new HashMap<String, Object>(), null);
// Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java // public class PropConst { // // public static final String TYPE = "type"; // public static final String VALUE = "value"; // public static final String SIZE = "size"; // public static final String DOMAIN = "domain"; // public static final String EXPR = "expr"; // public static final String FILE = "file"; // public static final String DELIMITER = "delimiter"; // public static final String ITEMS = "items"; // public static final String INDEX = "index"; // public static final String HOST = "host"; // public static final String PORT = "port"; // public static final String CLUSTER_NAME = "clusterName"; // public static final String CONNECTION_URL = "connectionUrl"; // public static final String JDBC_DRIVER = "jdbcDriver"; // public static final String DEPTH = "depth"; // public static final String FIELD = "field"; // public static final String VAR = "var"; // public static final String OP = "op"; // public static final String FORMAT = "format"; // public static final String HEADER = "header"; // public static final String SUFFIX = "suffix"; // public static final String PREFIX = "prefix"; // public static final String PATH_PROVIDER = "pathProvider"; // public static final String BROKER_LIST = "brokerList"; // public static final String GENDER = "gender"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/cons/TypeConst.java // public class TypeConst { // // public static final String STRING = "string"; // public static final String LONG = "long"; // public static final String INT = "int"; // public static final String BOOLEAN = "boolean"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java // public class Context { // // private Parent parent; // // private Map<String, Template> templates; // // private Map<String, Object> variables; // // private Sink sink; // // public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) { // this.templates = templates; // this.variables = variables; // this.sink = sink; // } // // public Context(Context parentContext, Map<String, Object> entity) { // parent = new Parent(entity, parentContext.getParent()); // templates = parentContext.getTemplates(); // variables = parentContext.getVariables(); // sink = parentContext.getSink(); // } // // public Parent getParent() { // return parent; // } // // public Map<String, Object> getVariables() { // return variables; // } // // public Sink getSink() { // return sink; // } // // public Map<String, Template> getTemplates() { // return templates; // } // // } // // Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java // public class Field { // // private String name; // // private String type; // // private Provider provider; // // public Field() { // } // // public Field(String name, String type, Provider provider) { // this.name = name; // this.type = type; // this.provider = provider; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // public Provider getProvider() { // return provider; // } // // public void setProvider(Provider provider) { // this.provider = provider; // } // } // Path: src/test/java/com/presidentio/testdatagenerator/provider/ExpressionProviderTest.java import com.presidentio.testdatagenerator.cons.PropConst; import com.presidentio.testdatagenerator.cons.TypeConst; import com.presidentio.testdatagenerator.context.Context; import com.presidentio.testdatagenerator.model.Field; import org.junit.Assert; import org.junit.Test; import java.util.HashMap; import java.util.Map; /** * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.presidentio.testdatagenerator.provider; public class ExpressionProviderTest { @Test public void testNextValueSimpleMath() throws Exception { Map<String, String> props = new HashMap<>(); String propExpr = "2 + 10"; props.put(PropConst.EXPR, propExpr); ExpressionProvider expressionProvider = new ExpressionProvider(); expressionProvider.init(props); Context context = new Context(null, new HashMap<String, Object>(), null);
Object result = expressionProvider.nextValue(context, new Field(null, TypeConst.INT, null));
presidentio/test-data-generator
src/test/java/com/presidentio/testdatagenerator/provider/ExpressionProviderTest.java
// Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java // public class PropConst { // // public static final String TYPE = "type"; // public static final String VALUE = "value"; // public static final String SIZE = "size"; // public static final String DOMAIN = "domain"; // public static final String EXPR = "expr"; // public static final String FILE = "file"; // public static final String DELIMITER = "delimiter"; // public static final String ITEMS = "items"; // public static final String INDEX = "index"; // public static final String HOST = "host"; // public static final String PORT = "port"; // public static final String CLUSTER_NAME = "clusterName"; // public static final String CONNECTION_URL = "connectionUrl"; // public static final String JDBC_DRIVER = "jdbcDriver"; // public static final String DEPTH = "depth"; // public static final String FIELD = "field"; // public static final String VAR = "var"; // public static final String OP = "op"; // public static final String FORMAT = "format"; // public static final String HEADER = "header"; // public static final String SUFFIX = "suffix"; // public static final String PREFIX = "prefix"; // public static final String PATH_PROVIDER = "pathProvider"; // public static final String BROKER_LIST = "brokerList"; // public static final String GENDER = "gender"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/cons/TypeConst.java // public class TypeConst { // // public static final String STRING = "string"; // public static final String LONG = "long"; // public static final String INT = "int"; // public static final String BOOLEAN = "boolean"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java // public class Context { // // private Parent parent; // // private Map<String, Template> templates; // // private Map<String, Object> variables; // // private Sink sink; // // public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) { // this.templates = templates; // this.variables = variables; // this.sink = sink; // } // // public Context(Context parentContext, Map<String, Object> entity) { // parent = new Parent(entity, parentContext.getParent()); // templates = parentContext.getTemplates(); // variables = parentContext.getVariables(); // sink = parentContext.getSink(); // } // // public Parent getParent() { // return parent; // } // // public Map<String, Object> getVariables() { // return variables; // } // // public Sink getSink() { // return sink; // } // // public Map<String, Template> getTemplates() { // return templates; // } // // } // // Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java // public class Field { // // private String name; // // private String type; // // private Provider provider; // // public Field() { // } // // public Field(String name, String type, Provider provider) { // this.name = name; // this.type = type; // this.provider = provider; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // public Provider getProvider() { // return provider; // } // // public void setProvider(Provider provider) { // this.provider = provider; // } // }
import com.presidentio.testdatagenerator.cons.PropConst; import com.presidentio.testdatagenerator.cons.TypeConst; import com.presidentio.testdatagenerator.context.Context; import com.presidentio.testdatagenerator.model.Field; import org.junit.Assert; import org.junit.Test; import java.util.HashMap; import java.util.Map;
/** * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.presidentio.testdatagenerator.provider; public class ExpressionProviderTest { @Test public void testNextValueSimpleMath() throws Exception { Map<String, String> props = new HashMap<>(); String propExpr = "2 + 10"; props.put(PropConst.EXPR, propExpr); ExpressionProvider expressionProvider = new ExpressionProvider(); expressionProvider.init(props); Context context = new Context(null, new HashMap<String, Object>(), null);
// Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java // public class PropConst { // // public static final String TYPE = "type"; // public static final String VALUE = "value"; // public static final String SIZE = "size"; // public static final String DOMAIN = "domain"; // public static final String EXPR = "expr"; // public static final String FILE = "file"; // public static final String DELIMITER = "delimiter"; // public static final String ITEMS = "items"; // public static final String INDEX = "index"; // public static final String HOST = "host"; // public static final String PORT = "port"; // public static final String CLUSTER_NAME = "clusterName"; // public static final String CONNECTION_URL = "connectionUrl"; // public static final String JDBC_DRIVER = "jdbcDriver"; // public static final String DEPTH = "depth"; // public static final String FIELD = "field"; // public static final String VAR = "var"; // public static final String OP = "op"; // public static final String FORMAT = "format"; // public static final String HEADER = "header"; // public static final String SUFFIX = "suffix"; // public static final String PREFIX = "prefix"; // public static final String PATH_PROVIDER = "pathProvider"; // public static final String BROKER_LIST = "brokerList"; // public static final String GENDER = "gender"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/cons/TypeConst.java // public class TypeConst { // // public static final String STRING = "string"; // public static final String LONG = "long"; // public static final String INT = "int"; // public static final String BOOLEAN = "boolean"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java // public class Context { // // private Parent parent; // // private Map<String, Template> templates; // // private Map<String, Object> variables; // // private Sink sink; // // public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) { // this.templates = templates; // this.variables = variables; // this.sink = sink; // } // // public Context(Context parentContext, Map<String, Object> entity) { // parent = new Parent(entity, parentContext.getParent()); // templates = parentContext.getTemplates(); // variables = parentContext.getVariables(); // sink = parentContext.getSink(); // } // // public Parent getParent() { // return parent; // } // // public Map<String, Object> getVariables() { // return variables; // } // // public Sink getSink() { // return sink; // } // // public Map<String, Template> getTemplates() { // return templates; // } // // } // // Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java // public class Field { // // private String name; // // private String type; // // private Provider provider; // // public Field() { // } // // public Field(String name, String type, Provider provider) { // this.name = name; // this.type = type; // this.provider = provider; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // public Provider getProvider() { // return provider; // } // // public void setProvider(Provider provider) { // this.provider = provider; // } // } // Path: src/test/java/com/presidentio/testdatagenerator/provider/ExpressionProviderTest.java import com.presidentio.testdatagenerator.cons.PropConst; import com.presidentio.testdatagenerator.cons.TypeConst; import com.presidentio.testdatagenerator.context.Context; import com.presidentio.testdatagenerator.model.Field; import org.junit.Assert; import org.junit.Test; import java.util.HashMap; import java.util.Map; /** * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.presidentio.testdatagenerator.provider; public class ExpressionProviderTest { @Test public void testNextValueSimpleMath() throws Exception { Map<String, String> props = new HashMap<>(); String propExpr = "2 + 10"; props.put(PropConst.EXPR, propExpr); ExpressionProvider expressionProvider = new ExpressionProvider(); expressionProvider.init(props); Context context = new Context(null, new HashMap<String, Object>(), null);
Object result = expressionProvider.nextValue(context, new Field(null, TypeConst.INT, null));
presidentio/test-data-generator
src/main/java/com/presidentio/testdatagenerator/output/path/TimeBasedPathProvider.java
// Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java // public class PropConst { // // public static final String TYPE = "type"; // public static final String VALUE = "value"; // public static final String SIZE = "size"; // public static final String DOMAIN = "domain"; // public static final String EXPR = "expr"; // public static final String FILE = "file"; // public static final String DELIMITER = "delimiter"; // public static final String ITEMS = "items"; // public static final String INDEX = "index"; // public static final String HOST = "host"; // public static final String PORT = "port"; // public static final String CLUSTER_NAME = "clusterName"; // public static final String CONNECTION_URL = "connectionUrl"; // public static final String JDBC_DRIVER = "jdbcDriver"; // public static final String DEPTH = "depth"; // public static final String FIELD = "field"; // public static final String VAR = "var"; // public static final String OP = "op"; // public static final String FORMAT = "format"; // public static final String HEADER = "header"; // public static final String SUFFIX = "suffix"; // public static final String PREFIX = "prefix"; // public static final String PATH_PROVIDER = "pathProvider"; // public static final String BROKER_LIST = "brokerList"; // public static final String GENDER = "gender"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/model/Template.java // public class Template { // // private String id; // // private String extend; // // @JsonIgnore // private Template extendTemplate; // // private Integer count; // // private String name; // // private List<Field> fields; // // private List<String> childs = new ArrayList<>(); // // public String getId() { // return id; // } // // public void setId(String id) { // this.id = id; // } // // public String getExtend() { // return extend; // } // // public void setExtend(String extend) { // this.extend = extend; // } // // public Template getExtendTemplate() { // return extendTemplate; // } // // public void setExtendTemplate(Template extendTemplate) { // this.extendTemplate = extendTemplate; // } // // public Integer getCount() { // if (count == null && extendTemplate != null) { // return extendTemplate.getCount(); // } // return count; // } // // public void setCount(Integer count) { // this.count = count; // } // // public String getName() { // if (name == null && extendTemplate != null) { // return extendTemplate.getName(); // } // return name; // } // // public void setName(String name) { // this.name = name; // } // // public List<Field> getFields() { // List<Field> result = new ArrayList<>(); // if (extendTemplate != null && extendTemplate.getFields() != null) { // result.addAll(extendTemplate.getFields()); // } // if (fields != null) { // result.addAll(fields); // } // return result; // } // // public void setFields(List<Field> fields) { // this.fields = fields; // } // // public List<String> getChilds() { // List<String> result = new ArrayList<>(); // if (extendTemplate != null && extendTemplate.getChilds() != null) { // result.addAll(extendTemplate.getChilds()); // } // if (childs != null) { // result.addAll(childs); // } // return result; // } // // public void setChilds(List<String> childs) { // this.childs = childs; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // Template template = (Template) o; // // if (name != null ? !name.equals(template.name) : template.name != null) return false; // // return true; // } // // @Override // public int hashCode() { // return name != null ? name.hashCode() : 0; // } // }
import com.presidentio.testdatagenerator.cons.PropConst; import com.presidentio.testdatagenerator.model.Template; import java.text.SimpleDateFormat; import java.util.*;
package com.presidentio.testdatagenerator.output.path; /** * Created by presidentio on 24.04.15. */ public class TimeBasedPathProvider implements PathProvider { private String suffix = ""; private String prefix = ""; private SimpleDateFormat format = new SimpleDateFormat("/yyyy/MM/dd/HH/"); @Override public void init(Map<String, String> props) {
// Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java // public class PropConst { // // public static final String TYPE = "type"; // public static final String VALUE = "value"; // public static final String SIZE = "size"; // public static final String DOMAIN = "domain"; // public static final String EXPR = "expr"; // public static final String FILE = "file"; // public static final String DELIMITER = "delimiter"; // public static final String ITEMS = "items"; // public static final String INDEX = "index"; // public static final String HOST = "host"; // public static final String PORT = "port"; // public static final String CLUSTER_NAME = "clusterName"; // public static final String CONNECTION_URL = "connectionUrl"; // public static final String JDBC_DRIVER = "jdbcDriver"; // public static final String DEPTH = "depth"; // public static final String FIELD = "field"; // public static final String VAR = "var"; // public static final String OP = "op"; // public static final String FORMAT = "format"; // public static final String HEADER = "header"; // public static final String SUFFIX = "suffix"; // public static final String PREFIX = "prefix"; // public static final String PATH_PROVIDER = "pathProvider"; // public static final String BROKER_LIST = "brokerList"; // public static final String GENDER = "gender"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/model/Template.java // public class Template { // // private String id; // // private String extend; // // @JsonIgnore // private Template extendTemplate; // // private Integer count; // // private String name; // // private List<Field> fields; // // private List<String> childs = new ArrayList<>(); // // public String getId() { // return id; // } // // public void setId(String id) { // this.id = id; // } // // public String getExtend() { // return extend; // } // // public void setExtend(String extend) { // this.extend = extend; // } // // public Template getExtendTemplate() { // return extendTemplate; // } // // public void setExtendTemplate(Template extendTemplate) { // this.extendTemplate = extendTemplate; // } // // public Integer getCount() { // if (count == null && extendTemplate != null) { // return extendTemplate.getCount(); // } // return count; // } // // public void setCount(Integer count) { // this.count = count; // } // // public String getName() { // if (name == null && extendTemplate != null) { // return extendTemplate.getName(); // } // return name; // } // // public void setName(String name) { // this.name = name; // } // // public List<Field> getFields() { // List<Field> result = new ArrayList<>(); // if (extendTemplate != null && extendTemplate.getFields() != null) { // result.addAll(extendTemplate.getFields()); // } // if (fields != null) { // result.addAll(fields); // } // return result; // } // // public void setFields(List<Field> fields) { // this.fields = fields; // } // // public List<String> getChilds() { // List<String> result = new ArrayList<>(); // if (extendTemplate != null && extendTemplate.getChilds() != null) { // result.addAll(extendTemplate.getChilds()); // } // if (childs != null) { // result.addAll(childs); // } // return result; // } // // public void setChilds(List<String> childs) { // this.childs = childs; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // Template template = (Template) o; // // if (name != null ? !name.equals(template.name) : template.name != null) return false; // // return true; // } // // @Override // public int hashCode() { // return name != null ? name.hashCode() : 0; // } // } // Path: src/main/java/com/presidentio/testdatagenerator/output/path/TimeBasedPathProvider.java import com.presidentio.testdatagenerator.cons.PropConst; import com.presidentio.testdatagenerator.model.Template; import java.text.SimpleDateFormat; import java.util.*; package com.presidentio.testdatagenerator.output.path; /** * Created by presidentio on 24.04.15. */ public class TimeBasedPathProvider implements PathProvider { private String suffix = ""; private String prefix = ""; private SimpleDateFormat format = new SimpleDateFormat("/yyyy/MM/dd/HH/"); @Override public void init(Map<String, String> props) {
if (props.containsKey(PropConst.SUFFIX)) {
presidentio/test-data-generator
src/main/java/com/presidentio/testdatagenerator/output/path/TimeBasedPathProvider.java
// Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java // public class PropConst { // // public static final String TYPE = "type"; // public static final String VALUE = "value"; // public static final String SIZE = "size"; // public static final String DOMAIN = "domain"; // public static final String EXPR = "expr"; // public static final String FILE = "file"; // public static final String DELIMITER = "delimiter"; // public static final String ITEMS = "items"; // public static final String INDEX = "index"; // public static final String HOST = "host"; // public static final String PORT = "port"; // public static final String CLUSTER_NAME = "clusterName"; // public static final String CONNECTION_URL = "connectionUrl"; // public static final String JDBC_DRIVER = "jdbcDriver"; // public static final String DEPTH = "depth"; // public static final String FIELD = "field"; // public static final String VAR = "var"; // public static final String OP = "op"; // public static final String FORMAT = "format"; // public static final String HEADER = "header"; // public static final String SUFFIX = "suffix"; // public static final String PREFIX = "prefix"; // public static final String PATH_PROVIDER = "pathProvider"; // public static final String BROKER_LIST = "brokerList"; // public static final String GENDER = "gender"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/model/Template.java // public class Template { // // private String id; // // private String extend; // // @JsonIgnore // private Template extendTemplate; // // private Integer count; // // private String name; // // private List<Field> fields; // // private List<String> childs = new ArrayList<>(); // // public String getId() { // return id; // } // // public void setId(String id) { // this.id = id; // } // // public String getExtend() { // return extend; // } // // public void setExtend(String extend) { // this.extend = extend; // } // // public Template getExtendTemplate() { // return extendTemplate; // } // // public void setExtendTemplate(Template extendTemplate) { // this.extendTemplate = extendTemplate; // } // // public Integer getCount() { // if (count == null && extendTemplate != null) { // return extendTemplate.getCount(); // } // return count; // } // // public void setCount(Integer count) { // this.count = count; // } // // public String getName() { // if (name == null && extendTemplate != null) { // return extendTemplate.getName(); // } // return name; // } // // public void setName(String name) { // this.name = name; // } // // public List<Field> getFields() { // List<Field> result = new ArrayList<>(); // if (extendTemplate != null && extendTemplate.getFields() != null) { // result.addAll(extendTemplate.getFields()); // } // if (fields != null) { // result.addAll(fields); // } // return result; // } // // public void setFields(List<Field> fields) { // this.fields = fields; // } // // public List<String> getChilds() { // List<String> result = new ArrayList<>(); // if (extendTemplate != null && extendTemplate.getChilds() != null) { // result.addAll(extendTemplate.getChilds()); // } // if (childs != null) { // result.addAll(childs); // } // return result; // } // // public void setChilds(List<String> childs) { // this.childs = childs; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // Template template = (Template) o; // // if (name != null ? !name.equals(template.name) : template.name != null) return false; // // return true; // } // // @Override // public int hashCode() { // return name != null ? name.hashCode() : 0; // } // }
import com.presidentio.testdatagenerator.cons.PropConst; import com.presidentio.testdatagenerator.model.Template; import java.text.SimpleDateFormat; import java.util.*;
package com.presidentio.testdatagenerator.output.path; /** * Created by presidentio on 24.04.15. */ public class TimeBasedPathProvider implements PathProvider { private String suffix = ""; private String prefix = ""; private SimpleDateFormat format = new SimpleDateFormat("/yyyy/MM/dd/HH/"); @Override public void init(Map<String, String> props) { if (props.containsKey(PropConst.SUFFIX)) { suffix = props.get(PropConst.SUFFIX); } if (props.containsKey(PropConst.PREFIX)) { prefix = props.get(PropConst.PREFIX); } } @Override
// Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java // public class PropConst { // // public static final String TYPE = "type"; // public static final String VALUE = "value"; // public static final String SIZE = "size"; // public static final String DOMAIN = "domain"; // public static final String EXPR = "expr"; // public static final String FILE = "file"; // public static final String DELIMITER = "delimiter"; // public static final String ITEMS = "items"; // public static final String INDEX = "index"; // public static final String HOST = "host"; // public static final String PORT = "port"; // public static final String CLUSTER_NAME = "clusterName"; // public static final String CONNECTION_URL = "connectionUrl"; // public static final String JDBC_DRIVER = "jdbcDriver"; // public static final String DEPTH = "depth"; // public static final String FIELD = "field"; // public static final String VAR = "var"; // public static final String OP = "op"; // public static final String FORMAT = "format"; // public static final String HEADER = "header"; // public static final String SUFFIX = "suffix"; // public static final String PREFIX = "prefix"; // public static final String PATH_PROVIDER = "pathProvider"; // public static final String BROKER_LIST = "brokerList"; // public static final String GENDER = "gender"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/model/Template.java // public class Template { // // private String id; // // private String extend; // // @JsonIgnore // private Template extendTemplate; // // private Integer count; // // private String name; // // private List<Field> fields; // // private List<String> childs = new ArrayList<>(); // // public String getId() { // return id; // } // // public void setId(String id) { // this.id = id; // } // // public String getExtend() { // return extend; // } // // public void setExtend(String extend) { // this.extend = extend; // } // // public Template getExtendTemplate() { // return extendTemplate; // } // // public void setExtendTemplate(Template extendTemplate) { // this.extendTemplate = extendTemplate; // } // // public Integer getCount() { // if (count == null && extendTemplate != null) { // return extendTemplate.getCount(); // } // return count; // } // // public void setCount(Integer count) { // this.count = count; // } // // public String getName() { // if (name == null && extendTemplate != null) { // return extendTemplate.getName(); // } // return name; // } // // public void setName(String name) { // this.name = name; // } // // public List<Field> getFields() { // List<Field> result = new ArrayList<>(); // if (extendTemplate != null && extendTemplate.getFields() != null) { // result.addAll(extendTemplate.getFields()); // } // if (fields != null) { // result.addAll(fields); // } // return result; // } // // public void setFields(List<Field> fields) { // this.fields = fields; // } // // public List<String> getChilds() { // List<String> result = new ArrayList<>(); // if (extendTemplate != null && extendTemplate.getChilds() != null) { // result.addAll(extendTemplate.getChilds()); // } // if (childs != null) { // result.addAll(childs); // } // return result; // } // // public void setChilds(List<String> childs) { // this.childs = childs; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // Template template = (Template) o; // // if (name != null ? !name.equals(template.name) : template.name != null) return false; // // return true; // } // // @Override // public int hashCode() { // return name != null ? name.hashCode() : 0; // } // } // Path: src/main/java/com/presidentio/testdatagenerator/output/path/TimeBasedPathProvider.java import com.presidentio.testdatagenerator.cons.PropConst; import com.presidentio.testdatagenerator.model.Template; import java.text.SimpleDateFormat; import java.util.*; package com.presidentio.testdatagenerator.output.path; /** * Created by presidentio on 24.04.15. */ public class TimeBasedPathProvider implements PathProvider { private String suffix = ""; private String prefix = ""; private SimpleDateFormat format = new SimpleDateFormat("/yyyy/MM/dd/HH/"); @Override public void init(Map<String, String> props) { if (props.containsKey(PropConst.SUFFIX)) { suffix = props.get(PropConst.SUFFIX); } if (props.containsKey(PropConst.PREFIX)) { prefix = props.get(PropConst.PREFIX); } } @Override
public String getFilePath(Template template, Map<String, Object> map) {
presidentio/test-data-generator
src/main/java/com/presidentio/testdatagenerator/context/Context.java
// Path: src/main/java/com/presidentio/testdatagenerator/model/Template.java // public class Template { // // private String id; // // private String extend; // // @JsonIgnore // private Template extendTemplate; // // private Integer count; // // private String name; // // private List<Field> fields; // // private List<String> childs = new ArrayList<>(); // // public String getId() { // return id; // } // // public void setId(String id) { // this.id = id; // } // // public String getExtend() { // return extend; // } // // public void setExtend(String extend) { // this.extend = extend; // } // // public Template getExtendTemplate() { // return extendTemplate; // } // // public void setExtendTemplate(Template extendTemplate) { // this.extendTemplate = extendTemplate; // } // // public Integer getCount() { // if (count == null && extendTemplate != null) { // return extendTemplate.getCount(); // } // return count; // } // // public void setCount(Integer count) { // this.count = count; // } // // public String getName() { // if (name == null && extendTemplate != null) { // return extendTemplate.getName(); // } // return name; // } // // public void setName(String name) { // this.name = name; // } // // public List<Field> getFields() { // List<Field> result = new ArrayList<>(); // if (extendTemplate != null && extendTemplate.getFields() != null) { // result.addAll(extendTemplate.getFields()); // } // if (fields != null) { // result.addAll(fields); // } // return result; // } // // public void setFields(List<Field> fields) { // this.fields = fields; // } // // public List<String> getChilds() { // List<String> result = new ArrayList<>(); // if (extendTemplate != null && extendTemplate.getChilds() != null) { // result.addAll(extendTemplate.getChilds()); // } // if (childs != null) { // result.addAll(childs); // } // return result; // } // // public void setChilds(List<String> childs) { // this.childs = childs; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // Template template = (Template) o; // // if (name != null ? !name.equals(template.name) : template.name != null) return false; // // return true; // } // // @Override // public int hashCode() { // return name != null ? name.hashCode() : 0; // } // } // // Path: src/main/java/com/presidentio/testdatagenerator/output/Sink.java // public interface Sink { // // void init(Map<String, String> props); // // void process(Template template, Map<String, Object> map); // // void close(); // // }
import com.presidentio.testdatagenerator.output.Sink; import java.util.Map; import com.presidentio.testdatagenerator.model.Template;
/** * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.presidentio.testdatagenerator.context; public class Context { private Parent parent;
// Path: src/main/java/com/presidentio/testdatagenerator/model/Template.java // public class Template { // // private String id; // // private String extend; // // @JsonIgnore // private Template extendTemplate; // // private Integer count; // // private String name; // // private List<Field> fields; // // private List<String> childs = new ArrayList<>(); // // public String getId() { // return id; // } // // public void setId(String id) { // this.id = id; // } // // public String getExtend() { // return extend; // } // // public void setExtend(String extend) { // this.extend = extend; // } // // public Template getExtendTemplate() { // return extendTemplate; // } // // public void setExtendTemplate(Template extendTemplate) { // this.extendTemplate = extendTemplate; // } // // public Integer getCount() { // if (count == null && extendTemplate != null) { // return extendTemplate.getCount(); // } // return count; // } // // public void setCount(Integer count) { // this.count = count; // } // // public String getName() { // if (name == null && extendTemplate != null) { // return extendTemplate.getName(); // } // return name; // } // // public void setName(String name) { // this.name = name; // } // // public List<Field> getFields() { // List<Field> result = new ArrayList<>(); // if (extendTemplate != null && extendTemplate.getFields() != null) { // result.addAll(extendTemplate.getFields()); // } // if (fields != null) { // result.addAll(fields); // } // return result; // } // // public void setFields(List<Field> fields) { // this.fields = fields; // } // // public List<String> getChilds() { // List<String> result = new ArrayList<>(); // if (extendTemplate != null && extendTemplate.getChilds() != null) { // result.addAll(extendTemplate.getChilds()); // } // if (childs != null) { // result.addAll(childs); // } // return result; // } // // public void setChilds(List<String> childs) { // this.childs = childs; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // Template template = (Template) o; // // if (name != null ? !name.equals(template.name) : template.name != null) return false; // // return true; // } // // @Override // public int hashCode() { // return name != null ? name.hashCode() : 0; // } // } // // Path: src/main/java/com/presidentio/testdatagenerator/output/Sink.java // public interface Sink { // // void init(Map<String, String> props); // // void process(Template template, Map<String, Object> map); // // void close(); // // } // Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java import com.presidentio.testdatagenerator.output.Sink; import java.util.Map; import com.presidentio.testdatagenerator.model.Template; /** * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.presidentio.testdatagenerator.context; public class Context { private Parent parent;
private Map<String, Template> templates;
presidentio/test-data-generator
src/main/java/com/presidentio/testdatagenerator/context/Context.java
// Path: src/main/java/com/presidentio/testdatagenerator/model/Template.java // public class Template { // // private String id; // // private String extend; // // @JsonIgnore // private Template extendTemplate; // // private Integer count; // // private String name; // // private List<Field> fields; // // private List<String> childs = new ArrayList<>(); // // public String getId() { // return id; // } // // public void setId(String id) { // this.id = id; // } // // public String getExtend() { // return extend; // } // // public void setExtend(String extend) { // this.extend = extend; // } // // public Template getExtendTemplate() { // return extendTemplate; // } // // public void setExtendTemplate(Template extendTemplate) { // this.extendTemplate = extendTemplate; // } // // public Integer getCount() { // if (count == null && extendTemplate != null) { // return extendTemplate.getCount(); // } // return count; // } // // public void setCount(Integer count) { // this.count = count; // } // // public String getName() { // if (name == null && extendTemplate != null) { // return extendTemplate.getName(); // } // return name; // } // // public void setName(String name) { // this.name = name; // } // // public List<Field> getFields() { // List<Field> result = new ArrayList<>(); // if (extendTemplate != null && extendTemplate.getFields() != null) { // result.addAll(extendTemplate.getFields()); // } // if (fields != null) { // result.addAll(fields); // } // return result; // } // // public void setFields(List<Field> fields) { // this.fields = fields; // } // // public List<String> getChilds() { // List<String> result = new ArrayList<>(); // if (extendTemplate != null && extendTemplate.getChilds() != null) { // result.addAll(extendTemplate.getChilds()); // } // if (childs != null) { // result.addAll(childs); // } // return result; // } // // public void setChilds(List<String> childs) { // this.childs = childs; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // Template template = (Template) o; // // if (name != null ? !name.equals(template.name) : template.name != null) return false; // // return true; // } // // @Override // public int hashCode() { // return name != null ? name.hashCode() : 0; // } // } // // Path: src/main/java/com/presidentio/testdatagenerator/output/Sink.java // public interface Sink { // // void init(Map<String, String> props); // // void process(Template template, Map<String, Object> map); // // void close(); // // }
import com.presidentio.testdatagenerator.output.Sink; import java.util.Map; import com.presidentio.testdatagenerator.model.Template;
/** * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.presidentio.testdatagenerator.context; public class Context { private Parent parent; private Map<String, Template> templates; private Map<String, Object> variables;
// Path: src/main/java/com/presidentio/testdatagenerator/model/Template.java // public class Template { // // private String id; // // private String extend; // // @JsonIgnore // private Template extendTemplate; // // private Integer count; // // private String name; // // private List<Field> fields; // // private List<String> childs = new ArrayList<>(); // // public String getId() { // return id; // } // // public void setId(String id) { // this.id = id; // } // // public String getExtend() { // return extend; // } // // public void setExtend(String extend) { // this.extend = extend; // } // // public Template getExtendTemplate() { // return extendTemplate; // } // // public void setExtendTemplate(Template extendTemplate) { // this.extendTemplate = extendTemplate; // } // // public Integer getCount() { // if (count == null && extendTemplate != null) { // return extendTemplate.getCount(); // } // return count; // } // // public void setCount(Integer count) { // this.count = count; // } // // public String getName() { // if (name == null && extendTemplate != null) { // return extendTemplate.getName(); // } // return name; // } // // public void setName(String name) { // this.name = name; // } // // public List<Field> getFields() { // List<Field> result = new ArrayList<>(); // if (extendTemplate != null && extendTemplate.getFields() != null) { // result.addAll(extendTemplate.getFields()); // } // if (fields != null) { // result.addAll(fields); // } // return result; // } // // public void setFields(List<Field> fields) { // this.fields = fields; // } // // public List<String> getChilds() { // List<String> result = new ArrayList<>(); // if (extendTemplate != null && extendTemplate.getChilds() != null) { // result.addAll(extendTemplate.getChilds()); // } // if (childs != null) { // result.addAll(childs); // } // return result; // } // // public void setChilds(List<String> childs) { // this.childs = childs; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // Template template = (Template) o; // // if (name != null ? !name.equals(template.name) : template.name != null) return false; // // return true; // } // // @Override // public int hashCode() { // return name != null ? name.hashCode() : 0; // } // } // // Path: src/main/java/com/presidentio/testdatagenerator/output/Sink.java // public interface Sink { // // void init(Map<String, String> props); // // void process(Template template, Map<String, Object> map); // // void close(); // // } // Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java import com.presidentio.testdatagenerator.output.Sink; import java.util.Map; import com.presidentio.testdatagenerator.model.Template; /** * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.presidentio.testdatagenerator.context; public class Context { private Parent parent; private Map<String, Template> templates; private Map<String, Object> variables;
private Sink sink;
presidentio/test-data-generator
src/main/java/com/presidentio/testdatagenerator/benchmark/ConstBenchmark.java
// Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java // public class PropConst { // // public static final String TYPE = "type"; // public static final String VALUE = "value"; // public static final String SIZE = "size"; // public static final String DOMAIN = "domain"; // public static final String EXPR = "expr"; // public static final String FILE = "file"; // public static final String DELIMITER = "delimiter"; // public static final String ITEMS = "items"; // public static final String INDEX = "index"; // public static final String HOST = "host"; // public static final String PORT = "port"; // public static final String CLUSTER_NAME = "clusterName"; // public static final String CONNECTION_URL = "connectionUrl"; // public static final String JDBC_DRIVER = "jdbcDriver"; // public static final String DEPTH = "depth"; // public static final String FIELD = "field"; // public static final String VAR = "var"; // public static final String OP = "op"; // public static final String FORMAT = "format"; // public static final String HEADER = "header"; // public static final String SUFFIX = "suffix"; // public static final String PREFIX = "prefix"; // public static final String PATH_PROVIDER = "pathProvider"; // public static final String BROKER_LIST = "brokerList"; // public static final String GENDER = "gender"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/cons/TypeConst.java // public class TypeConst { // // public static final String STRING = "string"; // public static final String LONG = "long"; // public static final String INT = "int"; // public static final String BOOLEAN = "boolean"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java // public class Context { // // private Parent parent; // // private Map<String, Template> templates; // // private Map<String, Object> variables; // // private Sink sink; // // public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) { // this.templates = templates; // this.variables = variables; // this.sink = sink; // } // // public Context(Context parentContext, Map<String, Object> entity) { // parent = new Parent(entity, parentContext.getParent()); // templates = parentContext.getTemplates(); // variables = parentContext.getVariables(); // sink = parentContext.getSink(); // } // // public Parent getParent() { // return parent; // } // // public Map<String, Object> getVariables() { // return variables; // } // // public Sink getSink() { // return sink; // } // // public Map<String, Template> getTemplates() { // return templates; // } // // } // // Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java // public class Field { // // private String name; // // private String type; // // private Provider provider; // // public Field() { // } // // public Field(String name, String type, Provider provider) { // this.name = name; // this.type = type; // this.provider = provider; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // public Provider getProvider() { // return provider; // } // // public void setProvider(Provider provider) { // this.provider = provider; // } // } // // Path: src/main/java/com/presidentio/testdatagenerator/provider/ConstValueProvider.java // public class ConstValueProvider implements ValueProvider { // // private String value; // // @Override // public void init(Map<String, String> props) { // Map<String, String> propsCopy = new HashMap<>(props); // value = propsCopy.remove(PropConst.VALUE); // if (value == null) { // throw new IllegalArgumentException("Value does not specified or null"); // } // if (!propsCopy.isEmpty()) { // throw new IllegalArgumentException("Redundant props for ConstValueProvider: " + propsCopy); // } // } // // @Override // public Object nextValue(Context context, Field field) { // String type = field.getType(); // switch (type) { // case TypeConst.STRING: // return value; // case TypeConst.LONG: // return Long.valueOf(value); // case TypeConst.INT: // return Integer.valueOf(value); // case TypeConst.BOOLEAN: // return Boolean.valueOf(value); // default: // throw new IllegalArgumentException("Field type not known: " + type); // } // } // // } // // Path: src/main/java/com/presidentio/testdatagenerator/provider/ValueProvider.java // public interface ValueProvider { // // void init(Map<String, String> props); // // Object nextValue(Context context, Field field); // // }
import com.presidentio.testdatagenerator.cons.PropConst; import com.presidentio.testdatagenerator.cons.TypeConst; import com.presidentio.testdatagenerator.context.Context; import com.presidentio.testdatagenerator.model.Field; import com.presidentio.testdatagenerator.provider.ConstValueProvider; import com.presidentio.testdatagenerator.provider.ValueProvider; import org.openjdk.jmh.annotations.*; import java.util.HashMap; import java.util.Map; import java.util.concurrent.TimeUnit;
package com.presidentio.testdatagenerator.benchmark; /** * Created by Vitalii_Gergel on 3/19/2015. */ @Fork(1) @Warmup(iterations = 3) @OutputTimeUnit(TimeUnit.MICROSECONDS) @Measurement(iterations = 10) @State(Scope.Benchmark) public class ConstBenchmark {
// Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java // public class PropConst { // // public static final String TYPE = "type"; // public static final String VALUE = "value"; // public static final String SIZE = "size"; // public static final String DOMAIN = "domain"; // public static final String EXPR = "expr"; // public static final String FILE = "file"; // public static final String DELIMITER = "delimiter"; // public static final String ITEMS = "items"; // public static final String INDEX = "index"; // public static final String HOST = "host"; // public static final String PORT = "port"; // public static final String CLUSTER_NAME = "clusterName"; // public static final String CONNECTION_URL = "connectionUrl"; // public static final String JDBC_DRIVER = "jdbcDriver"; // public static final String DEPTH = "depth"; // public static final String FIELD = "field"; // public static final String VAR = "var"; // public static final String OP = "op"; // public static final String FORMAT = "format"; // public static final String HEADER = "header"; // public static final String SUFFIX = "suffix"; // public static final String PREFIX = "prefix"; // public static final String PATH_PROVIDER = "pathProvider"; // public static final String BROKER_LIST = "brokerList"; // public static final String GENDER = "gender"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/cons/TypeConst.java // public class TypeConst { // // public static final String STRING = "string"; // public static final String LONG = "long"; // public static final String INT = "int"; // public static final String BOOLEAN = "boolean"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java // public class Context { // // private Parent parent; // // private Map<String, Template> templates; // // private Map<String, Object> variables; // // private Sink sink; // // public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) { // this.templates = templates; // this.variables = variables; // this.sink = sink; // } // // public Context(Context parentContext, Map<String, Object> entity) { // parent = new Parent(entity, parentContext.getParent()); // templates = parentContext.getTemplates(); // variables = parentContext.getVariables(); // sink = parentContext.getSink(); // } // // public Parent getParent() { // return parent; // } // // public Map<String, Object> getVariables() { // return variables; // } // // public Sink getSink() { // return sink; // } // // public Map<String, Template> getTemplates() { // return templates; // } // // } // // Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java // public class Field { // // private String name; // // private String type; // // private Provider provider; // // public Field() { // } // // public Field(String name, String type, Provider provider) { // this.name = name; // this.type = type; // this.provider = provider; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // public Provider getProvider() { // return provider; // } // // public void setProvider(Provider provider) { // this.provider = provider; // } // } // // Path: src/main/java/com/presidentio/testdatagenerator/provider/ConstValueProvider.java // public class ConstValueProvider implements ValueProvider { // // private String value; // // @Override // public void init(Map<String, String> props) { // Map<String, String> propsCopy = new HashMap<>(props); // value = propsCopy.remove(PropConst.VALUE); // if (value == null) { // throw new IllegalArgumentException("Value does not specified or null"); // } // if (!propsCopy.isEmpty()) { // throw new IllegalArgumentException("Redundant props for ConstValueProvider: " + propsCopy); // } // } // // @Override // public Object nextValue(Context context, Field field) { // String type = field.getType(); // switch (type) { // case TypeConst.STRING: // return value; // case TypeConst.LONG: // return Long.valueOf(value); // case TypeConst.INT: // return Integer.valueOf(value); // case TypeConst.BOOLEAN: // return Boolean.valueOf(value); // default: // throw new IllegalArgumentException("Field type not known: " + type); // } // } // // } // // Path: src/main/java/com/presidentio/testdatagenerator/provider/ValueProvider.java // public interface ValueProvider { // // void init(Map<String, String> props); // // Object nextValue(Context context, Field field); // // } // Path: src/main/java/com/presidentio/testdatagenerator/benchmark/ConstBenchmark.java import com.presidentio.testdatagenerator.cons.PropConst; import com.presidentio.testdatagenerator.cons.TypeConst; import com.presidentio.testdatagenerator.context.Context; import com.presidentio.testdatagenerator.model.Field; import com.presidentio.testdatagenerator.provider.ConstValueProvider; import com.presidentio.testdatagenerator.provider.ValueProvider; import org.openjdk.jmh.annotations.*; import java.util.HashMap; import java.util.Map; import java.util.concurrent.TimeUnit; package com.presidentio.testdatagenerator.benchmark; /** * Created by Vitalii_Gergel on 3/19/2015. */ @Fork(1) @Warmup(iterations = 3) @OutputTimeUnit(TimeUnit.MICROSECONDS) @Measurement(iterations = 10) @State(Scope.Benchmark) public class ConstBenchmark {
private Context context;
presidentio/test-data-generator
src/main/java/com/presidentio/testdatagenerator/benchmark/ConstBenchmark.java
// Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java // public class PropConst { // // public static final String TYPE = "type"; // public static final String VALUE = "value"; // public static final String SIZE = "size"; // public static final String DOMAIN = "domain"; // public static final String EXPR = "expr"; // public static final String FILE = "file"; // public static final String DELIMITER = "delimiter"; // public static final String ITEMS = "items"; // public static final String INDEX = "index"; // public static final String HOST = "host"; // public static final String PORT = "port"; // public static final String CLUSTER_NAME = "clusterName"; // public static final String CONNECTION_URL = "connectionUrl"; // public static final String JDBC_DRIVER = "jdbcDriver"; // public static final String DEPTH = "depth"; // public static final String FIELD = "field"; // public static final String VAR = "var"; // public static final String OP = "op"; // public static final String FORMAT = "format"; // public static final String HEADER = "header"; // public static final String SUFFIX = "suffix"; // public static final String PREFIX = "prefix"; // public static final String PATH_PROVIDER = "pathProvider"; // public static final String BROKER_LIST = "brokerList"; // public static final String GENDER = "gender"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/cons/TypeConst.java // public class TypeConst { // // public static final String STRING = "string"; // public static final String LONG = "long"; // public static final String INT = "int"; // public static final String BOOLEAN = "boolean"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java // public class Context { // // private Parent parent; // // private Map<String, Template> templates; // // private Map<String, Object> variables; // // private Sink sink; // // public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) { // this.templates = templates; // this.variables = variables; // this.sink = sink; // } // // public Context(Context parentContext, Map<String, Object> entity) { // parent = new Parent(entity, parentContext.getParent()); // templates = parentContext.getTemplates(); // variables = parentContext.getVariables(); // sink = parentContext.getSink(); // } // // public Parent getParent() { // return parent; // } // // public Map<String, Object> getVariables() { // return variables; // } // // public Sink getSink() { // return sink; // } // // public Map<String, Template> getTemplates() { // return templates; // } // // } // // Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java // public class Field { // // private String name; // // private String type; // // private Provider provider; // // public Field() { // } // // public Field(String name, String type, Provider provider) { // this.name = name; // this.type = type; // this.provider = provider; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // public Provider getProvider() { // return provider; // } // // public void setProvider(Provider provider) { // this.provider = provider; // } // } // // Path: src/main/java/com/presidentio/testdatagenerator/provider/ConstValueProvider.java // public class ConstValueProvider implements ValueProvider { // // private String value; // // @Override // public void init(Map<String, String> props) { // Map<String, String> propsCopy = new HashMap<>(props); // value = propsCopy.remove(PropConst.VALUE); // if (value == null) { // throw new IllegalArgumentException("Value does not specified or null"); // } // if (!propsCopy.isEmpty()) { // throw new IllegalArgumentException("Redundant props for ConstValueProvider: " + propsCopy); // } // } // // @Override // public Object nextValue(Context context, Field field) { // String type = field.getType(); // switch (type) { // case TypeConst.STRING: // return value; // case TypeConst.LONG: // return Long.valueOf(value); // case TypeConst.INT: // return Integer.valueOf(value); // case TypeConst.BOOLEAN: // return Boolean.valueOf(value); // default: // throw new IllegalArgumentException("Field type not known: " + type); // } // } // // } // // Path: src/main/java/com/presidentio/testdatagenerator/provider/ValueProvider.java // public interface ValueProvider { // // void init(Map<String, String> props); // // Object nextValue(Context context, Field field); // // }
import com.presidentio.testdatagenerator.cons.PropConst; import com.presidentio.testdatagenerator.cons.TypeConst; import com.presidentio.testdatagenerator.context.Context; import com.presidentio.testdatagenerator.model.Field; import com.presidentio.testdatagenerator.provider.ConstValueProvider; import com.presidentio.testdatagenerator.provider.ValueProvider; import org.openjdk.jmh.annotations.*; import java.util.HashMap; import java.util.Map; import java.util.concurrent.TimeUnit;
package com.presidentio.testdatagenerator.benchmark; /** * Created by Vitalii_Gergel on 3/19/2015. */ @Fork(1) @Warmup(iterations = 3) @OutputTimeUnit(TimeUnit.MICROSECONDS) @Measurement(iterations = 10) @State(Scope.Benchmark) public class ConstBenchmark { private Context context;
// Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java // public class PropConst { // // public static final String TYPE = "type"; // public static final String VALUE = "value"; // public static final String SIZE = "size"; // public static final String DOMAIN = "domain"; // public static final String EXPR = "expr"; // public static final String FILE = "file"; // public static final String DELIMITER = "delimiter"; // public static final String ITEMS = "items"; // public static final String INDEX = "index"; // public static final String HOST = "host"; // public static final String PORT = "port"; // public static final String CLUSTER_NAME = "clusterName"; // public static final String CONNECTION_URL = "connectionUrl"; // public static final String JDBC_DRIVER = "jdbcDriver"; // public static final String DEPTH = "depth"; // public static final String FIELD = "field"; // public static final String VAR = "var"; // public static final String OP = "op"; // public static final String FORMAT = "format"; // public static final String HEADER = "header"; // public static final String SUFFIX = "suffix"; // public static final String PREFIX = "prefix"; // public static final String PATH_PROVIDER = "pathProvider"; // public static final String BROKER_LIST = "brokerList"; // public static final String GENDER = "gender"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/cons/TypeConst.java // public class TypeConst { // // public static final String STRING = "string"; // public static final String LONG = "long"; // public static final String INT = "int"; // public static final String BOOLEAN = "boolean"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java // public class Context { // // private Parent parent; // // private Map<String, Template> templates; // // private Map<String, Object> variables; // // private Sink sink; // // public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) { // this.templates = templates; // this.variables = variables; // this.sink = sink; // } // // public Context(Context parentContext, Map<String, Object> entity) { // parent = new Parent(entity, parentContext.getParent()); // templates = parentContext.getTemplates(); // variables = parentContext.getVariables(); // sink = parentContext.getSink(); // } // // public Parent getParent() { // return parent; // } // // public Map<String, Object> getVariables() { // return variables; // } // // public Sink getSink() { // return sink; // } // // public Map<String, Template> getTemplates() { // return templates; // } // // } // // Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java // public class Field { // // private String name; // // private String type; // // private Provider provider; // // public Field() { // } // // public Field(String name, String type, Provider provider) { // this.name = name; // this.type = type; // this.provider = provider; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // public Provider getProvider() { // return provider; // } // // public void setProvider(Provider provider) { // this.provider = provider; // } // } // // Path: src/main/java/com/presidentio/testdatagenerator/provider/ConstValueProvider.java // public class ConstValueProvider implements ValueProvider { // // private String value; // // @Override // public void init(Map<String, String> props) { // Map<String, String> propsCopy = new HashMap<>(props); // value = propsCopy.remove(PropConst.VALUE); // if (value == null) { // throw new IllegalArgumentException("Value does not specified or null"); // } // if (!propsCopy.isEmpty()) { // throw new IllegalArgumentException("Redundant props for ConstValueProvider: " + propsCopy); // } // } // // @Override // public Object nextValue(Context context, Field field) { // String type = field.getType(); // switch (type) { // case TypeConst.STRING: // return value; // case TypeConst.LONG: // return Long.valueOf(value); // case TypeConst.INT: // return Integer.valueOf(value); // case TypeConst.BOOLEAN: // return Boolean.valueOf(value); // default: // throw new IllegalArgumentException("Field type not known: " + type); // } // } // // } // // Path: src/main/java/com/presidentio/testdatagenerator/provider/ValueProvider.java // public interface ValueProvider { // // void init(Map<String, String> props); // // Object nextValue(Context context, Field field); // // } // Path: src/main/java/com/presidentio/testdatagenerator/benchmark/ConstBenchmark.java import com.presidentio.testdatagenerator.cons.PropConst; import com.presidentio.testdatagenerator.cons.TypeConst; import com.presidentio.testdatagenerator.context.Context; import com.presidentio.testdatagenerator.model.Field; import com.presidentio.testdatagenerator.provider.ConstValueProvider; import com.presidentio.testdatagenerator.provider.ValueProvider; import org.openjdk.jmh.annotations.*; import java.util.HashMap; import java.util.Map; import java.util.concurrent.TimeUnit; package com.presidentio.testdatagenerator.benchmark; /** * Created by Vitalii_Gergel on 3/19/2015. */ @Fork(1) @Warmup(iterations = 3) @OutputTimeUnit(TimeUnit.MICROSECONDS) @Measurement(iterations = 10) @State(Scope.Benchmark) public class ConstBenchmark { private Context context;
private ValueProvider valueProvider;
presidentio/test-data-generator
src/main/java/com/presidentio/testdatagenerator/benchmark/ConstBenchmark.java
// Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java // public class PropConst { // // public static final String TYPE = "type"; // public static final String VALUE = "value"; // public static final String SIZE = "size"; // public static final String DOMAIN = "domain"; // public static final String EXPR = "expr"; // public static final String FILE = "file"; // public static final String DELIMITER = "delimiter"; // public static final String ITEMS = "items"; // public static final String INDEX = "index"; // public static final String HOST = "host"; // public static final String PORT = "port"; // public static final String CLUSTER_NAME = "clusterName"; // public static final String CONNECTION_URL = "connectionUrl"; // public static final String JDBC_DRIVER = "jdbcDriver"; // public static final String DEPTH = "depth"; // public static final String FIELD = "field"; // public static final String VAR = "var"; // public static final String OP = "op"; // public static final String FORMAT = "format"; // public static final String HEADER = "header"; // public static final String SUFFIX = "suffix"; // public static final String PREFIX = "prefix"; // public static final String PATH_PROVIDER = "pathProvider"; // public static final String BROKER_LIST = "brokerList"; // public static final String GENDER = "gender"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/cons/TypeConst.java // public class TypeConst { // // public static final String STRING = "string"; // public static final String LONG = "long"; // public static final String INT = "int"; // public static final String BOOLEAN = "boolean"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java // public class Context { // // private Parent parent; // // private Map<String, Template> templates; // // private Map<String, Object> variables; // // private Sink sink; // // public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) { // this.templates = templates; // this.variables = variables; // this.sink = sink; // } // // public Context(Context parentContext, Map<String, Object> entity) { // parent = new Parent(entity, parentContext.getParent()); // templates = parentContext.getTemplates(); // variables = parentContext.getVariables(); // sink = parentContext.getSink(); // } // // public Parent getParent() { // return parent; // } // // public Map<String, Object> getVariables() { // return variables; // } // // public Sink getSink() { // return sink; // } // // public Map<String, Template> getTemplates() { // return templates; // } // // } // // Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java // public class Field { // // private String name; // // private String type; // // private Provider provider; // // public Field() { // } // // public Field(String name, String type, Provider provider) { // this.name = name; // this.type = type; // this.provider = provider; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // public Provider getProvider() { // return provider; // } // // public void setProvider(Provider provider) { // this.provider = provider; // } // } // // Path: src/main/java/com/presidentio/testdatagenerator/provider/ConstValueProvider.java // public class ConstValueProvider implements ValueProvider { // // private String value; // // @Override // public void init(Map<String, String> props) { // Map<String, String> propsCopy = new HashMap<>(props); // value = propsCopy.remove(PropConst.VALUE); // if (value == null) { // throw new IllegalArgumentException("Value does not specified or null"); // } // if (!propsCopy.isEmpty()) { // throw new IllegalArgumentException("Redundant props for ConstValueProvider: " + propsCopy); // } // } // // @Override // public Object nextValue(Context context, Field field) { // String type = field.getType(); // switch (type) { // case TypeConst.STRING: // return value; // case TypeConst.LONG: // return Long.valueOf(value); // case TypeConst.INT: // return Integer.valueOf(value); // case TypeConst.BOOLEAN: // return Boolean.valueOf(value); // default: // throw new IllegalArgumentException("Field type not known: " + type); // } // } // // } // // Path: src/main/java/com/presidentio/testdatagenerator/provider/ValueProvider.java // public interface ValueProvider { // // void init(Map<String, String> props); // // Object nextValue(Context context, Field field); // // }
import com.presidentio.testdatagenerator.cons.PropConst; import com.presidentio.testdatagenerator.cons.TypeConst; import com.presidentio.testdatagenerator.context.Context; import com.presidentio.testdatagenerator.model.Field; import com.presidentio.testdatagenerator.provider.ConstValueProvider; import com.presidentio.testdatagenerator.provider.ValueProvider; import org.openjdk.jmh.annotations.*; import java.util.HashMap; import java.util.Map; import java.util.concurrent.TimeUnit;
package com.presidentio.testdatagenerator.benchmark; /** * Created by Vitalii_Gergel on 3/19/2015. */ @Fork(1) @Warmup(iterations = 3) @OutputTimeUnit(TimeUnit.MICROSECONDS) @Measurement(iterations = 10) @State(Scope.Benchmark) public class ConstBenchmark { private Context context; private ValueProvider valueProvider;
// Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java // public class PropConst { // // public static final String TYPE = "type"; // public static final String VALUE = "value"; // public static final String SIZE = "size"; // public static final String DOMAIN = "domain"; // public static final String EXPR = "expr"; // public static final String FILE = "file"; // public static final String DELIMITER = "delimiter"; // public static final String ITEMS = "items"; // public static final String INDEX = "index"; // public static final String HOST = "host"; // public static final String PORT = "port"; // public static final String CLUSTER_NAME = "clusterName"; // public static final String CONNECTION_URL = "connectionUrl"; // public static final String JDBC_DRIVER = "jdbcDriver"; // public static final String DEPTH = "depth"; // public static final String FIELD = "field"; // public static final String VAR = "var"; // public static final String OP = "op"; // public static final String FORMAT = "format"; // public static final String HEADER = "header"; // public static final String SUFFIX = "suffix"; // public static final String PREFIX = "prefix"; // public static final String PATH_PROVIDER = "pathProvider"; // public static final String BROKER_LIST = "brokerList"; // public static final String GENDER = "gender"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/cons/TypeConst.java // public class TypeConst { // // public static final String STRING = "string"; // public static final String LONG = "long"; // public static final String INT = "int"; // public static final String BOOLEAN = "boolean"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java // public class Context { // // private Parent parent; // // private Map<String, Template> templates; // // private Map<String, Object> variables; // // private Sink sink; // // public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) { // this.templates = templates; // this.variables = variables; // this.sink = sink; // } // // public Context(Context parentContext, Map<String, Object> entity) { // parent = new Parent(entity, parentContext.getParent()); // templates = parentContext.getTemplates(); // variables = parentContext.getVariables(); // sink = parentContext.getSink(); // } // // public Parent getParent() { // return parent; // } // // public Map<String, Object> getVariables() { // return variables; // } // // public Sink getSink() { // return sink; // } // // public Map<String, Template> getTemplates() { // return templates; // } // // } // // Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java // public class Field { // // private String name; // // private String type; // // private Provider provider; // // public Field() { // } // // public Field(String name, String type, Provider provider) { // this.name = name; // this.type = type; // this.provider = provider; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // public Provider getProvider() { // return provider; // } // // public void setProvider(Provider provider) { // this.provider = provider; // } // } // // Path: src/main/java/com/presidentio/testdatagenerator/provider/ConstValueProvider.java // public class ConstValueProvider implements ValueProvider { // // private String value; // // @Override // public void init(Map<String, String> props) { // Map<String, String> propsCopy = new HashMap<>(props); // value = propsCopy.remove(PropConst.VALUE); // if (value == null) { // throw new IllegalArgumentException("Value does not specified or null"); // } // if (!propsCopy.isEmpty()) { // throw new IllegalArgumentException("Redundant props for ConstValueProvider: " + propsCopy); // } // } // // @Override // public Object nextValue(Context context, Field field) { // String type = field.getType(); // switch (type) { // case TypeConst.STRING: // return value; // case TypeConst.LONG: // return Long.valueOf(value); // case TypeConst.INT: // return Integer.valueOf(value); // case TypeConst.BOOLEAN: // return Boolean.valueOf(value); // default: // throw new IllegalArgumentException("Field type not known: " + type); // } // } // // } // // Path: src/main/java/com/presidentio/testdatagenerator/provider/ValueProvider.java // public interface ValueProvider { // // void init(Map<String, String> props); // // Object nextValue(Context context, Field field); // // } // Path: src/main/java/com/presidentio/testdatagenerator/benchmark/ConstBenchmark.java import com.presidentio.testdatagenerator.cons.PropConst; import com.presidentio.testdatagenerator.cons.TypeConst; import com.presidentio.testdatagenerator.context.Context; import com.presidentio.testdatagenerator.model.Field; import com.presidentio.testdatagenerator.provider.ConstValueProvider; import com.presidentio.testdatagenerator.provider.ValueProvider; import org.openjdk.jmh.annotations.*; import java.util.HashMap; import java.util.Map; import java.util.concurrent.TimeUnit; package com.presidentio.testdatagenerator.benchmark; /** * Created by Vitalii_Gergel on 3/19/2015. */ @Fork(1) @Warmup(iterations = 3) @OutputTimeUnit(TimeUnit.MICROSECONDS) @Measurement(iterations = 10) @State(Scope.Benchmark) public class ConstBenchmark { private Context context; private ValueProvider valueProvider;
private Field field;
presidentio/test-data-generator
src/main/java/com/presidentio/testdatagenerator/benchmark/ConstBenchmark.java
// Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java // public class PropConst { // // public static final String TYPE = "type"; // public static final String VALUE = "value"; // public static final String SIZE = "size"; // public static final String DOMAIN = "domain"; // public static final String EXPR = "expr"; // public static final String FILE = "file"; // public static final String DELIMITER = "delimiter"; // public static final String ITEMS = "items"; // public static final String INDEX = "index"; // public static final String HOST = "host"; // public static final String PORT = "port"; // public static final String CLUSTER_NAME = "clusterName"; // public static final String CONNECTION_URL = "connectionUrl"; // public static final String JDBC_DRIVER = "jdbcDriver"; // public static final String DEPTH = "depth"; // public static final String FIELD = "field"; // public static final String VAR = "var"; // public static final String OP = "op"; // public static final String FORMAT = "format"; // public static final String HEADER = "header"; // public static final String SUFFIX = "suffix"; // public static final String PREFIX = "prefix"; // public static final String PATH_PROVIDER = "pathProvider"; // public static final String BROKER_LIST = "brokerList"; // public static final String GENDER = "gender"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/cons/TypeConst.java // public class TypeConst { // // public static final String STRING = "string"; // public static final String LONG = "long"; // public static final String INT = "int"; // public static final String BOOLEAN = "boolean"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java // public class Context { // // private Parent parent; // // private Map<String, Template> templates; // // private Map<String, Object> variables; // // private Sink sink; // // public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) { // this.templates = templates; // this.variables = variables; // this.sink = sink; // } // // public Context(Context parentContext, Map<String, Object> entity) { // parent = new Parent(entity, parentContext.getParent()); // templates = parentContext.getTemplates(); // variables = parentContext.getVariables(); // sink = parentContext.getSink(); // } // // public Parent getParent() { // return parent; // } // // public Map<String, Object> getVariables() { // return variables; // } // // public Sink getSink() { // return sink; // } // // public Map<String, Template> getTemplates() { // return templates; // } // // } // // Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java // public class Field { // // private String name; // // private String type; // // private Provider provider; // // public Field() { // } // // public Field(String name, String type, Provider provider) { // this.name = name; // this.type = type; // this.provider = provider; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // public Provider getProvider() { // return provider; // } // // public void setProvider(Provider provider) { // this.provider = provider; // } // } // // Path: src/main/java/com/presidentio/testdatagenerator/provider/ConstValueProvider.java // public class ConstValueProvider implements ValueProvider { // // private String value; // // @Override // public void init(Map<String, String> props) { // Map<String, String> propsCopy = new HashMap<>(props); // value = propsCopy.remove(PropConst.VALUE); // if (value == null) { // throw new IllegalArgumentException("Value does not specified or null"); // } // if (!propsCopy.isEmpty()) { // throw new IllegalArgumentException("Redundant props for ConstValueProvider: " + propsCopy); // } // } // // @Override // public Object nextValue(Context context, Field field) { // String type = field.getType(); // switch (type) { // case TypeConst.STRING: // return value; // case TypeConst.LONG: // return Long.valueOf(value); // case TypeConst.INT: // return Integer.valueOf(value); // case TypeConst.BOOLEAN: // return Boolean.valueOf(value); // default: // throw new IllegalArgumentException("Field type not known: " + type); // } // } // // } // // Path: src/main/java/com/presidentio/testdatagenerator/provider/ValueProvider.java // public interface ValueProvider { // // void init(Map<String, String> props); // // Object nextValue(Context context, Field field); // // }
import com.presidentio.testdatagenerator.cons.PropConst; import com.presidentio.testdatagenerator.cons.TypeConst; import com.presidentio.testdatagenerator.context.Context; import com.presidentio.testdatagenerator.model.Field; import com.presidentio.testdatagenerator.provider.ConstValueProvider; import com.presidentio.testdatagenerator.provider.ValueProvider; import org.openjdk.jmh.annotations.*; import java.util.HashMap; import java.util.Map; import java.util.concurrent.TimeUnit;
package com.presidentio.testdatagenerator.benchmark; /** * Created by Vitalii_Gergel on 3/19/2015. */ @Fork(1) @Warmup(iterations = 3) @OutputTimeUnit(TimeUnit.MICROSECONDS) @Measurement(iterations = 10) @State(Scope.Benchmark) public class ConstBenchmark { private Context context; private ValueProvider valueProvider; private Field field; @Setup public void init() { Map<String, String> props = new HashMap<>(); String propValue = "123";
// Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java // public class PropConst { // // public static final String TYPE = "type"; // public static final String VALUE = "value"; // public static final String SIZE = "size"; // public static final String DOMAIN = "domain"; // public static final String EXPR = "expr"; // public static final String FILE = "file"; // public static final String DELIMITER = "delimiter"; // public static final String ITEMS = "items"; // public static final String INDEX = "index"; // public static final String HOST = "host"; // public static final String PORT = "port"; // public static final String CLUSTER_NAME = "clusterName"; // public static final String CONNECTION_URL = "connectionUrl"; // public static final String JDBC_DRIVER = "jdbcDriver"; // public static final String DEPTH = "depth"; // public static final String FIELD = "field"; // public static final String VAR = "var"; // public static final String OP = "op"; // public static final String FORMAT = "format"; // public static final String HEADER = "header"; // public static final String SUFFIX = "suffix"; // public static final String PREFIX = "prefix"; // public static final String PATH_PROVIDER = "pathProvider"; // public static final String BROKER_LIST = "brokerList"; // public static final String GENDER = "gender"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/cons/TypeConst.java // public class TypeConst { // // public static final String STRING = "string"; // public static final String LONG = "long"; // public static final String INT = "int"; // public static final String BOOLEAN = "boolean"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java // public class Context { // // private Parent parent; // // private Map<String, Template> templates; // // private Map<String, Object> variables; // // private Sink sink; // // public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) { // this.templates = templates; // this.variables = variables; // this.sink = sink; // } // // public Context(Context parentContext, Map<String, Object> entity) { // parent = new Parent(entity, parentContext.getParent()); // templates = parentContext.getTemplates(); // variables = parentContext.getVariables(); // sink = parentContext.getSink(); // } // // public Parent getParent() { // return parent; // } // // public Map<String, Object> getVariables() { // return variables; // } // // public Sink getSink() { // return sink; // } // // public Map<String, Template> getTemplates() { // return templates; // } // // } // // Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java // public class Field { // // private String name; // // private String type; // // private Provider provider; // // public Field() { // } // // public Field(String name, String type, Provider provider) { // this.name = name; // this.type = type; // this.provider = provider; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // public Provider getProvider() { // return provider; // } // // public void setProvider(Provider provider) { // this.provider = provider; // } // } // // Path: src/main/java/com/presidentio/testdatagenerator/provider/ConstValueProvider.java // public class ConstValueProvider implements ValueProvider { // // private String value; // // @Override // public void init(Map<String, String> props) { // Map<String, String> propsCopy = new HashMap<>(props); // value = propsCopy.remove(PropConst.VALUE); // if (value == null) { // throw new IllegalArgumentException("Value does not specified or null"); // } // if (!propsCopy.isEmpty()) { // throw new IllegalArgumentException("Redundant props for ConstValueProvider: " + propsCopy); // } // } // // @Override // public Object nextValue(Context context, Field field) { // String type = field.getType(); // switch (type) { // case TypeConst.STRING: // return value; // case TypeConst.LONG: // return Long.valueOf(value); // case TypeConst.INT: // return Integer.valueOf(value); // case TypeConst.BOOLEAN: // return Boolean.valueOf(value); // default: // throw new IllegalArgumentException("Field type not known: " + type); // } // } // // } // // Path: src/main/java/com/presidentio/testdatagenerator/provider/ValueProvider.java // public interface ValueProvider { // // void init(Map<String, String> props); // // Object nextValue(Context context, Field field); // // } // Path: src/main/java/com/presidentio/testdatagenerator/benchmark/ConstBenchmark.java import com.presidentio.testdatagenerator.cons.PropConst; import com.presidentio.testdatagenerator.cons.TypeConst; import com.presidentio.testdatagenerator.context.Context; import com.presidentio.testdatagenerator.model.Field; import com.presidentio.testdatagenerator.provider.ConstValueProvider; import com.presidentio.testdatagenerator.provider.ValueProvider; import org.openjdk.jmh.annotations.*; import java.util.HashMap; import java.util.Map; import java.util.concurrent.TimeUnit; package com.presidentio.testdatagenerator.benchmark; /** * Created by Vitalii_Gergel on 3/19/2015. */ @Fork(1) @Warmup(iterations = 3) @OutputTimeUnit(TimeUnit.MICROSECONDS) @Measurement(iterations = 10) @State(Scope.Benchmark) public class ConstBenchmark { private Context context; private ValueProvider valueProvider; private Field field; @Setup public void init() { Map<String, String> props = new HashMap<>(); String propValue = "123";
props.put(PropConst.VALUE, propValue);
presidentio/test-data-generator
src/main/java/com/presidentio/testdatagenerator/benchmark/ConstBenchmark.java
// Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java // public class PropConst { // // public static final String TYPE = "type"; // public static final String VALUE = "value"; // public static final String SIZE = "size"; // public static final String DOMAIN = "domain"; // public static final String EXPR = "expr"; // public static final String FILE = "file"; // public static final String DELIMITER = "delimiter"; // public static final String ITEMS = "items"; // public static final String INDEX = "index"; // public static final String HOST = "host"; // public static final String PORT = "port"; // public static final String CLUSTER_NAME = "clusterName"; // public static final String CONNECTION_URL = "connectionUrl"; // public static final String JDBC_DRIVER = "jdbcDriver"; // public static final String DEPTH = "depth"; // public static final String FIELD = "field"; // public static final String VAR = "var"; // public static final String OP = "op"; // public static final String FORMAT = "format"; // public static final String HEADER = "header"; // public static final String SUFFIX = "suffix"; // public static final String PREFIX = "prefix"; // public static final String PATH_PROVIDER = "pathProvider"; // public static final String BROKER_LIST = "brokerList"; // public static final String GENDER = "gender"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/cons/TypeConst.java // public class TypeConst { // // public static final String STRING = "string"; // public static final String LONG = "long"; // public static final String INT = "int"; // public static final String BOOLEAN = "boolean"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java // public class Context { // // private Parent parent; // // private Map<String, Template> templates; // // private Map<String, Object> variables; // // private Sink sink; // // public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) { // this.templates = templates; // this.variables = variables; // this.sink = sink; // } // // public Context(Context parentContext, Map<String, Object> entity) { // parent = new Parent(entity, parentContext.getParent()); // templates = parentContext.getTemplates(); // variables = parentContext.getVariables(); // sink = parentContext.getSink(); // } // // public Parent getParent() { // return parent; // } // // public Map<String, Object> getVariables() { // return variables; // } // // public Sink getSink() { // return sink; // } // // public Map<String, Template> getTemplates() { // return templates; // } // // } // // Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java // public class Field { // // private String name; // // private String type; // // private Provider provider; // // public Field() { // } // // public Field(String name, String type, Provider provider) { // this.name = name; // this.type = type; // this.provider = provider; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // public Provider getProvider() { // return provider; // } // // public void setProvider(Provider provider) { // this.provider = provider; // } // } // // Path: src/main/java/com/presidentio/testdatagenerator/provider/ConstValueProvider.java // public class ConstValueProvider implements ValueProvider { // // private String value; // // @Override // public void init(Map<String, String> props) { // Map<String, String> propsCopy = new HashMap<>(props); // value = propsCopy.remove(PropConst.VALUE); // if (value == null) { // throw new IllegalArgumentException("Value does not specified or null"); // } // if (!propsCopy.isEmpty()) { // throw new IllegalArgumentException("Redundant props for ConstValueProvider: " + propsCopy); // } // } // // @Override // public Object nextValue(Context context, Field field) { // String type = field.getType(); // switch (type) { // case TypeConst.STRING: // return value; // case TypeConst.LONG: // return Long.valueOf(value); // case TypeConst.INT: // return Integer.valueOf(value); // case TypeConst.BOOLEAN: // return Boolean.valueOf(value); // default: // throw new IllegalArgumentException("Field type not known: " + type); // } // } // // } // // Path: src/main/java/com/presidentio/testdatagenerator/provider/ValueProvider.java // public interface ValueProvider { // // void init(Map<String, String> props); // // Object nextValue(Context context, Field field); // // }
import com.presidentio.testdatagenerator.cons.PropConst; import com.presidentio.testdatagenerator.cons.TypeConst; import com.presidentio.testdatagenerator.context.Context; import com.presidentio.testdatagenerator.model.Field; import com.presidentio.testdatagenerator.provider.ConstValueProvider; import com.presidentio.testdatagenerator.provider.ValueProvider; import org.openjdk.jmh.annotations.*; import java.util.HashMap; import java.util.Map; import java.util.concurrent.TimeUnit;
package com.presidentio.testdatagenerator.benchmark; /** * Created by Vitalii_Gergel on 3/19/2015. */ @Fork(1) @Warmup(iterations = 3) @OutputTimeUnit(TimeUnit.MICROSECONDS) @Measurement(iterations = 10) @State(Scope.Benchmark) public class ConstBenchmark { private Context context; private ValueProvider valueProvider; private Field field; @Setup public void init() { Map<String, String> props = new HashMap<>(); String propValue = "123"; props.put(PropConst.VALUE, propValue);
// Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java // public class PropConst { // // public static final String TYPE = "type"; // public static final String VALUE = "value"; // public static final String SIZE = "size"; // public static final String DOMAIN = "domain"; // public static final String EXPR = "expr"; // public static final String FILE = "file"; // public static final String DELIMITER = "delimiter"; // public static final String ITEMS = "items"; // public static final String INDEX = "index"; // public static final String HOST = "host"; // public static final String PORT = "port"; // public static final String CLUSTER_NAME = "clusterName"; // public static final String CONNECTION_URL = "connectionUrl"; // public static final String JDBC_DRIVER = "jdbcDriver"; // public static final String DEPTH = "depth"; // public static final String FIELD = "field"; // public static final String VAR = "var"; // public static final String OP = "op"; // public static final String FORMAT = "format"; // public static final String HEADER = "header"; // public static final String SUFFIX = "suffix"; // public static final String PREFIX = "prefix"; // public static final String PATH_PROVIDER = "pathProvider"; // public static final String BROKER_LIST = "brokerList"; // public static final String GENDER = "gender"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/cons/TypeConst.java // public class TypeConst { // // public static final String STRING = "string"; // public static final String LONG = "long"; // public static final String INT = "int"; // public static final String BOOLEAN = "boolean"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java // public class Context { // // private Parent parent; // // private Map<String, Template> templates; // // private Map<String, Object> variables; // // private Sink sink; // // public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) { // this.templates = templates; // this.variables = variables; // this.sink = sink; // } // // public Context(Context parentContext, Map<String, Object> entity) { // parent = new Parent(entity, parentContext.getParent()); // templates = parentContext.getTemplates(); // variables = parentContext.getVariables(); // sink = parentContext.getSink(); // } // // public Parent getParent() { // return parent; // } // // public Map<String, Object> getVariables() { // return variables; // } // // public Sink getSink() { // return sink; // } // // public Map<String, Template> getTemplates() { // return templates; // } // // } // // Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java // public class Field { // // private String name; // // private String type; // // private Provider provider; // // public Field() { // } // // public Field(String name, String type, Provider provider) { // this.name = name; // this.type = type; // this.provider = provider; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // public Provider getProvider() { // return provider; // } // // public void setProvider(Provider provider) { // this.provider = provider; // } // } // // Path: src/main/java/com/presidentio/testdatagenerator/provider/ConstValueProvider.java // public class ConstValueProvider implements ValueProvider { // // private String value; // // @Override // public void init(Map<String, String> props) { // Map<String, String> propsCopy = new HashMap<>(props); // value = propsCopy.remove(PropConst.VALUE); // if (value == null) { // throw new IllegalArgumentException("Value does not specified or null"); // } // if (!propsCopy.isEmpty()) { // throw new IllegalArgumentException("Redundant props for ConstValueProvider: " + propsCopy); // } // } // // @Override // public Object nextValue(Context context, Field field) { // String type = field.getType(); // switch (type) { // case TypeConst.STRING: // return value; // case TypeConst.LONG: // return Long.valueOf(value); // case TypeConst.INT: // return Integer.valueOf(value); // case TypeConst.BOOLEAN: // return Boolean.valueOf(value); // default: // throw new IllegalArgumentException("Field type not known: " + type); // } // } // // } // // Path: src/main/java/com/presidentio/testdatagenerator/provider/ValueProvider.java // public interface ValueProvider { // // void init(Map<String, String> props); // // Object nextValue(Context context, Field field); // // } // Path: src/main/java/com/presidentio/testdatagenerator/benchmark/ConstBenchmark.java import com.presidentio.testdatagenerator.cons.PropConst; import com.presidentio.testdatagenerator.cons.TypeConst; import com.presidentio.testdatagenerator.context.Context; import com.presidentio.testdatagenerator.model.Field; import com.presidentio.testdatagenerator.provider.ConstValueProvider; import com.presidentio.testdatagenerator.provider.ValueProvider; import org.openjdk.jmh.annotations.*; import java.util.HashMap; import java.util.Map; import java.util.concurrent.TimeUnit; package com.presidentio.testdatagenerator.benchmark; /** * Created by Vitalii_Gergel on 3/19/2015. */ @Fork(1) @Warmup(iterations = 3) @OutputTimeUnit(TimeUnit.MICROSECONDS) @Measurement(iterations = 10) @State(Scope.Benchmark) public class ConstBenchmark { private Context context; private ValueProvider valueProvider; private Field field; @Setup public void init() { Map<String, String> props = new HashMap<>(); String propValue = "123"; props.put(PropConst.VALUE, propValue);
valueProvider = new ConstValueProvider();
presidentio/test-data-generator
src/test/java/com/presidentio/testdatagenerator/provider/SelectProviderTest.java
// Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java // public class PropConst { // // public static final String TYPE = "type"; // public static final String VALUE = "value"; // public static final String SIZE = "size"; // public static final String DOMAIN = "domain"; // public static final String EXPR = "expr"; // public static final String FILE = "file"; // public static final String DELIMITER = "delimiter"; // public static final String ITEMS = "items"; // public static final String INDEX = "index"; // public static final String HOST = "host"; // public static final String PORT = "port"; // public static final String CLUSTER_NAME = "clusterName"; // public static final String CONNECTION_URL = "connectionUrl"; // public static final String JDBC_DRIVER = "jdbcDriver"; // public static final String DEPTH = "depth"; // public static final String FIELD = "field"; // public static final String VAR = "var"; // public static final String OP = "op"; // public static final String FORMAT = "format"; // public static final String HEADER = "header"; // public static final String SUFFIX = "suffix"; // public static final String PREFIX = "prefix"; // public static final String PATH_PROVIDER = "pathProvider"; // public static final String BROKER_LIST = "brokerList"; // public static final String GENDER = "gender"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/cons/TypeConst.java // public class TypeConst { // // public static final String STRING = "string"; // public static final String LONG = "long"; // public static final String INT = "int"; // public static final String BOOLEAN = "boolean"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java // public class Context { // // private Parent parent; // // private Map<String, Template> templates; // // private Map<String, Object> variables; // // private Sink sink; // // public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) { // this.templates = templates; // this.variables = variables; // this.sink = sink; // } // // public Context(Context parentContext, Map<String, Object> entity) { // parent = new Parent(entity, parentContext.getParent()); // templates = parentContext.getTemplates(); // variables = parentContext.getVariables(); // sink = parentContext.getSink(); // } // // public Parent getParent() { // return parent; // } // // public Map<String, Object> getVariables() { // return variables; // } // // public Sink getSink() { // return sink; // } // // public Map<String, Template> getTemplates() { // return templates; // } // // } // // Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java // public class Field { // // private String name; // // private String type; // // private Provider provider; // // public Field() { // } // // public Field(String name, String type, Provider provider) { // this.name = name; // this.type = type; // this.provider = provider; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // public Provider getProvider() { // return provider; // } // // public void setProvider(Provider provider) { // this.provider = provider; // } // }
import com.presidentio.testdatagenerator.cons.PropConst; import com.presidentio.testdatagenerator.cons.TypeConst; import com.presidentio.testdatagenerator.context.Context; import com.presidentio.testdatagenerator.model.Field; import org.junit.Assert; import org.junit.Test; import java.util.*;
/** * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.presidentio.testdatagenerator.provider; public class SelectProviderTest { @Test public void testNextValue() throws Exception { Map<String, String> props = new HashMap<>(); String propItems = "5,6,7,8,9"; String propDelimiter = ",";
// Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java // public class PropConst { // // public static final String TYPE = "type"; // public static final String VALUE = "value"; // public static final String SIZE = "size"; // public static final String DOMAIN = "domain"; // public static final String EXPR = "expr"; // public static final String FILE = "file"; // public static final String DELIMITER = "delimiter"; // public static final String ITEMS = "items"; // public static final String INDEX = "index"; // public static final String HOST = "host"; // public static final String PORT = "port"; // public static final String CLUSTER_NAME = "clusterName"; // public static final String CONNECTION_URL = "connectionUrl"; // public static final String JDBC_DRIVER = "jdbcDriver"; // public static final String DEPTH = "depth"; // public static final String FIELD = "field"; // public static final String VAR = "var"; // public static final String OP = "op"; // public static final String FORMAT = "format"; // public static final String HEADER = "header"; // public static final String SUFFIX = "suffix"; // public static final String PREFIX = "prefix"; // public static final String PATH_PROVIDER = "pathProvider"; // public static final String BROKER_LIST = "brokerList"; // public static final String GENDER = "gender"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/cons/TypeConst.java // public class TypeConst { // // public static final String STRING = "string"; // public static final String LONG = "long"; // public static final String INT = "int"; // public static final String BOOLEAN = "boolean"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java // public class Context { // // private Parent parent; // // private Map<String, Template> templates; // // private Map<String, Object> variables; // // private Sink sink; // // public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) { // this.templates = templates; // this.variables = variables; // this.sink = sink; // } // // public Context(Context parentContext, Map<String, Object> entity) { // parent = new Parent(entity, parentContext.getParent()); // templates = parentContext.getTemplates(); // variables = parentContext.getVariables(); // sink = parentContext.getSink(); // } // // public Parent getParent() { // return parent; // } // // public Map<String, Object> getVariables() { // return variables; // } // // public Sink getSink() { // return sink; // } // // public Map<String, Template> getTemplates() { // return templates; // } // // } // // Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java // public class Field { // // private String name; // // private String type; // // private Provider provider; // // public Field() { // } // // public Field(String name, String type, Provider provider) { // this.name = name; // this.type = type; // this.provider = provider; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // public Provider getProvider() { // return provider; // } // // public void setProvider(Provider provider) { // this.provider = provider; // } // } // Path: src/test/java/com/presidentio/testdatagenerator/provider/SelectProviderTest.java import com.presidentio.testdatagenerator.cons.PropConst; import com.presidentio.testdatagenerator.cons.TypeConst; import com.presidentio.testdatagenerator.context.Context; import com.presidentio.testdatagenerator.model.Field; import org.junit.Assert; import org.junit.Test; import java.util.*; /** * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.presidentio.testdatagenerator.provider; public class SelectProviderTest { @Test public void testNextValue() throws Exception { Map<String, String> props = new HashMap<>(); String propItems = "5,6,7,8,9"; String propDelimiter = ",";
props.put(PropConst.ITEMS, propItems);
presidentio/test-data-generator
src/test/java/com/presidentio/testdatagenerator/provider/SelectProviderTest.java
// Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java // public class PropConst { // // public static final String TYPE = "type"; // public static final String VALUE = "value"; // public static final String SIZE = "size"; // public static final String DOMAIN = "domain"; // public static final String EXPR = "expr"; // public static final String FILE = "file"; // public static final String DELIMITER = "delimiter"; // public static final String ITEMS = "items"; // public static final String INDEX = "index"; // public static final String HOST = "host"; // public static final String PORT = "port"; // public static final String CLUSTER_NAME = "clusterName"; // public static final String CONNECTION_URL = "connectionUrl"; // public static final String JDBC_DRIVER = "jdbcDriver"; // public static final String DEPTH = "depth"; // public static final String FIELD = "field"; // public static final String VAR = "var"; // public static final String OP = "op"; // public static final String FORMAT = "format"; // public static final String HEADER = "header"; // public static final String SUFFIX = "suffix"; // public static final String PREFIX = "prefix"; // public static final String PATH_PROVIDER = "pathProvider"; // public static final String BROKER_LIST = "brokerList"; // public static final String GENDER = "gender"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/cons/TypeConst.java // public class TypeConst { // // public static final String STRING = "string"; // public static final String LONG = "long"; // public static final String INT = "int"; // public static final String BOOLEAN = "boolean"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java // public class Context { // // private Parent parent; // // private Map<String, Template> templates; // // private Map<String, Object> variables; // // private Sink sink; // // public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) { // this.templates = templates; // this.variables = variables; // this.sink = sink; // } // // public Context(Context parentContext, Map<String, Object> entity) { // parent = new Parent(entity, parentContext.getParent()); // templates = parentContext.getTemplates(); // variables = parentContext.getVariables(); // sink = parentContext.getSink(); // } // // public Parent getParent() { // return parent; // } // // public Map<String, Object> getVariables() { // return variables; // } // // public Sink getSink() { // return sink; // } // // public Map<String, Template> getTemplates() { // return templates; // } // // } // // Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java // public class Field { // // private String name; // // private String type; // // private Provider provider; // // public Field() { // } // // public Field(String name, String type, Provider provider) { // this.name = name; // this.type = type; // this.provider = provider; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // public Provider getProvider() { // return provider; // } // // public void setProvider(Provider provider) { // this.provider = provider; // } // }
import com.presidentio.testdatagenerator.cons.PropConst; import com.presidentio.testdatagenerator.cons.TypeConst; import com.presidentio.testdatagenerator.context.Context; import com.presidentio.testdatagenerator.model.Field; import org.junit.Assert; import org.junit.Test; import java.util.*;
/** * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.presidentio.testdatagenerator.provider; public class SelectProviderTest { @Test public void testNextValue() throws Exception { Map<String, String> props = new HashMap<>(); String propItems = "5,6,7,8,9"; String propDelimiter = ","; props.put(PropConst.ITEMS, propItems); props.put(PropConst.DELIMITER, propDelimiter); SelectProvider selectProvider = new SelectProvider(); selectProvider.init(props); List items = Arrays.asList(propItems.split(propDelimiter));
// Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java // public class PropConst { // // public static final String TYPE = "type"; // public static final String VALUE = "value"; // public static final String SIZE = "size"; // public static final String DOMAIN = "domain"; // public static final String EXPR = "expr"; // public static final String FILE = "file"; // public static final String DELIMITER = "delimiter"; // public static final String ITEMS = "items"; // public static final String INDEX = "index"; // public static final String HOST = "host"; // public static final String PORT = "port"; // public static final String CLUSTER_NAME = "clusterName"; // public static final String CONNECTION_URL = "connectionUrl"; // public static final String JDBC_DRIVER = "jdbcDriver"; // public static final String DEPTH = "depth"; // public static final String FIELD = "field"; // public static final String VAR = "var"; // public static final String OP = "op"; // public static final String FORMAT = "format"; // public static final String HEADER = "header"; // public static final String SUFFIX = "suffix"; // public static final String PREFIX = "prefix"; // public static final String PATH_PROVIDER = "pathProvider"; // public static final String BROKER_LIST = "brokerList"; // public static final String GENDER = "gender"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/cons/TypeConst.java // public class TypeConst { // // public static final String STRING = "string"; // public static final String LONG = "long"; // public static final String INT = "int"; // public static final String BOOLEAN = "boolean"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java // public class Context { // // private Parent parent; // // private Map<String, Template> templates; // // private Map<String, Object> variables; // // private Sink sink; // // public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) { // this.templates = templates; // this.variables = variables; // this.sink = sink; // } // // public Context(Context parentContext, Map<String, Object> entity) { // parent = new Parent(entity, parentContext.getParent()); // templates = parentContext.getTemplates(); // variables = parentContext.getVariables(); // sink = parentContext.getSink(); // } // // public Parent getParent() { // return parent; // } // // public Map<String, Object> getVariables() { // return variables; // } // // public Sink getSink() { // return sink; // } // // public Map<String, Template> getTemplates() { // return templates; // } // // } // // Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java // public class Field { // // private String name; // // private String type; // // private Provider provider; // // public Field() { // } // // public Field(String name, String type, Provider provider) { // this.name = name; // this.type = type; // this.provider = provider; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // public Provider getProvider() { // return provider; // } // // public void setProvider(Provider provider) { // this.provider = provider; // } // } // Path: src/test/java/com/presidentio/testdatagenerator/provider/SelectProviderTest.java import com.presidentio.testdatagenerator.cons.PropConst; import com.presidentio.testdatagenerator.cons.TypeConst; import com.presidentio.testdatagenerator.context.Context; import com.presidentio.testdatagenerator.model.Field; import org.junit.Assert; import org.junit.Test; import java.util.*; /** * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.presidentio.testdatagenerator.provider; public class SelectProviderTest { @Test public void testNextValue() throws Exception { Map<String, String> props = new HashMap<>(); String propItems = "5,6,7,8,9"; String propDelimiter = ","; props.put(PropConst.ITEMS, propItems); props.put(PropConst.DELIMITER, propDelimiter); SelectProvider selectProvider = new SelectProvider(); selectProvider.init(props); List items = Arrays.asList(propItems.split(propDelimiter));
Object result = selectProvider.nextValue(new Context(null, null, null), new Field("testField", TypeConst.STRING, null));
presidentio/test-data-generator
src/test/java/com/presidentio/testdatagenerator/provider/SelectProviderTest.java
// Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java // public class PropConst { // // public static final String TYPE = "type"; // public static final String VALUE = "value"; // public static final String SIZE = "size"; // public static final String DOMAIN = "domain"; // public static final String EXPR = "expr"; // public static final String FILE = "file"; // public static final String DELIMITER = "delimiter"; // public static final String ITEMS = "items"; // public static final String INDEX = "index"; // public static final String HOST = "host"; // public static final String PORT = "port"; // public static final String CLUSTER_NAME = "clusterName"; // public static final String CONNECTION_URL = "connectionUrl"; // public static final String JDBC_DRIVER = "jdbcDriver"; // public static final String DEPTH = "depth"; // public static final String FIELD = "field"; // public static final String VAR = "var"; // public static final String OP = "op"; // public static final String FORMAT = "format"; // public static final String HEADER = "header"; // public static final String SUFFIX = "suffix"; // public static final String PREFIX = "prefix"; // public static final String PATH_PROVIDER = "pathProvider"; // public static final String BROKER_LIST = "brokerList"; // public static final String GENDER = "gender"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/cons/TypeConst.java // public class TypeConst { // // public static final String STRING = "string"; // public static final String LONG = "long"; // public static final String INT = "int"; // public static final String BOOLEAN = "boolean"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java // public class Context { // // private Parent parent; // // private Map<String, Template> templates; // // private Map<String, Object> variables; // // private Sink sink; // // public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) { // this.templates = templates; // this.variables = variables; // this.sink = sink; // } // // public Context(Context parentContext, Map<String, Object> entity) { // parent = new Parent(entity, parentContext.getParent()); // templates = parentContext.getTemplates(); // variables = parentContext.getVariables(); // sink = parentContext.getSink(); // } // // public Parent getParent() { // return parent; // } // // public Map<String, Object> getVariables() { // return variables; // } // // public Sink getSink() { // return sink; // } // // public Map<String, Template> getTemplates() { // return templates; // } // // } // // Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java // public class Field { // // private String name; // // private String type; // // private Provider provider; // // public Field() { // } // // public Field(String name, String type, Provider provider) { // this.name = name; // this.type = type; // this.provider = provider; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // public Provider getProvider() { // return provider; // } // // public void setProvider(Provider provider) { // this.provider = provider; // } // }
import com.presidentio.testdatagenerator.cons.PropConst; import com.presidentio.testdatagenerator.cons.TypeConst; import com.presidentio.testdatagenerator.context.Context; import com.presidentio.testdatagenerator.model.Field; import org.junit.Assert; import org.junit.Test; import java.util.*;
/** * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.presidentio.testdatagenerator.provider; public class SelectProviderTest { @Test public void testNextValue() throws Exception { Map<String, String> props = new HashMap<>(); String propItems = "5,6,7,8,9"; String propDelimiter = ","; props.put(PropConst.ITEMS, propItems); props.put(PropConst.DELIMITER, propDelimiter); SelectProvider selectProvider = new SelectProvider(); selectProvider.init(props); List items = Arrays.asList(propItems.split(propDelimiter));
// Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java // public class PropConst { // // public static final String TYPE = "type"; // public static final String VALUE = "value"; // public static final String SIZE = "size"; // public static final String DOMAIN = "domain"; // public static final String EXPR = "expr"; // public static final String FILE = "file"; // public static final String DELIMITER = "delimiter"; // public static final String ITEMS = "items"; // public static final String INDEX = "index"; // public static final String HOST = "host"; // public static final String PORT = "port"; // public static final String CLUSTER_NAME = "clusterName"; // public static final String CONNECTION_URL = "connectionUrl"; // public static final String JDBC_DRIVER = "jdbcDriver"; // public static final String DEPTH = "depth"; // public static final String FIELD = "field"; // public static final String VAR = "var"; // public static final String OP = "op"; // public static final String FORMAT = "format"; // public static final String HEADER = "header"; // public static final String SUFFIX = "suffix"; // public static final String PREFIX = "prefix"; // public static final String PATH_PROVIDER = "pathProvider"; // public static final String BROKER_LIST = "brokerList"; // public static final String GENDER = "gender"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/cons/TypeConst.java // public class TypeConst { // // public static final String STRING = "string"; // public static final String LONG = "long"; // public static final String INT = "int"; // public static final String BOOLEAN = "boolean"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java // public class Context { // // private Parent parent; // // private Map<String, Template> templates; // // private Map<String, Object> variables; // // private Sink sink; // // public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) { // this.templates = templates; // this.variables = variables; // this.sink = sink; // } // // public Context(Context parentContext, Map<String, Object> entity) { // parent = new Parent(entity, parentContext.getParent()); // templates = parentContext.getTemplates(); // variables = parentContext.getVariables(); // sink = parentContext.getSink(); // } // // public Parent getParent() { // return parent; // } // // public Map<String, Object> getVariables() { // return variables; // } // // public Sink getSink() { // return sink; // } // // public Map<String, Template> getTemplates() { // return templates; // } // // } // // Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java // public class Field { // // private String name; // // private String type; // // private Provider provider; // // public Field() { // } // // public Field(String name, String type, Provider provider) { // this.name = name; // this.type = type; // this.provider = provider; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // public Provider getProvider() { // return provider; // } // // public void setProvider(Provider provider) { // this.provider = provider; // } // } // Path: src/test/java/com/presidentio/testdatagenerator/provider/SelectProviderTest.java import com.presidentio.testdatagenerator.cons.PropConst; import com.presidentio.testdatagenerator.cons.TypeConst; import com.presidentio.testdatagenerator.context.Context; import com.presidentio.testdatagenerator.model.Field; import org.junit.Assert; import org.junit.Test; import java.util.*; /** * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.presidentio.testdatagenerator.provider; public class SelectProviderTest { @Test public void testNextValue() throws Exception { Map<String, String> props = new HashMap<>(); String propItems = "5,6,7,8,9"; String propDelimiter = ","; props.put(PropConst.ITEMS, propItems); props.put(PropConst.DELIMITER, propDelimiter); SelectProvider selectProvider = new SelectProvider(); selectProvider.init(props); List items = Arrays.asList(propItems.split(propDelimiter));
Object result = selectProvider.nextValue(new Context(null, null, null), new Field("testField", TypeConst.STRING, null));
presidentio/test-data-generator
src/test/java/com/presidentio/testdatagenerator/provider/SelectProviderTest.java
// Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java // public class PropConst { // // public static final String TYPE = "type"; // public static final String VALUE = "value"; // public static final String SIZE = "size"; // public static final String DOMAIN = "domain"; // public static final String EXPR = "expr"; // public static final String FILE = "file"; // public static final String DELIMITER = "delimiter"; // public static final String ITEMS = "items"; // public static final String INDEX = "index"; // public static final String HOST = "host"; // public static final String PORT = "port"; // public static final String CLUSTER_NAME = "clusterName"; // public static final String CONNECTION_URL = "connectionUrl"; // public static final String JDBC_DRIVER = "jdbcDriver"; // public static final String DEPTH = "depth"; // public static final String FIELD = "field"; // public static final String VAR = "var"; // public static final String OP = "op"; // public static final String FORMAT = "format"; // public static final String HEADER = "header"; // public static final String SUFFIX = "suffix"; // public static final String PREFIX = "prefix"; // public static final String PATH_PROVIDER = "pathProvider"; // public static final String BROKER_LIST = "brokerList"; // public static final String GENDER = "gender"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/cons/TypeConst.java // public class TypeConst { // // public static final String STRING = "string"; // public static final String LONG = "long"; // public static final String INT = "int"; // public static final String BOOLEAN = "boolean"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java // public class Context { // // private Parent parent; // // private Map<String, Template> templates; // // private Map<String, Object> variables; // // private Sink sink; // // public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) { // this.templates = templates; // this.variables = variables; // this.sink = sink; // } // // public Context(Context parentContext, Map<String, Object> entity) { // parent = new Parent(entity, parentContext.getParent()); // templates = parentContext.getTemplates(); // variables = parentContext.getVariables(); // sink = parentContext.getSink(); // } // // public Parent getParent() { // return parent; // } // // public Map<String, Object> getVariables() { // return variables; // } // // public Sink getSink() { // return sink; // } // // public Map<String, Template> getTemplates() { // return templates; // } // // } // // Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java // public class Field { // // private String name; // // private String type; // // private Provider provider; // // public Field() { // } // // public Field(String name, String type, Provider provider) { // this.name = name; // this.type = type; // this.provider = provider; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // public Provider getProvider() { // return provider; // } // // public void setProvider(Provider provider) { // this.provider = provider; // } // }
import com.presidentio.testdatagenerator.cons.PropConst; import com.presidentio.testdatagenerator.cons.TypeConst; import com.presidentio.testdatagenerator.context.Context; import com.presidentio.testdatagenerator.model.Field; import org.junit.Assert; import org.junit.Test; import java.util.*;
/** * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.presidentio.testdatagenerator.provider; public class SelectProviderTest { @Test public void testNextValue() throws Exception { Map<String, String> props = new HashMap<>(); String propItems = "5,6,7,8,9"; String propDelimiter = ","; props.put(PropConst.ITEMS, propItems); props.put(PropConst.DELIMITER, propDelimiter); SelectProvider selectProvider = new SelectProvider(); selectProvider.init(props); List items = Arrays.asList(propItems.split(propDelimiter));
// Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java // public class PropConst { // // public static final String TYPE = "type"; // public static final String VALUE = "value"; // public static final String SIZE = "size"; // public static final String DOMAIN = "domain"; // public static final String EXPR = "expr"; // public static final String FILE = "file"; // public static final String DELIMITER = "delimiter"; // public static final String ITEMS = "items"; // public static final String INDEX = "index"; // public static final String HOST = "host"; // public static final String PORT = "port"; // public static final String CLUSTER_NAME = "clusterName"; // public static final String CONNECTION_URL = "connectionUrl"; // public static final String JDBC_DRIVER = "jdbcDriver"; // public static final String DEPTH = "depth"; // public static final String FIELD = "field"; // public static final String VAR = "var"; // public static final String OP = "op"; // public static final String FORMAT = "format"; // public static final String HEADER = "header"; // public static final String SUFFIX = "suffix"; // public static final String PREFIX = "prefix"; // public static final String PATH_PROVIDER = "pathProvider"; // public static final String BROKER_LIST = "brokerList"; // public static final String GENDER = "gender"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/cons/TypeConst.java // public class TypeConst { // // public static final String STRING = "string"; // public static final String LONG = "long"; // public static final String INT = "int"; // public static final String BOOLEAN = "boolean"; // // } // // Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java // public class Context { // // private Parent parent; // // private Map<String, Template> templates; // // private Map<String, Object> variables; // // private Sink sink; // // public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) { // this.templates = templates; // this.variables = variables; // this.sink = sink; // } // // public Context(Context parentContext, Map<String, Object> entity) { // parent = new Parent(entity, parentContext.getParent()); // templates = parentContext.getTemplates(); // variables = parentContext.getVariables(); // sink = parentContext.getSink(); // } // // public Parent getParent() { // return parent; // } // // public Map<String, Object> getVariables() { // return variables; // } // // public Sink getSink() { // return sink; // } // // public Map<String, Template> getTemplates() { // return templates; // } // // } // // Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java // public class Field { // // private String name; // // private String type; // // private Provider provider; // // public Field() { // } // // public Field(String name, String type, Provider provider) { // this.name = name; // this.type = type; // this.provider = provider; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // public Provider getProvider() { // return provider; // } // // public void setProvider(Provider provider) { // this.provider = provider; // } // } // Path: src/test/java/com/presidentio/testdatagenerator/provider/SelectProviderTest.java import com.presidentio.testdatagenerator.cons.PropConst; import com.presidentio.testdatagenerator.cons.TypeConst; import com.presidentio.testdatagenerator.context.Context; import com.presidentio.testdatagenerator.model.Field; import org.junit.Assert; import org.junit.Test; import java.util.*; /** * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.presidentio.testdatagenerator.provider; public class SelectProviderTest { @Test public void testNextValue() throws Exception { Map<String, String> props = new HashMap<>(); String propItems = "5,6,7,8,9"; String propDelimiter = ","; props.put(PropConst.ITEMS, propItems); props.put(PropConst.DELIMITER, propDelimiter); SelectProvider selectProvider = new SelectProvider(); selectProvider.init(props); List items = Arrays.asList(propItems.split(propDelimiter));
Object result = selectProvider.nextValue(new Context(null, null, null), new Field("testField", TypeConst.STRING, null));
crawler-commons/crawler-commons
src/main/java/crawlercommons/sitemaps/SiteMapURL.java
// Path: src/main/java/crawlercommons/sitemaps/extension/Extension.java // public enum Extension { // /** // * Google News sitemaps, see // * https://support.google.com/news/publisher-center/answer/74288 // */ // NEWS, // /** // * Google Image sitemaps, see // * https://support.google.com/webmasters/answer/178636 // */ // IMAGE, // /** // * Google Video sitemaps, see // * https://support.google.com/webmasters/answer/80471 // */ // VIDEO, // /** // * Usage of <code>&lt;xhtml:links&gt;</code> in sitemaps to include // * localized page versions/variants, see // * https://support.google.com/webmasters/answer/189077 // */ // LINKS, // /** // * <cite>Mobile sitemaps just contain an empty "mobile" tag to identify a // * URL as having mobile content</cite>, cf. // * http://www.google.com/schemas/sitemap-mobile/1.0 // */ // MOBILE // } // // Path: src/main/java/crawlercommons/sitemaps/extension/ExtensionMetadata.java // @SuppressWarnings("serial") // public abstract class ExtensionMetadata implements Serializable { // // public abstract boolean equals(Object other); // // public abstract Map<String, String[]> asMap(); // // public boolean isValid() { // return true; // } // // /** // * Compare URLs by their string representation because calling // * {@link URL#equals(Object)} may trigger an unwanted and potentially slow // * DNS lookup to resolve the host part // */ // protected static boolean urlEquals(URL a, URL b) { // return (a == b) || (a != null && b != null && a.toString().equals(b.toString())); // } // // }
import crawlercommons.sitemaps.extension.ExtensionMetadata; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.Serializable; import java.net.MalformedURLException; import java.net.URL; import java.time.ZonedDateTime; import java.util.Date; import java.util.Locale; import java.util.Map; import java.util.Map.Entry; import java.util.TreeMap; import crawlercommons.sitemaps.extension.Extension;
/** * Copyright 2016 Crawler-Commons * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package crawlercommons.sitemaps; /** * The SitemapUrl class represents a URL found in a Sitemap. * * @author fmccown */ @SuppressWarnings("serial") public class SiteMapURL implements Serializable { private static final Logger LOG = LoggerFactory.getLogger(SiteMapURL.class); public static final double DEFAULT_PRIORITY = 0.5; /** * Allowed change frequencies */ public enum ChangeFrequency { ALWAYS, HOURLY, DAILY, WEEKLY, MONTHLY, YEARLY, NEVER } ; /** * URL found in Sitemap (required) */ private URL url; /** * When URL was last modified (optional) */ private Date lastModified; /** * How often the URL changes (optional) */ private ChangeFrequency changeFreq; /** * Value between [0.0 - 1.0] (optional) */ private double priority = DEFAULT_PRIORITY; /** * could be false, if URL isn't found under base path as indicated here: * http://www.sitemaps.org/protocol.html#location * */ private boolean valid; /** * attributes from sitemap extensions (news, image, video sitemaps, etc.) */
// Path: src/main/java/crawlercommons/sitemaps/extension/Extension.java // public enum Extension { // /** // * Google News sitemaps, see // * https://support.google.com/news/publisher-center/answer/74288 // */ // NEWS, // /** // * Google Image sitemaps, see // * https://support.google.com/webmasters/answer/178636 // */ // IMAGE, // /** // * Google Video sitemaps, see // * https://support.google.com/webmasters/answer/80471 // */ // VIDEO, // /** // * Usage of <code>&lt;xhtml:links&gt;</code> in sitemaps to include // * localized page versions/variants, see // * https://support.google.com/webmasters/answer/189077 // */ // LINKS, // /** // * <cite>Mobile sitemaps just contain an empty "mobile" tag to identify a // * URL as having mobile content</cite>, cf. // * http://www.google.com/schemas/sitemap-mobile/1.0 // */ // MOBILE // } // // Path: src/main/java/crawlercommons/sitemaps/extension/ExtensionMetadata.java // @SuppressWarnings("serial") // public abstract class ExtensionMetadata implements Serializable { // // public abstract boolean equals(Object other); // // public abstract Map<String, String[]> asMap(); // // public boolean isValid() { // return true; // } // // /** // * Compare URLs by their string representation because calling // * {@link URL#equals(Object)} may trigger an unwanted and potentially slow // * DNS lookup to resolve the host part // */ // protected static boolean urlEquals(URL a, URL b) { // return (a == b) || (a != null && b != null && a.toString().equals(b.toString())); // } // // } // Path: src/main/java/crawlercommons/sitemaps/SiteMapURL.java import crawlercommons.sitemaps.extension.ExtensionMetadata; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.Serializable; import java.net.MalformedURLException; import java.net.URL; import java.time.ZonedDateTime; import java.util.Date; import java.util.Locale; import java.util.Map; import java.util.Map.Entry; import java.util.TreeMap; import crawlercommons.sitemaps.extension.Extension; /** * Copyright 2016 Crawler-Commons * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package crawlercommons.sitemaps; /** * The SitemapUrl class represents a URL found in a Sitemap. * * @author fmccown */ @SuppressWarnings("serial") public class SiteMapURL implements Serializable { private static final Logger LOG = LoggerFactory.getLogger(SiteMapURL.class); public static final double DEFAULT_PRIORITY = 0.5; /** * Allowed change frequencies */ public enum ChangeFrequency { ALWAYS, HOURLY, DAILY, WEEKLY, MONTHLY, YEARLY, NEVER } ; /** * URL found in Sitemap (required) */ private URL url; /** * When URL was last modified (optional) */ private Date lastModified; /** * How often the URL changes (optional) */ private ChangeFrequency changeFreq; /** * Value between [0.0 - 1.0] (optional) */ private double priority = DEFAULT_PRIORITY; /** * could be false, if URL isn't found under base path as indicated here: * http://www.sitemaps.org/protocol.html#location * */ private boolean valid; /** * attributes from sitemap extensions (news, image, video sitemaps, etc.) */
private Map<Extension, ExtensionMetadata[]> attributes;
crawler-commons/crawler-commons
src/main/java/crawlercommons/sitemaps/SiteMapURL.java
// Path: src/main/java/crawlercommons/sitemaps/extension/Extension.java // public enum Extension { // /** // * Google News sitemaps, see // * https://support.google.com/news/publisher-center/answer/74288 // */ // NEWS, // /** // * Google Image sitemaps, see // * https://support.google.com/webmasters/answer/178636 // */ // IMAGE, // /** // * Google Video sitemaps, see // * https://support.google.com/webmasters/answer/80471 // */ // VIDEO, // /** // * Usage of <code>&lt;xhtml:links&gt;</code> in sitemaps to include // * localized page versions/variants, see // * https://support.google.com/webmasters/answer/189077 // */ // LINKS, // /** // * <cite>Mobile sitemaps just contain an empty "mobile" tag to identify a // * URL as having mobile content</cite>, cf. // * http://www.google.com/schemas/sitemap-mobile/1.0 // */ // MOBILE // } // // Path: src/main/java/crawlercommons/sitemaps/extension/ExtensionMetadata.java // @SuppressWarnings("serial") // public abstract class ExtensionMetadata implements Serializable { // // public abstract boolean equals(Object other); // // public abstract Map<String, String[]> asMap(); // // public boolean isValid() { // return true; // } // // /** // * Compare URLs by their string representation because calling // * {@link URL#equals(Object)} may trigger an unwanted and potentially slow // * DNS lookup to resolve the host part // */ // protected static boolean urlEquals(URL a, URL b) { // return (a == b) || (a != null && b != null && a.toString().equals(b.toString())); // } // // }
import crawlercommons.sitemaps.extension.ExtensionMetadata; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.Serializable; import java.net.MalformedURLException; import java.net.URL; import java.time.ZonedDateTime; import java.util.Date; import java.util.Locale; import java.util.Map; import java.util.Map.Entry; import java.util.TreeMap; import crawlercommons.sitemaps.extension.Extension;
/** * Copyright 2016 Crawler-Commons * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package crawlercommons.sitemaps; /** * The SitemapUrl class represents a URL found in a Sitemap. * * @author fmccown */ @SuppressWarnings("serial") public class SiteMapURL implements Serializable { private static final Logger LOG = LoggerFactory.getLogger(SiteMapURL.class); public static final double DEFAULT_PRIORITY = 0.5; /** * Allowed change frequencies */ public enum ChangeFrequency { ALWAYS, HOURLY, DAILY, WEEKLY, MONTHLY, YEARLY, NEVER } ; /** * URL found in Sitemap (required) */ private URL url; /** * When URL was last modified (optional) */ private Date lastModified; /** * How often the URL changes (optional) */ private ChangeFrequency changeFreq; /** * Value between [0.0 - 1.0] (optional) */ private double priority = DEFAULT_PRIORITY; /** * could be false, if URL isn't found under base path as indicated here: * http://www.sitemaps.org/protocol.html#location * */ private boolean valid; /** * attributes from sitemap extensions (news, image, video sitemaps, etc.) */
// Path: src/main/java/crawlercommons/sitemaps/extension/Extension.java // public enum Extension { // /** // * Google News sitemaps, see // * https://support.google.com/news/publisher-center/answer/74288 // */ // NEWS, // /** // * Google Image sitemaps, see // * https://support.google.com/webmasters/answer/178636 // */ // IMAGE, // /** // * Google Video sitemaps, see // * https://support.google.com/webmasters/answer/80471 // */ // VIDEO, // /** // * Usage of <code>&lt;xhtml:links&gt;</code> in sitemaps to include // * localized page versions/variants, see // * https://support.google.com/webmasters/answer/189077 // */ // LINKS, // /** // * <cite>Mobile sitemaps just contain an empty "mobile" tag to identify a // * URL as having mobile content</cite>, cf. // * http://www.google.com/schemas/sitemap-mobile/1.0 // */ // MOBILE // } // // Path: src/main/java/crawlercommons/sitemaps/extension/ExtensionMetadata.java // @SuppressWarnings("serial") // public abstract class ExtensionMetadata implements Serializable { // // public abstract boolean equals(Object other); // // public abstract Map<String, String[]> asMap(); // // public boolean isValid() { // return true; // } // // /** // * Compare URLs by their string representation because calling // * {@link URL#equals(Object)} may trigger an unwanted and potentially slow // * DNS lookup to resolve the host part // */ // protected static boolean urlEquals(URL a, URL b) { // return (a == b) || (a != null && b != null && a.toString().equals(b.toString())); // } // // } // Path: src/main/java/crawlercommons/sitemaps/SiteMapURL.java import crawlercommons.sitemaps.extension.ExtensionMetadata; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.Serializable; import java.net.MalformedURLException; import java.net.URL; import java.time.ZonedDateTime; import java.util.Date; import java.util.Locale; import java.util.Map; import java.util.Map.Entry; import java.util.TreeMap; import crawlercommons.sitemaps.extension.Extension; /** * Copyright 2016 Crawler-Commons * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package crawlercommons.sitemaps; /** * The SitemapUrl class represents a URL found in a Sitemap. * * @author fmccown */ @SuppressWarnings("serial") public class SiteMapURL implements Serializable { private static final Logger LOG = LoggerFactory.getLogger(SiteMapURL.class); public static final double DEFAULT_PRIORITY = 0.5; /** * Allowed change frequencies */ public enum ChangeFrequency { ALWAYS, HOURLY, DAILY, WEEKLY, MONTHLY, YEARLY, NEVER } ; /** * URL found in Sitemap (required) */ private URL url; /** * When URL was last modified (optional) */ private Date lastModified; /** * How often the URL changes (optional) */ private ChangeFrequency changeFreq; /** * Value between [0.0 - 1.0] (optional) */ private double priority = DEFAULT_PRIORITY; /** * could be false, if URL isn't found under base path as indicated here: * http://www.sitemaps.org/protocol.html#location * */ private boolean valid; /** * attributes from sitemap extensions (news, image, video sitemaps, etc.) */
private Map<Extension, ExtensionMetadata[]> attributes;
crawler-commons/crawler-commons
src/test/java/crawlercommons/domains/EffectiveTldFinderTest.java
// Path: src/main/java/crawlercommons/domains/EffectiveTldFinder.java // public static class EffectiveTLD { // // private boolean exception = false; // private boolean wild = false; // private boolean isPrivate = false; // private String domain = null; // private String idn = null; // // /** // * Parse one non-empty, non-comment line in the public suffix list and // * hold the public suffix and its properties in the created object. // * // * @param line // * non-empty, non-comment line in the public suffix list // * @param isPrivateDomain // * whether line is in the section of &quot;PRIVATE // * DOMAINS&quot; of the public suffix list // * @throws IllegalArgumentException // * if the input line contains non-ASCII Unicode characters // * prohibited in IDNs, cf. {@link IDN#toASCII(String)} // */ // public EffectiveTLD(String line, boolean isPrivateDomain) throws IllegalArgumentException { // if (line.startsWith(EXCEPTION)) { // exception = true; // domain = line.substring(EXCEPTION.length(), line.length()); // } else if (line.startsWith(WILD_CARD)) { // wild = true; // domain = line.substring(WILD_CARD.length(), line.length()); // } else { // domain = line; // } // // String norm = normalizeName(domain); // if (!norm.equals(domain)) { // idn = domain; // domain = norm; // } // isPrivate = isPrivateDomain; // } // // /** // * Normalize a domain name: convert characters into to lowercase and // * encode dot-separated segments containing non-ASCII characters. Cf. // * {@link #asciiConvert(String)} and {@link IDN#toASCII(String)} // * // * @param str // * domain name segment // * @return normalized domain name containing only ASCII characters // * @throws IllegalArgumentException // * if the input contains prohibited characters // */ // private String normalizeName(String name) throws IllegalArgumentException { // String[] parts = name.split(DOT_REGEX); // String[] ary = new String[parts.length]; // for (int i = 0; i < parts.length; i++) { // ary[i] = asciiConvert(parts[i]); // } // return join(ary); // } // // /** // * Generate name variants caused by Internationalized Domain Names: // * every IDN part of a eTLD can be replaced by its punycoded ASCII // * variant. For two-part IDN eTLDs this will generate 4 variants. // * // * @return set of variant names // */ // public Set<String> getNameVariants() { // Set<String> res = new HashSet<>(); // if (idn == null) { // res.add(domain); // return res; // } // String[] parts = idn.split(DOT_REGEX); // String[] var = new String[parts.length]; // for (int i = 0; i < parts.length; i++) { // if (!isAscii(parts[i])) { // var[i] = IDN.toASCII(parts[i]); // } // } // for (int i = 0; i < parts.length; i++) { // Set<String> r = new HashSet<>(); // if (res.size() > 0) { // for (String p : res) { // r.add(p + DOT + parts[i]); // } // } else { // r.add(parts[i]); // } // if (var[i] != null && !var[i].equals(parts[i])) { // if (res.size() > 0) { // for (String p : res) { // r.add(p + DOT + var[i]); // } // } else { // r.add(var[i]); // } // } // res = r; // } // return res; // } // // /** // * Converts a single domain name segment (separated by dots) to ASCII if // * it contains non-ASCII character, cf. {@link IDN#toASCII(String)}. // * // * @param str // * domain name segment // * @return ASCII "Punycode" representation of the domain name segment // * @throws IllegalArgumentException // * if the input contains prohibited characters // */ // private static String asciiConvert(String str) throws IllegalArgumentException { // if (isAscii(str)) { // return str.toLowerCase(Locale.ROOT); // } // return IDN.toASCII(str); // } // // private static boolean isAscii(String str) { // char[] chars = str.toCharArray(); // for (char c : chars) { // if (c > 127) { // return false; // } // } // return true; // } // // public String getDomain() { // return domain; // } // // public boolean isWild() { // return wild; // } // // public boolean isException() { // return exception; // } // // @Override // public String toString() { // StringBuffer sb = new StringBuffer("["); // sb.append("domain=").append(domain).append(","); // sb.append("wild=").append(wild).append(","); // sb.append("exception=").append(exception).append(","); // sb.append("private=").append(isPrivate).append("]"); // return sb.toString(); // } // }
import crawlercommons.domains.EffectiveTldFinder.EffectiveTLD; import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.*;
/** * Copyright 2016 Crawler-Commons * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package crawlercommons.domains; public class EffectiveTldFinderTest { @Test public final void testDotComEtld() throws Exception {
// Path: src/main/java/crawlercommons/domains/EffectiveTldFinder.java // public static class EffectiveTLD { // // private boolean exception = false; // private boolean wild = false; // private boolean isPrivate = false; // private String domain = null; // private String idn = null; // // /** // * Parse one non-empty, non-comment line in the public suffix list and // * hold the public suffix and its properties in the created object. // * // * @param line // * non-empty, non-comment line in the public suffix list // * @param isPrivateDomain // * whether line is in the section of &quot;PRIVATE // * DOMAINS&quot; of the public suffix list // * @throws IllegalArgumentException // * if the input line contains non-ASCII Unicode characters // * prohibited in IDNs, cf. {@link IDN#toASCII(String)} // */ // public EffectiveTLD(String line, boolean isPrivateDomain) throws IllegalArgumentException { // if (line.startsWith(EXCEPTION)) { // exception = true; // domain = line.substring(EXCEPTION.length(), line.length()); // } else if (line.startsWith(WILD_CARD)) { // wild = true; // domain = line.substring(WILD_CARD.length(), line.length()); // } else { // domain = line; // } // // String norm = normalizeName(domain); // if (!norm.equals(domain)) { // idn = domain; // domain = norm; // } // isPrivate = isPrivateDomain; // } // // /** // * Normalize a domain name: convert characters into to lowercase and // * encode dot-separated segments containing non-ASCII characters. Cf. // * {@link #asciiConvert(String)} and {@link IDN#toASCII(String)} // * // * @param str // * domain name segment // * @return normalized domain name containing only ASCII characters // * @throws IllegalArgumentException // * if the input contains prohibited characters // */ // private String normalizeName(String name) throws IllegalArgumentException { // String[] parts = name.split(DOT_REGEX); // String[] ary = new String[parts.length]; // for (int i = 0; i < parts.length; i++) { // ary[i] = asciiConvert(parts[i]); // } // return join(ary); // } // // /** // * Generate name variants caused by Internationalized Domain Names: // * every IDN part of a eTLD can be replaced by its punycoded ASCII // * variant. For two-part IDN eTLDs this will generate 4 variants. // * // * @return set of variant names // */ // public Set<String> getNameVariants() { // Set<String> res = new HashSet<>(); // if (idn == null) { // res.add(domain); // return res; // } // String[] parts = idn.split(DOT_REGEX); // String[] var = new String[parts.length]; // for (int i = 0; i < parts.length; i++) { // if (!isAscii(parts[i])) { // var[i] = IDN.toASCII(parts[i]); // } // } // for (int i = 0; i < parts.length; i++) { // Set<String> r = new HashSet<>(); // if (res.size() > 0) { // for (String p : res) { // r.add(p + DOT + parts[i]); // } // } else { // r.add(parts[i]); // } // if (var[i] != null && !var[i].equals(parts[i])) { // if (res.size() > 0) { // for (String p : res) { // r.add(p + DOT + var[i]); // } // } else { // r.add(var[i]); // } // } // res = r; // } // return res; // } // // /** // * Converts a single domain name segment (separated by dots) to ASCII if // * it contains non-ASCII character, cf. {@link IDN#toASCII(String)}. // * // * @param str // * domain name segment // * @return ASCII "Punycode" representation of the domain name segment // * @throws IllegalArgumentException // * if the input contains prohibited characters // */ // private static String asciiConvert(String str) throws IllegalArgumentException { // if (isAscii(str)) { // return str.toLowerCase(Locale.ROOT); // } // return IDN.toASCII(str); // } // // private static boolean isAscii(String str) { // char[] chars = str.toCharArray(); // for (char c : chars) { // if (c > 127) { // return false; // } // } // return true; // } // // public String getDomain() { // return domain; // } // // public boolean isWild() { // return wild; // } // // public boolean isException() { // return exception; // } // // @Override // public String toString() { // StringBuffer sb = new StringBuffer("["); // sb.append("domain=").append(domain).append(","); // sb.append("wild=").append(wild).append(","); // sb.append("exception=").append(exception).append(","); // sb.append("private=").append(isPrivate).append("]"); // return sb.toString(); // } // } // Path: src/test/java/crawlercommons/domains/EffectiveTldFinderTest.java import crawlercommons.domains.EffectiveTldFinder.EffectiveTLD; import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.*; /** * Copyright 2016 Crawler-Commons * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package crawlercommons.domains; public class EffectiveTldFinderTest { @Test public final void testDotComEtld() throws Exception {
EffectiveTLD etld = null;
crawler-commons/crawler-commons
src/main/java/crawlercommons/filters/basic/BasicURLNormalizer.java
// Path: src/main/java/crawlercommons/utils/Strings.java // public class Strings { // // public static boolean isBlank(final String cs) { // if (cs == null || cs.isEmpty()) { // return true; // } // for (int i = 0; i < cs.length(); i++) { // if (Character.isWhitespace(cs.charAt(i)) == false) { // return false; // } // } // return true; // } // // } // // Path: src/main/java/crawlercommons/filters/URLFilter.java // public abstract class URLFilter { // // /** // * Returns a modified version of the input URL or null if the URL should be // * removed // * // * @param urlString // * a URL string to check against filter(s) // * @return a filtered URL // **/ // public abstract String filter(String urlString); // // }
import java.util.regex.Matcher; import java.util.regex.Pattern; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import crawlercommons.filters.URLFilter; import static java.nio.charset.StandardCharsets.UTF_8; import crawlercommons.utils.Strings; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.UnsupportedEncodingException; import java.net.IDN; import java.net.MalformedURLException; import java.net.URISyntaxException; import java.net.URL; import java.net.URLDecoder; import java.util.*;
/** * Parses the URL file and applies normalizations to the path and query components. * * @param file the URL file (as in java.net.URL.getFile()). * @return a normalized URL file */ private String normalizeUrlFile(String file) { // find the beginning of the query parameters int endPathIdx = file.indexOf('?'); if (endPathIdx == -1) { // no query parameters, just properly normalize the path return escapePath(unescapePath(file)); } int queryStartIdx = endPathIdx + 1; if (queryStartIdx >= file.length()) { // question mark was the last char in the file, so the query parameters // string is empty. we can just remove the question mark and properly // normalize the path. final String path = file.substring(0, file.length() - 1); return escapePath(unescapePath(path)); } file = escapePath(unescapePath(file)); List<NameValuePair> pairs = parseQueryParameters(file, queryStartIdx, queryParamsToRemove); StringBuilder normalizedFile = new StringBuilder(); String path = file.substring(0, endPathIdx);
// Path: src/main/java/crawlercommons/utils/Strings.java // public class Strings { // // public static boolean isBlank(final String cs) { // if (cs == null || cs.isEmpty()) { // return true; // } // for (int i = 0; i < cs.length(); i++) { // if (Character.isWhitespace(cs.charAt(i)) == false) { // return false; // } // } // return true; // } // // } // // Path: src/main/java/crawlercommons/filters/URLFilter.java // public abstract class URLFilter { // // /** // * Returns a modified version of the input URL or null if the URL should be // * removed // * // * @param urlString // * a URL string to check against filter(s) // * @return a filtered URL // **/ // public abstract String filter(String urlString); // // } // Path: src/main/java/crawlercommons/filters/basic/BasicURLNormalizer.java import java.util.regex.Matcher; import java.util.regex.Pattern; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import crawlercommons.filters.URLFilter; import static java.nio.charset.StandardCharsets.UTF_8; import crawlercommons.utils.Strings; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.UnsupportedEncodingException; import java.net.IDN; import java.net.MalformedURLException; import java.net.URISyntaxException; import java.net.URL; import java.net.URLDecoder; import java.util.*; /** * Parses the URL file and applies normalizations to the path and query components. * * @param file the URL file (as in java.net.URL.getFile()). * @return a normalized URL file */ private String normalizeUrlFile(String file) { // find the beginning of the query parameters int endPathIdx = file.indexOf('?'); if (endPathIdx == -1) { // no query parameters, just properly normalize the path return escapePath(unescapePath(file)); } int queryStartIdx = endPathIdx + 1; if (queryStartIdx >= file.length()) { // question mark was the last char in the file, so the query parameters // string is empty. we can just remove the question mark and properly // normalize the path. final String path = file.substring(0, file.length() - 1); return escapePath(unescapePath(path)); } file = escapePath(unescapePath(file)); List<NameValuePair> pairs = parseQueryParameters(file, queryStartIdx, queryParamsToRemove); StringBuilder normalizedFile = new StringBuilder(); String path = file.substring(0, endPathIdx);
if (!Strings.isBlank(path)) {
crawler-commons/crawler-commons
src/main/java/crawlercommons/robots/SimpleRobotRulesParser.java
// Path: src/main/java/crawlercommons/robots/SimpleRobotRules.java // public enum RobotRulesMode { // ALLOW_ALL, ALLOW_NONE, ALLOW_SOME // }
import org.apache.commons.io.IOUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import crawlercommons.robots.SimpleRobotRules.RobotRulesMode; import java.io.IOException; import java.net.HttpURLConnection; import java.net.MalformedURLException; import java.net.URL; import java.net.URLConnection; import java.net.URLDecoder; import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; import java.util.HashMap; import java.util.Locale; import java.util.Map; import java.util.StringTokenizer; import java.util.regex.Matcher; import java.util.regex.Pattern;
// number of warnings found in the latest processed robots.txt file private ThreadLocal<Integer> _numWarningsDuringLastParse = new ThreadLocal<>(); private int _maxWarnings; private long _maxCrawlDelay; public SimpleRobotRulesParser() { this(DEFAULT_MAX_CRAWL_DELAY, DEFAULT_MAX_WARNINGS); } /** * @param maxCrawlDelay * see {@link #setMaxCrawlDelay(long)} * @param maxWarnings * see {@link #setMaxWarnings(int)} */ public SimpleRobotRulesParser(long maxCrawlDelay, int maxWarnings) { this._maxCrawlDelay = maxCrawlDelay; this._maxWarnings = maxWarnings; } @Override public SimpleRobotRules failedFetch(int httpStatusCode) { SimpleRobotRules result; if ((httpStatusCode >= 200) && (httpStatusCode < 300)) { throw new IllegalStateException("Can't use status code constructor with 2xx response"); } else if ((httpStatusCode >= 300) && (httpStatusCode < 400)) { // Should only happen if we're getting endless redirects (more than // our follow limit), so treat it as a temporary failure.
// Path: src/main/java/crawlercommons/robots/SimpleRobotRules.java // public enum RobotRulesMode { // ALLOW_ALL, ALLOW_NONE, ALLOW_SOME // } // Path: src/main/java/crawlercommons/robots/SimpleRobotRulesParser.java import org.apache.commons.io.IOUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import crawlercommons.robots.SimpleRobotRules.RobotRulesMode; import java.io.IOException; import java.net.HttpURLConnection; import java.net.MalformedURLException; import java.net.URL; import java.net.URLConnection; import java.net.URLDecoder; import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; import java.util.HashMap; import java.util.Locale; import java.util.Map; import java.util.StringTokenizer; import java.util.regex.Matcher; import java.util.regex.Pattern; // number of warnings found in the latest processed robots.txt file private ThreadLocal<Integer> _numWarningsDuringLastParse = new ThreadLocal<>(); private int _maxWarnings; private long _maxCrawlDelay; public SimpleRobotRulesParser() { this(DEFAULT_MAX_CRAWL_DELAY, DEFAULT_MAX_WARNINGS); } /** * @param maxCrawlDelay * see {@link #setMaxCrawlDelay(long)} * @param maxWarnings * see {@link #setMaxWarnings(int)} */ public SimpleRobotRulesParser(long maxCrawlDelay, int maxWarnings) { this._maxCrawlDelay = maxCrawlDelay; this._maxWarnings = maxWarnings; } @Override public SimpleRobotRules failedFetch(int httpStatusCode) { SimpleRobotRules result; if ((httpStatusCode >= 200) && (httpStatusCode < 300)) { throw new IllegalStateException("Can't use status code constructor with 2xx response"); } else if ((httpStatusCode >= 300) && (httpStatusCode < 400)) { // Should only happen if we're getting endless redirects (more than // our follow limit), so treat it as a temporary failure.
result = new SimpleRobotRules(RobotRulesMode.ALLOW_NONE);
crawler-commons/crawler-commons
src/main/java/crawlercommons/sitemaps/Namespace.java
// Path: src/main/java/crawlercommons/sitemaps/extension/Extension.java // public enum Extension { // /** // * Google News sitemaps, see // * https://support.google.com/news/publisher-center/answer/74288 // */ // NEWS, // /** // * Google Image sitemaps, see // * https://support.google.com/webmasters/answer/178636 // */ // IMAGE, // /** // * Google Video sitemaps, see // * https://support.google.com/webmasters/answer/80471 // */ // VIDEO, // /** // * Usage of <code>&lt;xhtml:links&gt;</code> in sitemaps to include // * localized page versions/variants, see // * https://support.google.com/webmasters/answer/189077 // */ // LINKS, // /** // * <cite>Mobile sitemaps just contain an empty "mobile" tag to identify a // * URL as having mobile content</cite>, cf. // * http://www.google.com/schemas/sitemap-mobile/1.0 // */ // MOBILE // }
import java.util.Arrays; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; import java.util.TreeMap; import crawlercommons.sitemaps.extension.Extension;
* RSS and Atom sitemap formats do not have strict definition. But if we do * not parse as namespace aware, then RSS/Atom files that choose to use * namespaces will break. The relaxed compromise for RSS/Atom is to always * parse as "namespace aware", but we will only match elements by the * localName, accepting any element namespace. */ public static final String RSS_2_0 = "http://www.w3.org/1999/02/22-rdf-syntax-ns#"; public static final String ATOM_0_3 = "http://purl.org/atom/ns#"; public static final String ATOM_1_0 = "http://www.w3.org/2005/Atom"; public static final Set<String> SITEMAP_SUPPORTED_NAMESPACES = new HashSet<>(); static { SITEMAP_SUPPORTED_NAMESPACES.add(SITEMAP); SITEMAP_SUPPORTED_NAMESPACES.addAll(Arrays.asList(SITEMAP_LEGACY)); SITEMAP_SUPPORTED_NAMESPACES.addAll(Arrays.asList(IMAGE)); SITEMAP_SUPPORTED_NAMESPACES.addAll(Arrays.asList(VIDEO)); SITEMAP_SUPPORTED_NAMESPACES.addAll(Arrays.asList(NEWS)); SITEMAP_SUPPORTED_NAMESPACES.add(LINKS); } /** * @param uri * URI string identifying the namespace * @return true if namespace (identified by URI) is supported, false if the * namespace is not supported or unknown */ public static boolean isSupported(String uri) { return SITEMAP_SUPPORTED_NAMESPACES.contains(uri); }
// Path: src/main/java/crawlercommons/sitemaps/extension/Extension.java // public enum Extension { // /** // * Google News sitemaps, see // * https://support.google.com/news/publisher-center/answer/74288 // */ // NEWS, // /** // * Google Image sitemaps, see // * https://support.google.com/webmasters/answer/178636 // */ // IMAGE, // /** // * Google Video sitemaps, see // * https://support.google.com/webmasters/answer/80471 // */ // VIDEO, // /** // * Usage of <code>&lt;xhtml:links&gt;</code> in sitemaps to include // * localized page versions/variants, see // * https://support.google.com/webmasters/answer/189077 // */ // LINKS, // /** // * <cite>Mobile sitemaps just contain an empty "mobile" tag to identify a // * URL as having mobile content</cite>, cf. // * http://www.google.com/schemas/sitemap-mobile/1.0 // */ // MOBILE // } // Path: src/main/java/crawlercommons/sitemaps/Namespace.java import java.util.Arrays; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; import java.util.TreeMap; import crawlercommons.sitemaps.extension.Extension; * RSS and Atom sitemap formats do not have strict definition. But if we do * not parse as namespace aware, then RSS/Atom files that choose to use * namespaces will break. The relaxed compromise for RSS/Atom is to always * parse as "namespace aware", but we will only match elements by the * localName, accepting any element namespace. */ public static final String RSS_2_0 = "http://www.w3.org/1999/02/22-rdf-syntax-ns#"; public static final String ATOM_0_3 = "http://purl.org/atom/ns#"; public static final String ATOM_1_0 = "http://www.w3.org/2005/Atom"; public static final Set<String> SITEMAP_SUPPORTED_NAMESPACES = new HashSet<>(); static { SITEMAP_SUPPORTED_NAMESPACES.add(SITEMAP); SITEMAP_SUPPORTED_NAMESPACES.addAll(Arrays.asList(SITEMAP_LEGACY)); SITEMAP_SUPPORTED_NAMESPACES.addAll(Arrays.asList(IMAGE)); SITEMAP_SUPPORTED_NAMESPACES.addAll(Arrays.asList(VIDEO)); SITEMAP_SUPPORTED_NAMESPACES.addAll(Arrays.asList(NEWS)); SITEMAP_SUPPORTED_NAMESPACES.add(LINKS); } /** * @param uri * URI string identifying the namespace * @return true if namespace (identified by URI) is supported, false if the * namespace is not supported or unknown */ public static boolean isSupported(String uri) { return SITEMAP_SUPPORTED_NAMESPACES.contains(uri); }
public static final Map<Extension, List<String>> SITEMAP_EXTENSION_NAMESPACES = new TreeMap<>();
coderJohnZhang/TvLauncher
src/com/gotech/tv/launcher/anim/ControlViewPagerSpeed.java
// Path: src/com/gotech/tv/launcher/util/Constant.java // public class Constant { // // public static final int VIEW_PAGER_DURATION = 500; // public static final int MENU_HOME = 0; // public static final int MENU_APP = 1; // public static final int MENU_SETTING = 2; // public static final int TRAN_DUR_ANIM = 500; // public static final float APP_PAGE_SIZE = 12.0f; // public static final int APP_PAGE_COLUMNS = 4; // public static final int MOVE = 1; // public static final int PAGE_ITEM_NUM = 6; // public static final int DIALOG_AUTO_DISMISS = 0; // public static final int TIME_OUT = 5000; // // /** // * 加(解)密钥匙 // */ // public static final String DesEncryptKey = "TvLauncher"; // // /** // * 存取用户IP和软件类型 // **/ // public static final String UserServerConfigTxt = "serverconfig.txt"; // // /** // * 存用户名和密码文件 // **/ // public static final String UserDataTxt = "userpwd.txt"; // // /** // * 软件类型 // */ // public static String SOFTWARE_TYPE = "TvLauncher"; // // /** // * 默认分组号 // * 默认:创维 999 // */ // public static String MAC_REGISTER_DEFAULT_CODE = "009"; // // /** // * JSON数据格式错误 // **/ // public static int ParseData_FormatWrong = 2; // // /** // * 解析成功 // **/ // public static int ParseData_Success = 0; // // /** // * 用户访问超时 或 未登录 // **/ // public static int ParseData_TimeOut = 1; // // }
import java.lang.reflect.Field; import com.gotech.tv.launcher.util.Constant; import android.support.v4.view.ViewPager; import android.view.animation.AccelerateInterpolator;
package com.gotech.tv.launcher.anim; /** * @version 1.0 * @author: john * @date:Nov 30, 2015 10:09:46 AM * @description: fix speed scroller */ public class ControlViewPagerSpeed { private ViewPager mViewPager = null; public ControlViewPagerSpeed(ViewPager vp) { mViewPager = vp; } public void controlSpeed() { FixedSpeedScroller mScroller; try { Field mField; mField = ViewPager.class.getDeclaredField("mScroller"); mField.setAccessible(true); mScroller = new FixedSpeedScroller(mViewPager.getContext(), new AccelerateInterpolator());
// Path: src/com/gotech/tv/launcher/util/Constant.java // public class Constant { // // public static final int VIEW_PAGER_DURATION = 500; // public static final int MENU_HOME = 0; // public static final int MENU_APP = 1; // public static final int MENU_SETTING = 2; // public static final int TRAN_DUR_ANIM = 500; // public static final float APP_PAGE_SIZE = 12.0f; // public static final int APP_PAGE_COLUMNS = 4; // public static final int MOVE = 1; // public static final int PAGE_ITEM_NUM = 6; // public static final int DIALOG_AUTO_DISMISS = 0; // public static final int TIME_OUT = 5000; // // /** // * 加(解)密钥匙 // */ // public static final String DesEncryptKey = "TvLauncher"; // // /** // * 存取用户IP和软件类型 // **/ // public static final String UserServerConfigTxt = "serverconfig.txt"; // // /** // * 存用户名和密码文件 // **/ // public static final String UserDataTxt = "userpwd.txt"; // // /** // * 软件类型 // */ // public static String SOFTWARE_TYPE = "TvLauncher"; // // /** // * 默认分组号 // * 默认:创维 999 // */ // public static String MAC_REGISTER_DEFAULT_CODE = "009"; // // /** // * JSON数据格式错误 // **/ // public static int ParseData_FormatWrong = 2; // // /** // * 解析成功 // **/ // public static int ParseData_Success = 0; // // /** // * 用户访问超时 或 未登录 // **/ // public static int ParseData_TimeOut = 1; // // } // Path: src/com/gotech/tv/launcher/anim/ControlViewPagerSpeed.java import java.lang.reflect.Field; import com.gotech.tv.launcher.util.Constant; import android.support.v4.view.ViewPager; import android.view.animation.AccelerateInterpolator; package com.gotech.tv.launcher.anim; /** * @version 1.0 * @author: john * @date:Nov 30, 2015 10:09:46 AM * @description: fix speed scroller */ public class ControlViewPagerSpeed { private ViewPager mViewPager = null; public ControlViewPagerSpeed(ViewPager vp) { mViewPager = vp; } public void controlSpeed() { FixedSpeedScroller mScroller; try { Field mField; mField = ViewPager.class.getDeclaredField("mScroller"); mField.setAccessible(true); mScroller = new FixedSpeedScroller(mViewPager.getContext(), new AccelerateInterpolator());
mScroller.setmDuration(Constant.VIEW_PAGER_DURATION);
coderJohnZhang/TvLauncher
src/com/gotech/tv/launcher/view/FlyBorderView.java
// Path: src/com/gotech/tv/launcher/util/Constant.java // public class Constant { // // public static final int VIEW_PAGER_DURATION = 500; // public static final int MENU_HOME = 0; // public static final int MENU_APP = 1; // public static final int MENU_SETTING = 2; // public static final int TRAN_DUR_ANIM = 500; // public static final float APP_PAGE_SIZE = 12.0f; // public static final int APP_PAGE_COLUMNS = 4; // public static final int MOVE = 1; // public static final int PAGE_ITEM_NUM = 6; // public static final int DIALOG_AUTO_DISMISS = 0; // public static final int TIME_OUT = 5000; // // /** // * 加(解)密钥匙 // */ // public static final String DesEncryptKey = "TvLauncher"; // // /** // * 存取用户IP和软件类型 // **/ // public static final String UserServerConfigTxt = "serverconfig.txt"; // // /** // * 存用户名和密码文件 // **/ // public static final String UserDataTxt = "userpwd.txt"; // // /** // * 软件类型 // */ // public static String SOFTWARE_TYPE = "TvLauncher"; // // /** // * 默认分组号 // * 默认:创维 999 // */ // public static String MAC_REGISTER_DEFAULT_CODE = "009"; // // /** // * JSON数据格式错误 // **/ // public static int ParseData_FormatWrong = 2; // // /** // * 解析成功 // **/ // public static int ParseData_Success = 0; // // /** // * 用户访问超时 或 未登录 // **/ // public static int ParseData_TimeOut = 1; // // } // // Path: src/com/gotech/tv/launcher/util/DensityUtil.java // public class DensityUtil { // // public static int dip2px(Context context, float dpValue) { // final float scale = context.getResources().getDisplayMetrics().density; // return (int) (dpValue * scale + 0.5f); // } // // public static int px2dip(Context context, float pxValue) { // final float scale = context.getResources().getDisplayMetrics().density; // return (int) (pxValue / scale + 0.5f); // } // // }
import com.gotech.tv.launcher.util.Constant; import com.gotech.tv.launcher.util.DensityUtil; import android.content.Context; import android.graphics.Rect; import android.util.AttributeSet; import android.view.View; import android.view.ViewGroup; import android.view.animation.DecelerateInterpolator;
} /** * 设置焦点框的移动. */ public void setFocusView(View view, float scale) { if (mFocusView != view) { mFocusView = view; runTranslateAnimation(mFocusView, scale, scale); } } public void setSelectView(View view) { if (mSelectView != view) { mSelectView = view; runTranslateAnimation(mSelectView); } } private void runTranslateAnimation(View toView) { Rect fromRect = findLocationWithView(this); Rect toRect = findLocationWithView(toView); int x = toRect.left - fromRect.left; int y = toRect.top - fromRect.top; int deltaX = (toView.getWidth() - this.getWidth()) / 2; int deltaY = (toView.getHeight() - this.getHeight()) / 2; // tv if (isTvScreen) {
// Path: src/com/gotech/tv/launcher/util/Constant.java // public class Constant { // // public static final int VIEW_PAGER_DURATION = 500; // public static final int MENU_HOME = 0; // public static final int MENU_APP = 1; // public static final int MENU_SETTING = 2; // public static final int TRAN_DUR_ANIM = 500; // public static final float APP_PAGE_SIZE = 12.0f; // public static final int APP_PAGE_COLUMNS = 4; // public static final int MOVE = 1; // public static final int PAGE_ITEM_NUM = 6; // public static final int DIALOG_AUTO_DISMISS = 0; // public static final int TIME_OUT = 5000; // // /** // * 加(解)密钥匙 // */ // public static final String DesEncryptKey = "TvLauncher"; // // /** // * 存取用户IP和软件类型 // **/ // public static final String UserServerConfigTxt = "serverconfig.txt"; // // /** // * 存用户名和密码文件 // **/ // public static final String UserDataTxt = "userpwd.txt"; // // /** // * 软件类型 // */ // public static String SOFTWARE_TYPE = "TvLauncher"; // // /** // * 默认分组号 // * 默认:创维 999 // */ // public static String MAC_REGISTER_DEFAULT_CODE = "009"; // // /** // * JSON数据格式错误 // **/ // public static int ParseData_FormatWrong = 2; // // /** // * 解析成功 // **/ // public static int ParseData_Success = 0; // // /** // * 用户访问超时 或 未登录 // **/ // public static int ParseData_TimeOut = 1; // // } // // Path: src/com/gotech/tv/launcher/util/DensityUtil.java // public class DensityUtil { // // public static int dip2px(Context context, float dpValue) { // final float scale = context.getResources().getDisplayMetrics().density; // return (int) (dpValue * scale + 0.5f); // } // // public static int px2dip(Context context, float pxValue) { // final float scale = context.getResources().getDisplayMetrics().density; // return (int) (pxValue / scale + 0.5f); // } // // } // Path: src/com/gotech/tv/launcher/view/FlyBorderView.java import com.gotech.tv.launcher.util.Constant; import com.gotech.tv.launcher.util.DensityUtil; import android.content.Context; import android.graphics.Rect; import android.util.AttributeSet; import android.view.View; import android.view.ViewGroup; import android.view.animation.DecelerateInterpolator; } /** * 设置焦点框的移动. */ public void setFocusView(View view, float scale) { if (mFocusView != view) { mFocusView = view; runTranslateAnimation(mFocusView, scale, scale); } } public void setSelectView(View view) { if (mSelectView != view) { mSelectView = view; runTranslateAnimation(mSelectView); } } private void runTranslateAnimation(View toView) { Rect fromRect = findLocationWithView(this); Rect toRect = findLocationWithView(toView); int x = toRect.left - fromRect.left; int y = toRect.top - fromRect.top; int deltaX = (toView.getWidth() - this.getWidth()) / 2; int deltaY = (toView.getHeight() - this.getHeight()) / 2; // tv if (isTvScreen) {
x = DensityUtil.dip2px(this.getContext(), x + deltaX);
coderJohnZhang/TvLauncher
src/com/gotech/tv/launcher/view/FlyBorderView.java
// Path: src/com/gotech/tv/launcher/util/Constant.java // public class Constant { // // public static final int VIEW_PAGER_DURATION = 500; // public static final int MENU_HOME = 0; // public static final int MENU_APP = 1; // public static final int MENU_SETTING = 2; // public static final int TRAN_DUR_ANIM = 500; // public static final float APP_PAGE_SIZE = 12.0f; // public static final int APP_PAGE_COLUMNS = 4; // public static final int MOVE = 1; // public static final int PAGE_ITEM_NUM = 6; // public static final int DIALOG_AUTO_DISMISS = 0; // public static final int TIME_OUT = 5000; // // /** // * 加(解)密钥匙 // */ // public static final String DesEncryptKey = "TvLauncher"; // // /** // * 存取用户IP和软件类型 // **/ // public static final String UserServerConfigTxt = "serverconfig.txt"; // // /** // * 存用户名和密码文件 // **/ // public static final String UserDataTxt = "userpwd.txt"; // // /** // * 软件类型 // */ // public static String SOFTWARE_TYPE = "TvLauncher"; // // /** // * 默认分组号 // * 默认:创维 999 // */ // public static String MAC_REGISTER_DEFAULT_CODE = "009"; // // /** // * JSON数据格式错误 // **/ // public static int ParseData_FormatWrong = 2; // // /** // * 解析成功 // **/ // public static int ParseData_Success = 0; // // /** // * 用户访问超时 或 未登录 // **/ // public static int ParseData_TimeOut = 1; // // } // // Path: src/com/gotech/tv/launcher/util/DensityUtil.java // public class DensityUtil { // // public static int dip2px(Context context, float dpValue) { // final float scale = context.getResources().getDisplayMetrics().density; // return (int) (dpValue * scale + 0.5f); // } // // public static int px2dip(Context context, float pxValue) { // final float scale = context.getResources().getDisplayMetrics().density; // return (int) (pxValue / scale + 0.5f); // } // // }
import com.gotech.tv.launcher.util.Constant; import com.gotech.tv.launcher.util.DensityUtil; import android.content.Context; import android.graphics.Rect; import android.util.AttributeSet; import android.view.View; import android.view.ViewGroup; import android.view.animation.DecelerateInterpolator;
public void setSelectView(View view) { if (mSelectView != view) { mSelectView = view; runTranslateAnimation(mSelectView); } } private void runTranslateAnimation(View toView) { Rect fromRect = findLocationWithView(this); Rect toRect = findLocationWithView(toView); int x = toRect.left - fromRect.left; int y = toRect.top - fromRect.top; int deltaX = (toView.getWidth() - this.getWidth()) / 2; int deltaY = (toView.getHeight() - this.getHeight()) / 2; // tv if (isTvScreen) { x = DensityUtil.dip2px(this.getContext(), x + deltaX); y = DensityUtil.dip2px(this.getContext(), y + deltaY); } else { x = x + deltaX; y = y + deltaY; } flyWhiteBorder(x, y); } private void flyWhiteBorder(float x, float y) {
// Path: src/com/gotech/tv/launcher/util/Constant.java // public class Constant { // // public static final int VIEW_PAGER_DURATION = 500; // public static final int MENU_HOME = 0; // public static final int MENU_APP = 1; // public static final int MENU_SETTING = 2; // public static final int TRAN_DUR_ANIM = 500; // public static final float APP_PAGE_SIZE = 12.0f; // public static final int APP_PAGE_COLUMNS = 4; // public static final int MOVE = 1; // public static final int PAGE_ITEM_NUM = 6; // public static final int DIALOG_AUTO_DISMISS = 0; // public static final int TIME_OUT = 5000; // // /** // * 加(解)密钥匙 // */ // public static final String DesEncryptKey = "TvLauncher"; // // /** // * 存取用户IP和软件类型 // **/ // public static final String UserServerConfigTxt = "serverconfig.txt"; // // /** // * 存用户名和密码文件 // **/ // public static final String UserDataTxt = "userpwd.txt"; // // /** // * 软件类型 // */ // public static String SOFTWARE_TYPE = "TvLauncher"; // // /** // * 默认分组号 // * 默认:创维 999 // */ // public static String MAC_REGISTER_DEFAULT_CODE = "009"; // // /** // * JSON数据格式错误 // **/ // public static int ParseData_FormatWrong = 2; // // /** // * 解析成功 // **/ // public static int ParseData_Success = 0; // // /** // * 用户访问超时 或 未登录 // **/ // public static int ParseData_TimeOut = 1; // // } // // Path: src/com/gotech/tv/launcher/util/DensityUtil.java // public class DensityUtil { // // public static int dip2px(Context context, float dpValue) { // final float scale = context.getResources().getDisplayMetrics().density; // return (int) (dpValue * scale + 0.5f); // } // // public static int px2dip(Context context, float pxValue) { // final float scale = context.getResources().getDisplayMetrics().density; // return (int) (pxValue / scale + 0.5f); // } // // } // Path: src/com/gotech/tv/launcher/view/FlyBorderView.java import com.gotech.tv.launcher.util.Constant; import com.gotech.tv.launcher.util.DensityUtil; import android.content.Context; import android.graphics.Rect; import android.util.AttributeSet; import android.view.View; import android.view.ViewGroup; import android.view.animation.DecelerateInterpolator; public void setSelectView(View view) { if (mSelectView != view) { mSelectView = view; runTranslateAnimation(mSelectView); } } private void runTranslateAnimation(View toView) { Rect fromRect = findLocationWithView(this); Rect toRect = findLocationWithView(toView); int x = toRect.left - fromRect.left; int y = toRect.top - fromRect.top; int deltaX = (toView.getWidth() - this.getWidth()) / 2; int deltaY = (toView.getHeight() - this.getHeight()) / 2; // tv if (isTvScreen) { x = DensityUtil.dip2px(this.getContext(), x + deltaX); y = DensityUtil.dip2px(this.getContext(), y + deltaY); } else { x = x + deltaX; y = y + deltaY; } flyWhiteBorder(x, y); } private void flyWhiteBorder(float x, float y) {
animate().translationX(x).translationY(y).setDuration(Constant.TRAN_DUR_ANIM).setInterpolator(new DecelerateInterpolator()).start();
coderJohnZhang/TvLauncher
src/com/gotech/tv/launcher/util/FileUtils.java
// Path: src/com/gotech/tv/launcher/service/ContextManager.java // public class ContextManager { // //private static final String TAG = ContextManager.class.getSimpleName(); // // private static ContextManager instance = null; // // public static String ACTION_SN_ACTIVATE_RESULT = "action.sn.activate.result"; // public static String ACTION_USER_REGIST_RESULT = "action.user.regist.result"; // // public static String ACTION_LOAD_HOME_DATA_FINISH = "action.load.home.data.finish"; // // public static String LOCAL_INSTALL_PATH = Environment.getExternalStorageDirectory() + "/TvLauncher"; // public static String LOCAL_CACHE_PATH = LOCAL_INSTALL_PATH + "/download/"; // public static String LOCAL_CONFIG_PATH = LOCAL_INSTALL_PATH + "/config/"; // public static String LOCAL_FILE_PATH = LOCAL_INSTALL_PATH + "/files/"; // // static { // File file = new File(LOCAL_CACHE_PATH); // if (!file.exists()) { // file.mkdirs(); // } // file = new File(LOCAL_CONFIG_PATH); // if (!file.exists()) { // file.mkdirs(); // } // file = new File(LOCAL_FILE_PATH); // if (!file.exists()) { // file.mkdirs(); // } // } // // /** // * CN:最好使用baseContext // */ // private Context mCtx; // private UserInfoVo mUserInfo; // // private ContextManager(Context ctx) { // mCtx = ctx; // } // // public static synchronized ContextManager obtain(Context ctx) { // if (instance == null) { // instance = new ContextManager(ctx.getApplicationContext()); // } // return instance; // } // // /** // * CN:校验用户信息 // * // * @return // */ // public boolean checkUserInfoExist() { // UserInfoVo info = getUserInfo(); // return (info != null && !TextUtils.isEmpty(info.mUserName)); // } // // public UserInfoVo getUserInfo() { // if (mUserInfo == null) { // String userInfoStr = FileUtils.getInstance().getRegFile(Constant.UserDataTxt, mCtx); // if (!TextUtils.isEmpty(userInfoStr)) { // mUserInfo = new UserInfoVo(); // String[] info = userInfoStr.split("\\|\\^\\|"); // mUserInfo.mUserName = info[0]; // mUserInfo.mPassword = info[1]; // } // } // return mUserInfo; // } // // public String getUserName() { // return mUserInfo == null ? "" : mUserInfo.mUserName; // } // // }
import android.content.Context; import android.graphics.Bitmap; import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; import android.util.Log; import android.view.View; import com.gotech.tv.launcher.service.ContextManager; import java.io.BufferedOutputStream; import java.io.BufferedReader; import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.RandomAccessFile; import java.net.HttpURLConnection; import java.net.URL;
package com.gotech.tv.launcher.util; public class FileUtils { public static String TAG = "FileUtils"; private static FileUtils instance; /** * singleton * * @return */ public static FileUtils getInstance() { if (instance == null) instance = new FileUtils(); return instance; } /** * 获取注册文件内容 * * @param fileName * @param c * @return */ public String getRegFile(String fileName, Context c) { String str = ""; FileInputStream inStream = null; ByteArrayOutputStream outStream = null; try {
// Path: src/com/gotech/tv/launcher/service/ContextManager.java // public class ContextManager { // //private static final String TAG = ContextManager.class.getSimpleName(); // // private static ContextManager instance = null; // // public static String ACTION_SN_ACTIVATE_RESULT = "action.sn.activate.result"; // public static String ACTION_USER_REGIST_RESULT = "action.user.regist.result"; // // public static String ACTION_LOAD_HOME_DATA_FINISH = "action.load.home.data.finish"; // // public static String LOCAL_INSTALL_PATH = Environment.getExternalStorageDirectory() + "/TvLauncher"; // public static String LOCAL_CACHE_PATH = LOCAL_INSTALL_PATH + "/download/"; // public static String LOCAL_CONFIG_PATH = LOCAL_INSTALL_PATH + "/config/"; // public static String LOCAL_FILE_PATH = LOCAL_INSTALL_PATH + "/files/"; // // static { // File file = new File(LOCAL_CACHE_PATH); // if (!file.exists()) { // file.mkdirs(); // } // file = new File(LOCAL_CONFIG_PATH); // if (!file.exists()) { // file.mkdirs(); // } // file = new File(LOCAL_FILE_PATH); // if (!file.exists()) { // file.mkdirs(); // } // } // // /** // * CN:最好使用baseContext // */ // private Context mCtx; // private UserInfoVo mUserInfo; // // private ContextManager(Context ctx) { // mCtx = ctx; // } // // public static synchronized ContextManager obtain(Context ctx) { // if (instance == null) { // instance = new ContextManager(ctx.getApplicationContext()); // } // return instance; // } // // /** // * CN:校验用户信息 // * // * @return // */ // public boolean checkUserInfoExist() { // UserInfoVo info = getUserInfo(); // return (info != null && !TextUtils.isEmpty(info.mUserName)); // } // // public UserInfoVo getUserInfo() { // if (mUserInfo == null) { // String userInfoStr = FileUtils.getInstance().getRegFile(Constant.UserDataTxt, mCtx); // if (!TextUtils.isEmpty(userInfoStr)) { // mUserInfo = new UserInfoVo(); // String[] info = userInfoStr.split("\\|\\^\\|"); // mUserInfo.mUserName = info[0]; // mUserInfo.mPassword = info[1]; // } // } // return mUserInfo; // } // // public String getUserName() { // return mUserInfo == null ? "" : mUserInfo.mUserName; // } // // } // Path: src/com/gotech/tv/launcher/util/FileUtils.java import android.content.Context; import android.graphics.Bitmap; import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; import android.util.Log; import android.view.View; import com.gotech.tv.launcher.service.ContextManager; import java.io.BufferedOutputStream; import java.io.BufferedReader; import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.RandomAccessFile; import java.net.HttpURLConnection; import java.net.URL; package com.gotech.tv.launcher.util; public class FileUtils { public static String TAG = "FileUtils"; private static FileUtils instance; /** * singleton * * @return */ public static FileUtils getInstance() { if (instance == null) instance = new FileUtils(); return instance; } /** * 获取注册文件内容 * * @param fileName * @param c * @return */ public String getRegFile(String fileName, Context c) { String str = ""; FileInputStream inStream = null; ByteArrayOutputStream outStream = null; try {
fileName = ContextManager.LOCAL_CONFIG_PATH + fileName;
coderJohnZhang/TvLauncher
src/com/gotech/tv/launcher/view/PageIndicator.java
// Path: src/com/gotech/tv/launcher/util/DensityUtil.java // public class DensityUtil { // // public static int dip2px(Context context, float dpValue) { // final float scale = context.getResources().getDisplayMetrics().density; // return (int) (dpValue * scale + 0.5f); // } // // public static int px2dip(Context context, float pxValue) { // final float scale = context.getResources().getDisplayMetrics().density; // return (int) (pxValue / scale + 0.5f); // } // // }
import android.content.Context; import android.content.res.TypedArray; import android.graphics.Color; import android.support.v4.view.ViewPager; import android.util.AttributeSet; import android.view.Gravity; import android.view.ViewGroup; import android.widget.FrameLayout; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.TextView; import com.gotech.tv.launcher.R; import com.gotech.tv.launcher.util.DensityUtil; import java.util.Locale;
default: return UNKNOWN; } } } public static final int DEFAULT_INDICATOR_SPACING = 5; private int mActivePosition = -1; private int mIndicatorSpacing; private boolean mIndicatorTypeChanged = false; private IndicatorType mIndicatorType = IndicatorType.of(INDICATOR_TYPE_CIRCLE); private ViewPager mViewPager; public PageIndicator(Context context) { this(context, null); } public PageIndicator(Context context, AttributeSet attrs) { this(context, attrs, 0); } public PageIndicator(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); TypedArray a = context.getTheme().obtainStyledAttributes(attrs, R.styleable.PageIndicator, 0, 0); try {
// Path: src/com/gotech/tv/launcher/util/DensityUtil.java // public class DensityUtil { // // public static int dip2px(Context context, float dpValue) { // final float scale = context.getResources().getDisplayMetrics().density; // return (int) (dpValue * scale + 0.5f); // } // // public static int px2dip(Context context, float pxValue) { // final float scale = context.getResources().getDisplayMetrics().density; // return (int) (pxValue / scale + 0.5f); // } // // } // Path: src/com/gotech/tv/launcher/view/PageIndicator.java import android.content.Context; import android.content.res.TypedArray; import android.graphics.Color; import android.support.v4.view.ViewPager; import android.util.AttributeSet; import android.view.Gravity; import android.view.ViewGroup; import android.widget.FrameLayout; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.TextView; import com.gotech.tv.launcher.R; import com.gotech.tv.launcher.util.DensityUtil; import java.util.Locale; default: return UNKNOWN; } } } public static final int DEFAULT_INDICATOR_SPACING = 5; private int mActivePosition = -1; private int mIndicatorSpacing; private boolean mIndicatorTypeChanged = false; private IndicatorType mIndicatorType = IndicatorType.of(INDICATOR_TYPE_CIRCLE); private ViewPager mViewPager; public PageIndicator(Context context) { this(context, null); } public PageIndicator(Context context, AttributeSet attrs) { this(context, attrs, 0); } public PageIndicator(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); TypedArray a = context.getTheme().obtainStyledAttributes(attrs, R.styleable.PageIndicator, 0, 0); try {
mIndicatorSpacing = a.getDimensionPixelSize(R.styleable.PageIndicator_indicator_spacing, DensityUtil.dip2px(context, (float) DEFAULT_INDICATOR_SPACING));
coderJohnZhang/TvLauncher
src/com/gotech/tv/launcher/view/CustomDialog.java
// Path: src/com/gotech/tv/launcher/util/Constant.java // public class Constant { // // public static final int VIEW_PAGER_DURATION = 500; // public static final int MENU_HOME = 0; // public static final int MENU_APP = 1; // public static final int MENU_SETTING = 2; // public static final int TRAN_DUR_ANIM = 500; // public static final float APP_PAGE_SIZE = 12.0f; // public static final int APP_PAGE_COLUMNS = 4; // public static final int MOVE = 1; // public static final int PAGE_ITEM_NUM = 6; // public static final int DIALOG_AUTO_DISMISS = 0; // public static final int TIME_OUT = 5000; // // /** // * 加(解)密钥匙 // */ // public static final String DesEncryptKey = "TvLauncher"; // // /** // * 存取用户IP和软件类型 // **/ // public static final String UserServerConfigTxt = "serverconfig.txt"; // // /** // * 存用户名和密码文件 // **/ // public static final String UserDataTxt = "userpwd.txt"; // // /** // * 软件类型 // */ // public static String SOFTWARE_TYPE = "TvLauncher"; // // /** // * 默认分组号 // * 默认:创维 999 // */ // public static String MAC_REGISTER_DEFAULT_CODE = "009"; // // /** // * JSON数据格式错误 // **/ // public static int ParseData_FormatWrong = 2; // // /** // * 解析成功 // **/ // public static int ParseData_Success = 0; // // /** // * 用户访问超时 或 未登录 // **/ // public static int ParseData_TimeOut = 1; // // }
import com.gotech.tv.launcher.R; import com.gotech.tv.launcher.util.Constant; import android.app.Dialog; import android.content.Context; import android.os.Handler; import android.os.Message; import android.view.KeyEvent; import android.widget.ImageButton;
package com.gotech.tv.launcher.view; /** * @version 1.0 * @author:john * @date:Dec 1, 2015 7:30:10 PM * @description: custom dialog */ public class CustomDialog extends Dialog { private Handler mHandler = new Handler() { @Override public void handleMessage(Message msg) { switch (msg.what) {
// Path: src/com/gotech/tv/launcher/util/Constant.java // public class Constant { // // public static final int VIEW_PAGER_DURATION = 500; // public static final int MENU_HOME = 0; // public static final int MENU_APP = 1; // public static final int MENU_SETTING = 2; // public static final int TRAN_DUR_ANIM = 500; // public static final float APP_PAGE_SIZE = 12.0f; // public static final int APP_PAGE_COLUMNS = 4; // public static final int MOVE = 1; // public static final int PAGE_ITEM_NUM = 6; // public static final int DIALOG_AUTO_DISMISS = 0; // public static final int TIME_OUT = 5000; // // /** // * 加(解)密钥匙 // */ // public static final String DesEncryptKey = "TvLauncher"; // // /** // * 存取用户IP和软件类型 // **/ // public static final String UserServerConfigTxt = "serverconfig.txt"; // // /** // * 存用户名和密码文件 // **/ // public static final String UserDataTxt = "userpwd.txt"; // // /** // * 软件类型 // */ // public static String SOFTWARE_TYPE = "TvLauncher"; // // /** // * 默认分组号 // * 默认:创维 999 // */ // public static String MAC_REGISTER_DEFAULT_CODE = "009"; // // /** // * JSON数据格式错误 // **/ // public static int ParseData_FormatWrong = 2; // // /** // * 解析成功 // **/ // public static int ParseData_Success = 0; // // /** // * 用户访问超时 或 未登录 // **/ // public static int ParseData_TimeOut = 1; // // } // Path: src/com/gotech/tv/launcher/view/CustomDialog.java import com.gotech.tv.launcher.R; import com.gotech.tv.launcher.util.Constant; import android.app.Dialog; import android.content.Context; import android.os.Handler; import android.os.Message; import android.view.KeyEvent; import android.widget.ImageButton; package com.gotech.tv.launcher.view; /** * @version 1.0 * @author:john * @date:Dec 1, 2015 7:30:10 PM * @description: custom dialog */ public class CustomDialog extends Dialog { private Handler mHandler = new Handler() { @Override public void handleMessage(Message msg) { switch (msg.what) {
case Constant.DIALOG_AUTO_DISMISS:
coderJohnZhang/TvLauncher
src/com/gotech/tv/launcher/parser/ParserSet.java
// Path: src/com/gotech/tv/launcher/util/Constant.java // public class Constant { // // public static final int VIEW_PAGER_DURATION = 500; // public static final int MENU_HOME = 0; // public static final int MENU_APP = 1; // public static final int MENU_SETTING = 2; // public static final int TRAN_DUR_ANIM = 500; // public static final float APP_PAGE_SIZE = 12.0f; // public static final int APP_PAGE_COLUMNS = 4; // public static final int MOVE = 1; // public static final int PAGE_ITEM_NUM = 6; // public static final int DIALOG_AUTO_DISMISS = 0; // public static final int TIME_OUT = 5000; // // /** // * 加(解)密钥匙 // */ // public static final String DesEncryptKey = "TvLauncher"; // // /** // * 存取用户IP和软件类型 // **/ // public static final String UserServerConfigTxt = "serverconfig.txt"; // // /** // * 存用户名和密码文件 // **/ // public static final String UserDataTxt = "userpwd.txt"; // // /** // * 软件类型 // */ // public static String SOFTWARE_TYPE = "TvLauncher"; // // /** // * 默认分组号 // * 默认:创维 999 // */ // public static String MAC_REGISTER_DEFAULT_CODE = "009"; // // /** // * JSON数据格式错误 // **/ // public static int ParseData_FormatWrong = 2; // // /** // * 解析成功 // **/ // public static int ParseData_Success = 0; // // /** // * 用户访问超时 或 未登录 // **/ // public static int ParseData_TimeOut = 1; // // } // // Path: src/com/gotech/tv/launcher/vo/ParseResultVo.java // public class ParseResultVo { // // /** // * 返回结果 类型 // */ // public int result; // /** // * 返回结果 字串 (可选 ) // */ // public String reMsg; // /** // * 返回结果集合 (可选) // */ // public List<?> list; // /** // * 返回结果 总记录 // */ // public int total; // // /** // * 对象属性 // */ // public Object obj; // // @Override // public String toString() { // return buildString(); // } // // private String buildString() { // StringBuilder builder = new StringBuilder(); // builder.append("[result: " + result); // if (!TextUtils.isEmpty(reMsg)) { // builder.append(", msg: " + reMsg); // } // builder.append("]@"); // builder.append(getClass().getSimpleName()); // builder.append("@"); // builder.append(Integer.toHexString(hashCode())); // return builder.toString(); // } // } // // Path: src/com/gotech/tv/launcher/vo/UserInfoVo.java // public class UserInfoVo { // public String mUserName; // public String mPassword; // // public UserInfoVo() { // // } // // public UserInfoVo(String mUserName, String mPassword) { // this.mUserName = mUserName; // this.mPassword = mPassword; // } // // @Override // public String toString() { // return mUserName; // } // }
import com.gotech.tv.launcher.util.Constant; import com.gotech.tv.launcher.vo.ParseResultVo; import com.gotech.tv.launcher.vo.UserInfoVo; import org.json.JSONObject;
package com.gotech.tv.launcher.parser; public class ParserSet { public static class StateParser extends BaseJsonParser<Integer> { public static final String KEY_STATE = "returnCode"; @Override public Integer parse(JSONObject data) throws DataParseException { int state = data.optInt(KEY_STATE, -1); return state; } } public static class JsonBeanParser extends BaseJsonParser<JSONObject> { @Override public JSONObject parse(JSONObject data) throws DataParseException { return data; } }
// Path: src/com/gotech/tv/launcher/util/Constant.java // public class Constant { // // public static final int VIEW_PAGER_DURATION = 500; // public static final int MENU_HOME = 0; // public static final int MENU_APP = 1; // public static final int MENU_SETTING = 2; // public static final int TRAN_DUR_ANIM = 500; // public static final float APP_PAGE_SIZE = 12.0f; // public static final int APP_PAGE_COLUMNS = 4; // public static final int MOVE = 1; // public static final int PAGE_ITEM_NUM = 6; // public static final int DIALOG_AUTO_DISMISS = 0; // public static final int TIME_OUT = 5000; // // /** // * 加(解)密钥匙 // */ // public static final String DesEncryptKey = "TvLauncher"; // // /** // * 存取用户IP和软件类型 // **/ // public static final String UserServerConfigTxt = "serverconfig.txt"; // // /** // * 存用户名和密码文件 // **/ // public static final String UserDataTxt = "userpwd.txt"; // // /** // * 软件类型 // */ // public static String SOFTWARE_TYPE = "TvLauncher"; // // /** // * 默认分组号 // * 默认:创维 999 // */ // public static String MAC_REGISTER_DEFAULT_CODE = "009"; // // /** // * JSON数据格式错误 // **/ // public static int ParseData_FormatWrong = 2; // // /** // * 解析成功 // **/ // public static int ParseData_Success = 0; // // /** // * 用户访问超时 或 未登录 // **/ // public static int ParseData_TimeOut = 1; // // } // // Path: src/com/gotech/tv/launcher/vo/ParseResultVo.java // public class ParseResultVo { // // /** // * 返回结果 类型 // */ // public int result; // /** // * 返回结果 字串 (可选 ) // */ // public String reMsg; // /** // * 返回结果集合 (可选) // */ // public List<?> list; // /** // * 返回结果 总记录 // */ // public int total; // // /** // * 对象属性 // */ // public Object obj; // // @Override // public String toString() { // return buildString(); // } // // private String buildString() { // StringBuilder builder = new StringBuilder(); // builder.append("[result: " + result); // if (!TextUtils.isEmpty(reMsg)) { // builder.append(", msg: " + reMsg); // } // builder.append("]@"); // builder.append(getClass().getSimpleName()); // builder.append("@"); // builder.append(Integer.toHexString(hashCode())); // return builder.toString(); // } // } // // Path: src/com/gotech/tv/launcher/vo/UserInfoVo.java // public class UserInfoVo { // public String mUserName; // public String mPassword; // // public UserInfoVo() { // // } // // public UserInfoVo(String mUserName, String mPassword) { // this.mUserName = mUserName; // this.mPassword = mPassword; // } // // @Override // public String toString() { // return mUserName; // } // } // Path: src/com/gotech/tv/launcher/parser/ParserSet.java import com.gotech.tv.launcher.util.Constant; import com.gotech.tv.launcher.vo.ParseResultVo; import com.gotech.tv.launcher.vo.UserInfoVo; import org.json.JSONObject; package com.gotech.tv.launcher.parser; public class ParserSet { public static class StateParser extends BaseJsonParser<Integer> { public static final String KEY_STATE = "returnCode"; @Override public Integer parse(JSONObject data) throws DataParseException { int state = data.optInt(KEY_STATE, -1); return state; } } public static class JsonBeanParser extends BaseJsonParser<JSONObject> { @Override public JSONObject parse(JSONObject data) throws DataParseException { return data; } }
public static class UserInfoParser extends BaseJsonParser<ParseResultVo> {
coderJohnZhang/TvLauncher
src/com/gotech/tv/launcher/parser/ParserSet.java
// Path: src/com/gotech/tv/launcher/util/Constant.java // public class Constant { // // public static final int VIEW_PAGER_DURATION = 500; // public static final int MENU_HOME = 0; // public static final int MENU_APP = 1; // public static final int MENU_SETTING = 2; // public static final int TRAN_DUR_ANIM = 500; // public static final float APP_PAGE_SIZE = 12.0f; // public static final int APP_PAGE_COLUMNS = 4; // public static final int MOVE = 1; // public static final int PAGE_ITEM_NUM = 6; // public static final int DIALOG_AUTO_DISMISS = 0; // public static final int TIME_OUT = 5000; // // /** // * 加(解)密钥匙 // */ // public static final String DesEncryptKey = "TvLauncher"; // // /** // * 存取用户IP和软件类型 // **/ // public static final String UserServerConfigTxt = "serverconfig.txt"; // // /** // * 存用户名和密码文件 // **/ // public static final String UserDataTxt = "userpwd.txt"; // // /** // * 软件类型 // */ // public static String SOFTWARE_TYPE = "TvLauncher"; // // /** // * 默认分组号 // * 默认:创维 999 // */ // public static String MAC_REGISTER_DEFAULT_CODE = "009"; // // /** // * JSON数据格式错误 // **/ // public static int ParseData_FormatWrong = 2; // // /** // * 解析成功 // **/ // public static int ParseData_Success = 0; // // /** // * 用户访问超时 或 未登录 // **/ // public static int ParseData_TimeOut = 1; // // } // // Path: src/com/gotech/tv/launcher/vo/ParseResultVo.java // public class ParseResultVo { // // /** // * 返回结果 类型 // */ // public int result; // /** // * 返回结果 字串 (可选 ) // */ // public String reMsg; // /** // * 返回结果集合 (可选) // */ // public List<?> list; // /** // * 返回结果 总记录 // */ // public int total; // // /** // * 对象属性 // */ // public Object obj; // // @Override // public String toString() { // return buildString(); // } // // private String buildString() { // StringBuilder builder = new StringBuilder(); // builder.append("[result: " + result); // if (!TextUtils.isEmpty(reMsg)) { // builder.append(", msg: " + reMsg); // } // builder.append("]@"); // builder.append(getClass().getSimpleName()); // builder.append("@"); // builder.append(Integer.toHexString(hashCode())); // return builder.toString(); // } // } // // Path: src/com/gotech/tv/launcher/vo/UserInfoVo.java // public class UserInfoVo { // public String mUserName; // public String mPassword; // // public UserInfoVo() { // // } // // public UserInfoVo(String mUserName, String mPassword) { // this.mUserName = mUserName; // this.mPassword = mPassword; // } // // @Override // public String toString() { // return mUserName; // } // }
import com.gotech.tv.launcher.util.Constant; import com.gotech.tv.launcher.vo.ParseResultVo; import com.gotech.tv.launcher.vo.UserInfoVo; import org.json.JSONObject;
package com.gotech.tv.launcher.parser; public class ParserSet { public static class StateParser extends BaseJsonParser<Integer> { public static final String KEY_STATE = "returnCode"; @Override public Integer parse(JSONObject data) throws DataParseException { int state = data.optInt(KEY_STATE, -1); return state; } } public static class JsonBeanParser extends BaseJsonParser<JSONObject> { @Override public JSONObject parse(JSONObject data) throws DataParseException { return data; } } public static class UserInfoParser extends BaseJsonParser<ParseResultVo> { @Override public ParseResultVo parse(JSONObject data) throws DataParseException { ParseResultVo vo = new ParseResultVo(); vo.result = data.optInt("errorCode", -1); vo.reMsg = data.optString("errorInfo");
// Path: src/com/gotech/tv/launcher/util/Constant.java // public class Constant { // // public static final int VIEW_PAGER_DURATION = 500; // public static final int MENU_HOME = 0; // public static final int MENU_APP = 1; // public static final int MENU_SETTING = 2; // public static final int TRAN_DUR_ANIM = 500; // public static final float APP_PAGE_SIZE = 12.0f; // public static final int APP_PAGE_COLUMNS = 4; // public static final int MOVE = 1; // public static final int PAGE_ITEM_NUM = 6; // public static final int DIALOG_AUTO_DISMISS = 0; // public static final int TIME_OUT = 5000; // // /** // * 加(解)密钥匙 // */ // public static final String DesEncryptKey = "TvLauncher"; // // /** // * 存取用户IP和软件类型 // **/ // public static final String UserServerConfigTxt = "serverconfig.txt"; // // /** // * 存用户名和密码文件 // **/ // public static final String UserDataTxt = "userpwd.txt"; // // /** // * 软件类型 // */ // public static String SOFTWARE_TYPE = "TvLauncher"; // // /** // * 默认分组号 // * 默认:创维 999 // */ // public static String MAC_REGISTER_DEFAULT_CODE = "009"; // // /** // * JSON数据格式错误 // **/ // public static int ParseData_FormatWrong = 2; // // /** // * 解析成功 // **/ // public static int ParseData_Success = 0; // // /** // * 用户访问超时 或 未登录 // **/ // public static int ParseData_TimeOut = 1; // // } // // Path: src/com/gotech/tv/launcher/vo/ParseResultVo.java // public class ParseResultVo { // // /** // * 返回结果 类型 // */ // public int result; // /** // * 返回结果 字串 (可选 ) // */ // public String reMsg; // /** // * 返回结果集合 (可选) // */ // public List<?> list; // /** // * 返回结果 总记录 // */ // public int total; // // /** // * 对象属性 // */ // public Object obj; // // @Override // public String toString() { // return buildString(); // } // // private String buildString() { // StringBuilder builder = new StringBuilder(); // builder.append("[result: " + result); // if (!TextUtils.isEmpty(reMsg)) { // builder.append(", msg: " + reMsg); // } // builder.append("]@"); // builder.append(getClass().getSimpleName()); // builder.append("@"); // builder.append(Integer.toHexString(hashCode())); // return builder.toString(); // } // } // // Path: src/com/gotech/tv/launcher/vo/UserInfoVo.java // public class UserInfoVo { // public String mUserName; // public String mPassword; // // public UserInfoVo() { // // } // // public UserInfoVo(String mUserName, String mPassword) { // this.mUserName = mUserName; // this.mPassword = mPassword; // } // // @Override // public String toString() { // return mUserName; // } // } // Path: src/com/gotech/tv/launcher/parser/ParserSet.java import com.gotech.tv.launcher.util.Constant; import com.gotech.tv.launcher.vo.ParseResultVo; import com.gotech.tv.launcher.vo.UserInfoVo; import org.json.JSONObject; package com.gotech.tv.launcher.parser; public class ParserSet { public static class StateParser extends BaseJsonParser<Integer> { public static final String KEY_STATE = "returnCode"; @Override public Integer parse(JSONObject data) throws DataParseException { int state = data.optInt(KEY_STATE, -1); return state; } } public static class JsonBeanParser extends BaseJsonParser<JSONObject> { @Override public JSONObject parse(JSONObject data) throws DataParseException { return data; } } public static class UserInfoParser extends BaseJsonParser<ParseResultVo> { @Override public ParseResultVo parse(JSONObject data) throws DataParseException { ParseResultVo vo = new ParseResultVo(); vo.result = data.optInt("errorCode", -1); vo.reMsg = data.optString("errorInfo");
vo.obj = new UserInfoVo(data.optString("accountid", ""), data.optString("accountid", "password"));
coderJohnZhang/TvLauncher
src/com/gotech/tv/launcher/parser/ParserSet.java
// Path: src/com/gotech/tv/launcher/util/Constant.java // public class Constant { // // public static final int VIEW_PAGER_DURATION = 500; // public static final int MENU_HOME = 0; // public static final int MENU_APP = 1; // public static final int MENU_SETTING = 2; // public static final int TRAN_DUR_ANIM = 500; // public static final float APP_PAGE_SIZE = 12.0f; // public static final int APP_PAGE_COLUMNS = 4; // public static final int MOVE = 1; // public static final int PAGE_ITEM_NUM = 6; // public static final int DIALOG_AUTO_DISMISS = 0; // public static final int TIME_OUT = 5000; // // /** // * 加(解)密钥匙 // */ // public static final String DesEncryptKey = "TvLauncher"; // // /** // * 存取用户IP和软件类型 // **/ // public static final String UserServerConfigTxt = "serverconfig.txt"; // // /** // * 存用户名和密码文件 // **/ // public static final String UserDataTxt = "userpwd.txt"; // // /** // * 软件类型 // */ // public static String SOFTWARE_TYPE = "TvLauncher"; // // /** // * 默认分组号 // * 默认:创维 999 // */ // public static String MAC_REGISTER_DEFAULT_CODE = "009"; // // /** // * JSON数据格式错误 // **/ // public static int ParseData_FormatWrong = 2; // // /** // * 解析成功 // **/ // public static int ParseData_Success = 0; // // /** // * 用户访问超时 或 未登录 // **/ // public static int ParseData_TimeOut = 1; // // } // // Path: src/com/gotech/tv/launcher/vo/ParseResultVo.java // public class ParseResultVo { // // /** // * 返回结果 类型 // */ // public int result; // /** // * 返回结果 字串 (可选 ) // */ // public String reMsg; // /** // * 返回结果集合 (可选) // */ // public List<?> list; // /** // * 返回结果 总记录 // */ // public int total; // // /** // * 对象属性 // */ // public Object obj; // // @Override // public String toString() { // return buildString(); // } // // private String buildString() { // StringBuilder builder = new StringBuilder(); // builder.append("[result: " + result); // if (!TextUtils.isEmpty(reMsg)) { // builder.append(", msg: " + reMsg); // } // builder.append("]@"); // builder.append(getClass().getSimpleName()); // builder.append("@"); // builder.append(Integer.toHexString(hashCode())); // return builder.toString(); // } // } // // Path: src/com/gotech/tv/launcher/vo/UserInfoVo.java // public class UserInfoVo { // public String mUserName; // public String mPassword; // // public UserInfoVo() { // // } // // public UserInfoVo(String mUserName, String mPassword) { // this.mUserName = mUserName; // this.mPassword = mPassword; // } // // @Override // public String toString() { // return mUserName; // } // }
import com.gotech.tv.launcher.util.Constant; import com.gotech.tv.launcher.vo.ParseResultVo; import com.gotech.tv.launcher.vo.UserInfoVo; import org.json.JSONObject;
public static class TokenUpdateParser extends BaseJsonParser<String> { @Override public String parse(JSONObject data) throws DataParseException { return data.optString("newUserToken"); } } public static class HeartRunParser extends BaseJsonParser<Integer> { @Override public Integer parse(JSONObject data) throws DataParseException { return data.optInt("status"); } } public static class FindUserIdParser extends BaseJsonParser<String> { @Override public String parse(JSONObject data) throws DataParseException { return data.optString("userid"); } } public static class HistoryParser extends BaseJsonParser<ParseResultVo> { private static final String KEY_DES = "description"; @Override public ParseResultVo parse(JSONObject data) throws DataParseException { ParseResultVo vo = new ParseResultVo(); if (data.has(StateParser.KEY_STATE)) {
// Path: src/com/gotech/tv/launcher/util/Constant.java // public class Constant { // // public static final int VIEW_PAGER_DURATION = 500; // public static final int MENU_HOME = 0; // public static final int MENU_APP = 1; // public static final int MENU_SETTING = 2; // public static final int TRAN_DUR_ANIM = 500; // public static final float APP_PAGE_SIZE = 12.0f; // public static final int APP_PAGE_COLUMNS = 4; // public static final int MOVE = 1; // public static final int PAGE_ITEM_NUM = 6; // public static final int DIALOG_AUTO_DISMISS = 0; // public static final int TIME_OUT = 5000; // // /** // * 加(解)密钥匙 // */ // public static final String DesEncryptKey = "TvLauncher"; // // /** // * 存取用户IP和软件类型 // **/ // public static final String UserServerConfigTxt = "serverconfig.txt"; // // /** // * 存用户名和密码文件 // **/ // public static final String UserDataTxt = "userpwd.txt"; // // /** // * 软件类型 // */ // public static String SOFTWARE_TYPE = "TvLauncher"; // // /** // * 默认分组号 // * 默认:创维 999 // */ // public static String MAC_REGISTER_DEFAULT_CODE = "009"; // // /** // * JSON数据格式错误 // **/ // public static int ParseData_FormatWrong = 2; // // /** // * 解析成功 // **/ // public static int ParseData_Success = 0; // // /** // * 用户访问超时 或 未登录 // **/ // public static int ParseData_TimeOut = 1; // // } // // Path: src/com/gotech/tv/launcher/vo/ParseResultVo.java // public class ParseResultVo { // // /** // * 返回结果 类型 // */ // public int result; // /** // * 返回结果 字串 (可选 ) // */ // public String reMsg; // /** // * 返回结果集合 (可选) // */ // public List<?> list; // /** // * 返回结果 总记录 // */ // public int total; // // /** // * 对象属性 // */ // public Object obj; // // @Override // public String toString() { // return buildString(); // } // // private String buildString() { // StringBuilder builder = new StringBuilder(); // builder.append("[result: " + result); // if (!TextUtils.isEmpty(reMsg)) { // builder.append(", msg: " + reMsg); // } // builder.append("]@"); // builder.append(getClass().getSimpleName()); // builder.append("@"); // builder.append(Integer.toHexString(hashCode())); // return builder.toString(); // } // } // // Path: src/com/gotech/tv/launcher/vo/UserInfoVo.java // public class UserInfoVo { // public String mUserName; // public String mPassword; // // public UserInfoVo() { // // } // // public UserInfoVo(String mUserName, String mPassword) { // this.mUserName = mUserName; // this.mPassword = mPassword; // } // // @Override // public String toString() { // return mUserName; // } // } // Path: src/com/gotech/tv/launcher/parser/ParserSet.java import com.gotech.tv.launcher.util.Constant; import com.gotech.tv.launcher.vo.ParseResultVo; import com.gotech.tv.launcher.vo.UserInfoVo; import org.json.JSONObject; public static class TokenUpdateParser extends BaseJsonParser<String> { @Override public String parse(JSONObject data) throws DataParseException { return data.optString("newUserToken"); } } public static class HeartRunParser extends BaseJsonParser<Integer> { @Override public Integer parse(JSONObject data) throws DataParseException { return data.optInt("status"); } } public static class FindUserIdParser extends BaseJsonParser<String> { @Override public String parse(JSONObject data) throws DataParseException { return data.optString("userid"); } } public static class HistoryParser extends BaseJsonParser<ParseResultVo> { private static final String KEY_DES = "description"; @Override public ParseResultVo parse(JSONObject data) throws DataParseException { ParseResultVo vo = new ParseResultVo(); if (data.has(StateParser.KEY_STATE)) {
vo.result = Constant.ParseData_TimeOut;
coderJohnZhang/TvLauncher
src/com/gotech/tv/launcher/adapter/AppGridAdapter.java
// Path: src/com/gotech/tv/launcher/vo/AppInfoVo.java // public class AppInfoVo { // // public String mAppName; // public String mAppPackageName; // public Drawable mAppIcon; // public Intent mAppIntent; // public Integer[] mAppPanelId = {R.drawable.color_01, R.drawable.color_02, R.drawable.color_03, R.drawable.color_04, R.drawable.color_05, R.drawable.color_06, R.drawable.color_07, // R.drawable.color_08, R.drawable.color_09, R.drawable.color_10, R.drawable.color_11, R.drawable.color_12}; // public boolean isSystemApps = false; // // }
import java.util.ArrayList; import java.util.List; import com.gotech.tv.launcher.R; import com.gotech.tv.launcher.vo.AppInfoVo; import android.content.Context; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.BaseAdapter; import android.widget.ImageView; import android.widget.TextView;
package com.gotech.tv.launcher.adapter; public class AppGridAdapter extends BaseAdapter { private int mPage = 0; private int mPageSize = 0;
// Path: src/com/gotech/tv/launcher/vo/AppInfoVo.java // public class AppInfoVo { // // public String mAppName; // public String mAppPackageName; // public Drawable mAppIcon; // public Intent mAppIntent; // public Integer[] mAppPanelId = {R.drawable.color_01, R.drawable.color_02, R.drawable.color_03, R.drawable.color_04, R.drawable.color_05, R.drawable.color_06, R.drawable.color_07, // R.drawable.color_08, R.drawable.color_09, R.drawable.color_10, R.drawable.color_11, R.drawable.color_12}; // public boolean isSystemApps = false; // // } // Path: src/com/gotech/tv/launcher/adapter/AppGridAdapter.java import java.util.ArrayList; import java.util.List; import com.gotech.tv.launcher.R; import com.gotech.tv.launcher.vo.AppInfoVo; import android.content.Context; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.BaseAdapter; import android.widget.ImageView; import android.widget.TextView; package com.gotech.tv.launcher.adapter; public class AppGridAdapter extends BaseAdapter { private int mPage = 0; private int mPageSize = 0;
private List<AppInfoVo> mData = null;