@Test public void testOnceTuples() { IGeneratorSet generatorSet = generatorSetResources_.read("generator-set-once.xml"); ITestCaseGenerator[] generators = IteratorUtils.toArray(generatorSet.getGenerators(), ITestCaseGenerator.class); assertEquals("Generators", 1, generators.length); TupleGenerator tupleGenerator; TupleCombiner[] combiners; TupleCombiner combiner; tupleGenerator = (TupleGenerator) generators[0]; combiners = tupleGenerator .getCombiners() .toArray(new TupleCombiner[tupleGenerator.getCombiners().size()]); assertEquals("Default generator, combiners", 1, tupleGenerator.getCombiners().size()); combiner = combiners[0]; assertSetEquals( "Other tuples", new TupleRef[] { new TupleRef() .addVarBinding(new VarBinding("X1", "V1")) .addVarBinding(new VarBinding("X2", "V2")) .addVarBinding(new VarBinding("X3", "V3")), new TupleRef() .addVarBinding(new VarBinding("X4", "V4")) .addVarBinding(new VarBinding("X5", "V5")) .addVarBinding(new VarBinding("X6", "V6")) }, combiner.getOnceTuples()); }
/** * Tests {@link GeneratorSetDocReader#getGeneratorSet getGeneratorSet()} using the following * inputs. * * <p> * * <TABLE border="1" cellpadding="8"> * <TR align="left"><TH colspan=2> 3. getGeneratorSet (Success) </TH></TR> * <TR align="left"><TH> Input Choice </TH> <TH> Value </TH></TR> * <TR><TD> TupleGenerator.Count </TD> <TD> One </TD></TR> * <TR><TD> TupleGenerator.Function </TD> <TD> All </TD></TR> * <TR><TD> TupleGenerator.Seed </TD> <TD> Default </TD></TR> * <TR><TD> TupleGenerator.Tuples </TD> <TD> Defined </TD></TR> * <TR><TD> Combiner.Count </TD> <TD> Many </TD></TR> * <TR><TD> Combiner.Tuples </TD> <TD> Defined </TD></TR> * <TR><TD> Include.Count </TD> <TD> Many </TD></TR> * <TR><TD> Include.Var </TD> <TD> Valid </TD></TR> * <TR><TD> Exclude.Count </TD> <TD> One </TD></TR> * <TR><TD> Exclude.Var </TD> <TD> Valid </TD></TR> * </TABLE> */ @Test public void testGetGeneratorSet_3() { IGeneratorSet generatorSet = generatorSetResources_.read("generator-set-3.xml"); ITestCaseGenerator[] generators = IteratorUtils.toArray(generatorSet.getGenerators(), ITestCaseGenerator.class); assertEquals("Generators", 1, generators.length); TupleGenerator tupleGenerator; String functionName; TupleCombiner[] combiners; TupleCombiner combiner; VarSet varSet; IVarDef varDef; tupleGenerator = (TupleGenerator) generators[0]; functionName = "F4"; assertEquals( "Found default generator for function=" + functionName, true, tupleGenerator == generatorSet.getGenerator(functionName)); assertEquals("Default generator, seed", null, tupleGenerator.getRandomSeed()); assertEquals("Default generator, defaultTupleSize", 3, tupleGenerator.getDefaultTupleSize()); combiners = tupleGenerator .getCombiners() .toArray(new TupleCombiner[tupleGenerator.getCombiners().size()]); assertEquals("Default generator, combiners", 2, tupleGenerator.getCombiners().size()); combiner = combiners[0]; assertEquals("Combiner[0], tupleSize", 1, combiner.getTupleSize()); assertEquals( "Combiner[0], onceTuples", 0, IteratorUtils.toArray(combiner.getOnceTuples(), TupleRef.class).length); varSet = new VarSet("A") .addMember(new VarDef("B")) .addMember(new VarSet("X").addMember(new VarDef("Y"))); varDef = varSet.getDescendant("X.Y"); assertEquals("Combiner[0], var=" + varDef + ", eligible", true, combiner.isEligible(varDef)); varDef = varSet.getDescendant("B"); assertEquals("Combiner[0], var=" + varDef + ", eligible", false, combiner.isEligible(varDef)); varDef = new VarDef("C"); assertEquals("Combiner[0], var=" + varDef + ", eligible", true, combiner.isEligible(varDef)); varDef = new VarDef("D"); assertEquals("Combiner[0], var=" + varDef + ", eligible", false, combiner.isEligible(varDef)); combiner = combiners[1]; assertEquals("Combiner[1], tupleSize", 3, combiner.getTupleSize()); varSet = new VarSet("D") .addMember(new VarSet("X").addMember(new VarDef("Y"))) .addMember(new VarDef("Z")) .addMember(new VarSet("E").addMember(new VarDef("E1"))); varDef = varSet.getDescendant("X.Y"); assertEquals("Combiner[1], var=" + varDef + ", eligible", true, combiner.isEligible(varDef)); varDef = varSet.getDescendant("Z"); assertEquals("Combiner[1], var=" + varDef + ", eligible", true, combiner.isEligible(varDef)); varDef = varSet.getDescendant("E.E1"); assertEquals("Combiner[1], var=" + varDef + ", eligible", false, combiner.isEligible(varDef)); varDef = new VarDef("F"); assertEquals("Combiner[1], var=" + varDef + ", eligible", false, combiner.isEligible(varDef)); }