/** * Value that must be an IP4 address */ public static PactDslRootValue ipAddress() { PactDslRootValue value = new PactDslRootValue(); value.setValue("127.0.0.1"); value.setMatcher(value.regexp("(\\d{1,3}\\.)+\\d{1,3}")); return value; }
/** * Value that must be an IP4 address */ public static PactDslRootValue ipAddress() { PactDslRootValue value = new PactDslRootValue(); value.setValue("127.0.0.1"); value.setMatcher(value.regexp("(\\d{1,3}\\.)+\\d{1,3}")); return value; }
/** * Value that must be encoded as an UUID * @param uuid example UUID to use for generated bodies */ public static PactDslRootValue uuid(String uuid) { if (!uuid.matches(UUID_REGEX)) { throw new InvalidMatcherException(EXAMPLE + uuid + "\" is not an UUID"); } PactDslRootValue value = new PactDslRootValue(); value.setValue(uuid); value.setMatcher(value.regexp(UUID_REGEX)); return value; }
/** * Value that must be encoded as a hexadecimal value * @param hexValue example value to use for generated bodies */ public static PactDslRootValue hexValue(String hexValue) { if (!hexValue.matches(HEXADECIMAL)) { throw new InvalidMatcherException(EXAMPLE + hexValue + "\" is not a hexadecimal value"); } PactDslRootValue value = new PactDslRootValue(); value.setValue(hexValue); value.setMatcher(value.regexp("[0-9a-fA-F]+")); return value; }
/** * Value that must be encoded as an UUID * @param uuid example UUID to use for generated bodies */ public static PactDslRootValue uuid(String uuid) { if (!uuid.matches(UUID_REGEX)) { throw new InvalidMatcherException(EXAMPLE + uuid + "\" is not an UUID"); } PactDslRootValue value = new PactDslRootValue(); value.setValue(uuid); value.setMatcher(value.regexp(UUID_REGEX)); return value; }
/** * Value that must be encoded as a hexadecimal value * @param hexValue example value to use for generated bodies */ public static PactDslRootValue hexValue(String hexValue) { if (!hexValue.matches(HEXADECIMAL)) { throw new InvalidMatcherException(EXAMPLE + hexValue + "\" is not a hexadecimal value"); } PactDslRootValue value = new PactDslRootValue(); value.setValue(hexValue); value.setMatcher(value.regexp("[0-9a-fA-F]+")); return value; }
/** * Value that must match the regular expression * @param regex regular expression * @param value example value to use for generated bodies */ public static PactDslRootValue stringMatcher(String regex, String value) { if (!value.matches(regex)) { throw new InvalidMatcherException(EXAMPLE + value + "\" does not match regular expression \"" + regex + "\""); } PactDslRootValue rootValue = new PactDslRootValue(); rootValue.setValue(value); rootValue.setMatcher(rootValue.regexp(regex)); return rootValue; }
/** * Value that must match the regular expression * @param regex regular expression * @param value example value to use for generated bodies */ public static PactDslRootValue stringMatcher(String regex, String value) { if (!value.matches(regex)) { throw new InvalidMatcherException(EXAMPLE + value + "\" does not match regular expression \"" + regex + "\""); } PactDslRootValue rootValue = new PactDslRootValue(); rootValue.setValue(value); rootValue.setMatcher(rootValue.regexp(regex)); return rootValue; }
/** * Value that must be encoded as an UUID */ public static PactDslRootValue uuid() { PactDslRootValue value = new PactDslRootValue(); value.generators.addGenerator(Category.BODY, "", UuidGenerator.INSTANCE); value.setValue("e2490de5-5bd3-43d5-b7c4-526e33f71304"); value.setMatcher(value.regexp(UUID_REGEX)); return value; }
/** * Value that must be encoded as an UUID */ public static PactDslRootValue uuid() { PactDslRootValue value = new PactDslRootValue(); value.generators.addGenerator(Category.BODY, "", UuidGenerator.INSTANCE); value.setValue("e2490de5-5bd3-43d5-b7c4-526e33f71304"); value.setMatcher(value.regexp(UUID_REGEX)); return value; }
/** * Value that must be encoded as a hexadecimal value */ public static PactDslRootValue hexValue() { PactDslRootValue value = new PactDslRootValue(); value.generators.addGenerator(Category.BODY, "", new RandomHexadecimalGenerator(10)); value.setValue("1234a"); value.setMatcher(value.regexp("[0-9a-fA-F]+")); return value; }
/** * Value that must be encoded as a hexadecimal value */ public static PactDslRootValue hexValue() { PactDslRootValue value = new PactDslRootValue(); value.generators.addGenerator(Category.BODY, "", new RandomHexadecimalGenerator(10)); value.setValue("1234a"); value.setMatcher(value.regexp("[0-9a-fA-F]+")); return value; }
/** * Value that must match the regular expression * @param regex regular expression * @deprecated Use the version that takes an example value */ @Deprecated public static PactDslRootValue stringMatcher(String regex) { PactDslRootValue rootValue = new PactDslRootValue(); rootValue.generators.addGenerator(Category.BODY, "", new RegexGenerator(regex)); rootValue.setValue(new Generex(regex).random()); rootValue.setMatcher(rootValue.regexp(regex)); return rootValue; }
/** * Value that must match the regular expression * @param regex regular expression * @deprecated Use the version that takes an example value */ @Deprecated public static PactDslRootValue stringMatcher(String regex) { PactDslRootValue rootValue = new PactDslRootValue(); rootValue.generators.addGenerator(Category.BODY, "", new RegexGenerator(regex)); rootValue.setValue(new Generex(regex).random()); rootValue.setMatcher(rootValue.regexp(regex)); return rootValue; }