/** * Array of values that are not objects where each item must match the provided example * @param value Value to use to match each item * @param numberExamples number of examples to generate */ public PactDslJsonArray eachLike(PactDslJsonRootValue value, int numberExamples) { if (numberExamples == 0) { throw new IllegalArgumentException("Testing Zero examples is unsafe. Please make sure to provide at least one " + "example in the Pact provider implementation. See https://github.com/DiUS/pact-jvm/issues/546"); } matchers.addRule(rootPath + appendArrayIndex(1), matchMin(0)); PactDslJsonArray parent = new PactDslJsonArray(rootPath, "", this, true); parent.setNumberExamples(numberExamples); parent.putObject(value); return (PactDslJsonArray) parent.closeArray(); }
public LambdaDslJsonArray decimalType(final BigDecimal example) { pactArray.decimalType(example); return this; }
@Override public PactDslJsonArray eachArrayLike() { return eachArrayLike(1); }
@Override public PactDslJsonArray eachArrayLike(int numberExamples) { matchers.addRule(rootPath + appendArrayIndex(1), matchMin(0)); PactDslJsonArray parent = new PactDslJsonArray(rootPath, "", this, true); parent.setNumberExamples(numberExamples); return new PactDslJsonArray("", "", parent); }
/** * Root level array where each item must match the provided matcher * @param numberExamples Number of examples to generate */ public static PactDslJsonArray arrayEachLike(Integer numberExamples, PactDslJsonRootValue value) { PactDslJsonArray parent = new PactDslJsonArray("", "", null, true); parent.setNumberExamples(numberExamples); parent.matchers.addRule("", parent.matchMin(0)); parent.putObject(value); return parent; }
@Override public PactDslJsonArray eachArrayWithMaxLike(int numberExamples, Integer size) { if (numberExamples > size) { throw new IllegalArgumentException(String.format("Number of example %d is more than the maximum size of %d", numberExamples, size)); } matchers.addRule(rootPath + appendArrayIndex(1), matchMax(size)); PactDslJsonArray parent = new PactDslJsonArray(rootPath, "", this, true); parent.setNumberExamples(numberExamples); return new PactDslJsonArray("", "", parent); }
/** * Attribute that is an array of values that are not objects where each item must match the following example * @param name field name * @param value Value to use to match each item * @param numberExamples number of examples to generate */ public PactDslJsonBody eachLike(String name, PactDslJsonRootValue value, int numberExamples) { matchers.addRule(matcherKey(name), matchMin(0)); PactDslJsonArray parent = new PactDslJsonArray(matcherKey(name), "", this, true); parent.setNumberExamples(numberExamples); parent.putObject(value); return (PactDslJsonBody) parent.closeArray(); }
/** * Array of values with a maximum size that are not objects where each item must match the provided example * @param size maximum size of the array * @param value Value to use to match each item * @param numberExamples number of examples to generate */ public PactDslJsonArray maxArrayLike(Integer size, PactDslJsonRootValue value, int numberExamples) { if (numberExamples > size) { throw new IllegalArgumentException(String.format("Number of example %d is more than the maximum size of %d", numberExamples, size)); } matchers.addRule(rootPath + appendArrayIndex(1), matchMax(size)); PactDslJsonArray parent = new PactDslJsonArray(rootPath, "", this, true); parent.setNumberExamples(numberExamples); parent.putObject(value); return (PactDslJsonArray) parent.closeArray(); }
@Override public PactDslJsonArray eachArrayWithMaxLike(String name, int numberExamples, Integer size) { if (numberExamples > size) { throw new IllegalArgumentException(String.format("Number of example %d is more than the maximum size of %d", numberExamples, size)); } matchers.addRule(matcherKey(name), matchMax(size)); PactDslJsonArray parent = new PactDslJsonArray(matcherKey(name), name, this, true); parent.setNumberExamples(numberExamples); return new PactDslJsonArray("", "", parent); }
public static LambdaDslJsonArray newJsonArrayMinLike(Integer size, Consumer<LambdaDslJsonArray> array) { final PactDslJsonArray pactDslJsonArray = new PactDslJsonArray("", "", null, true); pactDslJsonArray.setNumberExamples(size); pactDslJsonArray.getMatchers().addRule(new MinTypeMatcher(size)); final LambdaDslJsonArray dslArray = new LambdaDslJsonArray(pactDslJsonArray); array.accept(dslArray); return dslArray; }
/** * Array where each item must match the following example * @param numberExamples Number of examples to generate */ public static PactDslJsonBody arrayEachLike(Integer numberExamples) { PactDslJsonArray parent = new PactDslJsonArray("", "", null, true); parent.setNumberExamples(numberExamples); parent.matchers.addRule("", parent.matchMin(0)); return new PactDslJsonBody(".", "", parent); }
public LambdaDslObject array(final String name, final Consumer<LambdaDslJsonArray> array) { final PactDslJsonArray pactArray = object.array(name); final LambdaDslJsonArray dslArray = new LambdaDslJsonArray(pactArray); array.accept(dslArray); pactArray.closeArray(); return this; }
public LambdaDslJsonArray eachArrayWithMinMaxLike(Integer minSize, Integer maxSize, int numberExamples, Consumer<LambdaDslJsonArray> nestedArray) { final PactDslJsonArray arrayLike = pactArray.eachArrayWithMinMaxLike(numberExamples, minSize, maxSize); final LambdaDslJsonArray dslArray = new LambdaDslJsonArray(arrayLike); nestedArray.accept(dslArray); arrayLike.closeArray().closeArray(); return this; }
public LambdaDslJsonArray eachArrayWithMaxLike(int numberExamples, Integer size, Consumer<LambdaDslJsonArray> nestedArray) { final PactDslJsonArray arrayLike = pactArray.eachArrayWithMaxLike(numberExamples, size); final LambdaDslJsonArray dslArray = new LambdaDslJsonArray(arrayLike); nestedArray.accept(dslArray); arrayLike.closeArray().closeArray(); return this; }
public LambdaDslJsonArray eachArrayWithMinLike(Integer size, Consumer<LambdaDslJsonArray> nestedArray) { final PactDslJsonArray arrayLike = pactArray.eachArrayWithMinLike(size); final LambdaDslJsonArray dslArray = new LambdaDslJsonArray(arrayLike); nestedArray.accept(dslArray); arrayLike.closeArray().closeArray(); return this; }
public LambdaDslJsonArray eachArrayLike(Consumer<LambdaDslJsonArray> nestedArray) { final PactDslJsonArray arrayLike = pactArray.eachArrayLike(); final LambdaDslJsonArray dslArray = new LambdaDslJsonArray(arrayLike); nestedArray.accept(dslArray); arrayLike.closeArray().closeArray(); return this; }
/** * Array of values that are not objects where each item must match the provided example * @param value Value to use to match each item */ public PactDslJsonArray eachLike(PactDslJsonRootValue value) { return eachLike(value, 1); }
/** * Element that is a JSON array */ public PactDslJsonArray array() { return new PactDslJsonArray("", "", this); }
/** * Element that must be a decimal value */ public PactDslJsonArray decimalType() { generators.addGenerator(Category.BODY, rootPath + appendArrayIndex(1), new RandomDecimalGenerator(10)); return decimalType(new BigDecimal("100")); }
/** * Element that must be encoded as a hexadecimal value */ public PactDslJsonArray hexValue() { generators.addGenerator(Category.BODY, rootPath + appendArrayIndex(1), new RandomHexadecimalGenerator(10)); return hexValue("1234a"); }