org.minijson.tool.testset.AutoGenerator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of minijson-tool Show documentation
Show all versions of minijson-tool Show documentation
A simple JSON parser/generator in Java. Tool module.
The newest version!
package org.minijson.tool.testset;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Random;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.minijson.builder.IndentedJsonBuilder;
import org.minijson.builder.JsonBuilderException;
import org.minijson.mini.MiniJsonBuilder;
// Auto generates a set of JSON strings according to the given spec...
// ...
// This effort has been abandoned.
// This class is not completely implemented...
// ...
public class AutoGenerator implements Generator
{
private static final Logger log = Logger.getLogger(AutoGenerator.class.getName());
private static final Random sRandom = new Random(System.currentTimeMillis());
public AutoGenerator()
{
}
@Override
public List generateTestSet(JsonTestSetSpec jsonTestSetSpec)
{
if(jsonTestSetSpec == null || jsonTestSetSpec.isSpecEmpty()) {
log.warning("jsonTestSetSpec is null/empty. Cannot proceed.");
return null;
}
// re-process the data first
int size = jsonTestSetSpec.specSize();
List specs = new ArrayList();
List weights = new ArrayList();
List cumulWeights = new ArrayList();
double cumulWeight = 0.0;
double totalWeight = 0.0;
for(JsonTestDataSpec s : jsonTestSetSpec.specSet()) {
specs.add(s);
double w = jsonTestSetSpec.getWeight(s);
w += 0.01; // In case all weights are zero (even when some of them are), we add some small non-zero values.
weights.add(w);
cumulWeight += w;
cumulWeights.add(cumulWeight);
totalWeight = cumulWeight;
}
for(int i=0; i< size; i++) {
}
// Json serializer.
IndentedJsonBuilder jsonBuilder = new MiniJsonBuilder();
List jsonStrList = new ArrayList();
int count = jsonTestSetSpec.getCount();
for(int c=0; c();
// tbd..
} else {
topNode = new LinkedHashMap();
// tbd ...
}
return topNode;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy