/** * Element that is a JSON object */ public PactDslJsonBody object() { return new PactDslJsonBody(".", "", this); }
/** * Element that is a JSON object */ public PactDslJsonBody object() { return new PactDslJsonBody(".", "", this); }
public static PactDslJsonBody jsonBody() { return new PactDslJsonBody(); }
public static LambdaDslJsonBody newJsonBody(Consumer<LambdaDslJsonBody> array) { final PactDslJsonBody pactDslJsonBody = new PactDslJsonBody(); final LambdaDslJsonBody dslBody = new LambdaDslJsonBody(pactDslJsonBody); array.accept(dslBody); return dslBody; } }
/** * Attribute that is a JSON object * @param name field name */ public PactDslJsonBody object(String name) { String base = rootPath + name; if (!name.matches(Parser$.MODULE$.FieldRegex().toString())) { base = StringUtils.substringBeforeLast(rootPath, ".") + "['" + name + "']"; } return new PactDslJsonBody(base + ".", "", this); }
/** * Attribute that is a JSON object * @param name field name */ public PactDslJsonBody object(String name) { String base = rootPath + name; if (!name.matches(Parser$.MODULE$.FieldRegex().toString())) { base = StringUtils.substringBeforeLast(rootPath, ".") + "['" + name + "']"; } return new PactDslJsonBody(base + ".", "", this); }
/** * Accepts any key, and each key is mapped to a map that must match the following object definition * Note: this needs the Java system property "pact.matching.wildcard" set to value "true" when the pact file is verified. * @param exampleKey Example key to use for generating bodies */ public PactDslJsonBody eachKeyLike(String exampleKey) { if (FeatureToggles.isFeatureSet(Feature.UseMatchValuesMatcher)) { matchers.addRule(rootPath.endsWith(".") ? rootPath.substring(0, rootPath.length() - 1) : rootPath, ValuesMatcher.INSTANCE); } else { matchers.addRule(rootPath + "*", TypeMatcher.INSTANCE); } return new PactDslJsonBody(rootPath + "*.", exampleKey, this); }
/** * Accepts any key, and each key is mapped to a map that must match the following object definition * Note: this needs the Java system property "pact.matching.wildcard" set to value "true" when the pact file is verified. * @param exampleKey Example key to use for generating bodies */ public PactDslJsonBody eachKeyLike(String exampleKey) { if (FeatureToggles.isFeatureSet(Feature.UseMatchValuesMatcher)) { matchers.addRule(rootPath.endsWith(".") ? rootPath.substring(0, rootPath.length() - 1) : rootPath, ValuesMatcher.INSTANCE); } else { matchers.addRule(rootPath + "*", TypeMatcher.INSTANCE); } return new PactDslJsonBody(rootPath + "*.", exampleKey, this); }
/** * Accepts any key, and each key is mapped to a list of items that must match the following object definition * Note: this needs the Java system property "pact.matching.wildcard" set to value "true" when the pact file is verified. * @param exampleKey Example key to use for generating bodies */ public PactDslJsonBody eachKeyMappedToAnArrayLike(String exampleKey) { if (FeatureToggles.isFeatureSet(Feature.UseMatchValuesMatcher)) { matchers.addRule(rootPath.endsWith(".") ? rootPath.substring(0, rootPath.length() - 1) : rootPath, ValuesMatcher.INSTANCE); } else { matchers.addRule(rootPath + "*", matchMin(0)); } PactDslJsonArray parent = new PactDslJsonArray(rootPath + "*", exampleKey, this, true); return new PactDslJsonBody(".", "", parent); }
/** * Accepts any key, and each key is mapped to a list of items that must match the following object definition * Note: this needs the Java system property "pact.matching.wildcard" set to value "true" when the pact file is verified. * @param exampleKey Example key to use for generating bodies */ public PactDslJsonBody eachKeyMappedToAnArrayLike(String exampleKey) { if (FeatureToggles.isFeatureSet(Feature.UseMatchValuesMatcher)) { matchers.addRule(rootPath.endsWith(".") ? rootPath.substring(0, rootPath.length() - 1) : rootPath, ValuesMatcher.INSTANCE); } else { matchers.addRule(rootPath + "*", matchMin(0)); } PactDslJsonArray parent = new PactDslJsonArray(rootPath + "*", exampleKey, this, true); return new PactDslJsonBody(".", "", parent); }
/** * Attribute that is an array where each item must match the following example * @param name field name * @deprecated use eachLike */ @Override @Deprecated public PactDslJsonBody arrayLike(String name) { matchers.addRule(matcherKey(name), TypeMatcher.INSTANCE); return new PactDslJsonBody(".", ".", new PactDslJsonArray(matcherKey(name), "", this, true)); }
/** * Attribute that is an array where each item must match the following example * @param name field name * @deprecated use eachLike */ @Override @Deprecated public PactDslJsonBody arrayLike(String name) { matchers.addRule(matcherKey(name), TypeMatcher.INSTANCE); return new PactDslJsonBody(".", ".", new PactDslJsonArray(matcherKey(name), "", this, true)); }
/** * 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); }
/** * 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); }
/** * Element that is an array where each item must match the following example * @param numberExamples Number of examples to generate */ @Override public PactDslJsonBody eachLike(int numberExamples) { matchers.addRule(rootPath + appendArrayIndex(1), matchMin(0)); PactDslJsonArray parent = new PactDslJsonArray(rootPath, "", this, true); parent.setNumberExamples(numberExamples); return new PactDslJsonBody(".", "", parent); }
/** * Element that is an array where each item must match the following example * @param numberExamples Number of examples to generate */ @Override public PactDslJsonBody eachLike(int numberExamples) { matchers.addRule(rootPath + appendArrayIndex(1), matchMin(0)); PactDslJsonArray parent = new PactDslJsonArray(rootPath, "", this, true); parent.setNumberExamples(numberExamples); return new PactDslJsonBody(".", "", parent); }
/** * Attribute that is an array where each item must match the following example * @param name field name * @param numberExamples number of examples to generate */ @Override public PactDslJsonBody eachLike(String name, int numberExamples) { matchers.addRule(matcherKey(name), matchMin(0)); PactDslJsonArray parent = new PactDslJsonArray(matcherKey(name), "", this, true); parent.setNumberExamples(numberExamples); return new PactDslJsonBody(".", ".", parent); }
/** * Attribute that is an array where each item must match the following example * @param name field name * @param numberExamples number of examples to generate */ @Override public PactDslJsonBody eachLike(String name, int numberExamples) { matchers.addRule(matcherKey(name), matchMin(0)); PactDslJsonArray parent = new PactDslJsonArray(matcherKey(name), "", this, true); parent.setNumberExamples(numberExamples); return new PactDslJsonBody(".", ".", parent); }
@Override public PactDslJsonBody minMaxArrayLike(String name, Integer minSize, Integer maxSize, int numberExamples) { validateMinAndMaxAndExamples(minSize, maxSize, numberExamples); matchers.addRule(matcherKey(name), matchMinMax(minSize, maxSize)); PactDslJsonArray parent = new PactDslJsonArray(matcherKey(name), "", this, true); parent.setNumberExamples(numberExamples); return new PactDslJsonBody(".", "", parent); }
@Override public PactDslJsonBody minMaxArrayLike(String name, Integer minSize, Integer maxSize, int numberExamples) { validateMinAndMaxAndExamples(minSize, maxSize, numberExamples); matchers.addRule(matcherKey(name), matchMinMax(minSize, maxSize)); PactDslJsonArray parent = new PactDslJsonArray(matcherKey(name), "", this, true); parent.setNumberExamples(numberExamples); return new PactDslJsonBody(".", "", parent); }