/** * 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); }
/** * Accepts any key, and each key is mapped to a map that must match the provided 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 * @param value Value to use for matching and generated bodies */ public PactDslJsonBody eachKeyLike(String exampleKey, PactDslJsonRootValue value) { body.put(exampleKey, value.getBody()); if (FeatureToggles.isFeatureSet(Feature.UseMatchValuesMatcher)) { matchers.addRule(rootPath.endsWith(".") ? rootPath.substring(0, rootPath.length() - 1) : rootPath, ValuesMatcher.INSTANCE); } for(String matcherName: value.matchers.getMatchingRules().keySet()) { matchers.addRules(rootPath + "*" + matcherName, value.matchers.getMatchingRules().get(matcherName).getRules()); } return this; }
/** * Accepts any key, and each key is mapped to a map that must match the provided 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 * @param value Value to use for matching and generated bodies */ public PactDslJsonBody eachKeyLike(String exampleKey, PactDslJsonRootValue value) { body.put(exampleKey, value.getBody()); if (FeatureToggles.isFeatureSet(Feature.UseMatchValuesMatcher)) { matchers.addRule(rootPath.endsWith(".") ? rootPath.substring(0, rootPath.length() - 1) : rootPath, ValuesMatcher.INSTANCE); } for(String matcherName: value.matchers.getMatchingRules().keySet()) { matchers.addRules(rootPath + "*" + matcherName, value.matchers.getMatchingRules().get(matcherName).getRules()); } return this; }