/** * Value that can be any string * * @param example example value to use for generated bodies */ public static PactDslJsonRootValue stringType(String example) { PactDslJsonRootValue value = new PactDslJsonRootValue(); value.setValue(example); value.setMatcher(TypeMatcher.INSTANCE); return value; }
/** * Value that can be any number * @param number example number to use for generated bodies */ public static PactDslJsonRootValue numberType(Number number) { PactDslJsonRootValue value = new PactDslJsonRootValue(); value.setValue(number); value.setMatcher(TypeMatcher.INSTANCE); return value; }
/** * Value that must be an integer * @param number example integer value to use for generated bodies */ public static PactDslJsonRootValue integerType(Long number) { PactDslJsonRootValue value = new PactDslJsonRootValue(); value.setValue(number); value.setMatcher(new NumberTypeMatcher(NumberTypeMatcher.NumberType.INTEGER)); return value; }
/** * Value that must be a decimalType value * @param number example decimalType value */ public static PactDslJsonRootValue decimalType(BigDecimal number) { PactDslJsonRootValue value = new PactDslJsonRootValue(); value.setValue(number); value.setMatcher(new NumberTypeMatcher(NumberTypeMatcher.NumberType.DECIMAL)); return value; }
/** * Value that must be encoded as an UUID * @param uuid example UUID to use for generated bodies */ public static PactDslJsonRootValue uuid(String uuid) { if (!uuid.matches(UUID_REGEX)) { throw new InvalidMatcherException(EXAMPLE + uuid + "\" is not an UUID"); } PactDslJsonRootValue value = new PactDslJsonRootValue(); value.setValue(uuid); value.setMatcher(value.regexp(UUID_REGEX)); return value; }
/** * Value that must be a decimalType value * @param number example decimalType value */ public static PactDslJsonRootValue decimalType(BigDecimal number) { PactDslJsonRootValue value = new PactDslJsonRootValue(); value.setValue(number); value.setMatcher(new NumberTypeMatcher(NumberTypeMatcher.NumberType.DECIMAL)); return value; }
/** * Value that must be a decimalType value * @param number example decimalType value */ public static PactDslJsonRootValue decimalType(Double number) { PactDslJsonRootValue value = new PactDslJsonRootValue(); value.setValue(number); value.setMatcher(new NumberTypeMatcher(NumberTypeMatcher.NumberType.DECIMAL)); return value; }
/** * Value that must be an integer * @param number example integer value to use for generated bodies */ public static PactDslJsonRootValue integerType(Integer number) { PactDslJsonRootValue value = new PactDslJsonRootValue(); value.setValue(number); value.setMatcher(new NumberTypeMatcher(NumberTypeMatcher.NumberType.INTEGER)); return value; }
/** * Value that must be an integer * @param number example integer value to use for generated bodies */ public static PactDslJsonRootValue integerType(Integer number) { PactDslJsonRootValue value = new PactDslJsonRootValue(); value.setValue(number); value.setMatcher(new NumberTypeMatcher(NumberTypeMatcher.NumberType.INTEGER)); return value; }
/** * Value that can be any string */ public static PactDslJsonRootValue stringType() { PactDslJsonRootValue value = new PactDslJsonRootValue(); value.generators.addGenerator(Category.BODY, "", new RandomStringGenerator(20)); value.setValue("string"); value.setMatcher(TypeMatcher.INSTANCE); return value; }
/** * Value that can be any string */ public static PactDslJsonRootValue stringType() { PactDslJsonRootValue value = new PactDslJsonRootValue(); value.generators.addGenerator(Category.BODY, "", new RandomStringGenerator(20)); value.setValue("string"); value.setMatcher(TypeMatcher.INSTANCE); return value; }
/** * Value that can be any number */ public static PactDslJsonRootValue numberType() { PactDslJsonRootValue value = new PactDslJsonRootValue(); value.generators.addGenerator(Category.BODY, "", new RandomIntGenerator(0, Integer.MAX_VALUE)); value.setValue(100); value.setMatcher(TypeMatcher.INSTANCE); 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 PactDslJsonRootValue stringMatcher(String regex) { PactDslJsonRootValue rootValue = new PactDslJsonRootValue(); rootValue.generators.addGenerator(Category.BODY, "", new RegexGenerator(regex)); rootValue.setValue(new Generex(regex).random()); rootValue.setMatcher(rootValue.regexp(regex)); return rootValue; }
/** * Value that must be a decimal value */ public static PactDslJsonRootValue decimalType() { PactDslJsonRootValue value = new PactDslJsonRootValue(); value.generators.addGenerator(Category.BODY, "", new RandomDecimalGenerator(10)); value.setValue(100); value.setMatcher(new NumberTypeMatcher(NumberTypeMatcher.NumberType.DECIMAL)); return value; }
/** * Value that must match the given time format * @param format time format to match * @param example example time to use for generated bodies */ public static PactDslJsonRootValue time(String format, Date example) { FastDateFormat instance = FastDateFormat.getInstance(format); PactDslJsonRootValue value = new PactDslJsonRootValue(); value.setValue(instance.format(example)); value.setMatcher(value.matchTime(format)); return value; }
/** * Value that must match the given timestamp format * @param format timestamp format */ public static PactDslJsonRootValue timestamp(String format) { PactDslJsonRootValue value = new PactDslJsonRootValue(); value.generators.addGenerator(Category.BODY, "", new DateTimeGenerator(format)); FastDateFormat instance = FastDateFormat.getInstance(format); value.setValue(instance.format(new Date(DATE_2000))); value.setMatcher(value.matchTimestamp(format)); return value; }
/** * Value that must match the given time format * @param format time format to match */ public static PactDslJsonRootValue time(String format) { FastDateFormat instance = FastDateFormat.getInstance(format); PactDslJsonRootValue value = new PactDslJsonRootValue(); value.generators.addGenerator(Category.BODY, "", new TimeGenerator(format)); value.setValue(instance.format(new Date(DATE_2000))); value.setMatcher(value.matchTime(format)); return value; }
/** * Value that must match the given timestamp format * @param format timestamp format */ public static PactDslJsonRootValue timestamp(String format) { PactDslJsonRootValue value = new PactDslJsonRootValue(); value.generators.addGenerator(Category.BODY, "", new DateTimeGenerator(format)); FastDateFormat instance = FastDateFormat.getInstance(format); value.setValue(instance.format(new Date(DATE_2000))); value.setMatcher(value.matchTimestamp(format)); return value; }
/** * Value that must match the provided date format * @param format date format to match * @param example example date to use for generated values */ public static PactDslJsonRootValue date(String format, Date example) { FastDateFormat instance = FastDateFormat.getInstance(format); PactDslJsonRootValue value = new PactDslJsonRootValue(); value.setValue(instance.format(example)); value.setMatcher(value.matchDate(format)); return value; }
/** * Value that must match the given time format * @param format time format to match */ public static PactDslJsonRootValue time(String format) { FastDateFormat instance = FastDateFormat.getInstance(format); PactDslJsonRootValue value = new PactDslJsonRootValue(); value.generators.addGenerator(Category.BODY, "", new TimeGenerator(format)); value.setValue(instance.format(new Date(DATE_2000))); value.setMatcher(value.matchTime(format)); return value; }