/** * Value that can be any string * * @param example example value to use for generated bodies */ public static PactDslRootValue stringType(String example) { PactDslRootValue value = new PactDslRootValue(); value.setValue(example); value.setMatcher(TypeMatcher.INSTANCE); return value; }
/** * Value that can be any string * * @param example example value to use for generated bodies */ public static PactDslRootValue stringType(String example) { PactDslRootValue value = new PactDslRootValue(); value.setValue(example); value.setMatcher(TypeMatcher.INSTANCE); 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 a decimalType value * @param number example decimalType value */ public static PactDslRootValue decimalType(Double number) { PactDslRootValue value = new PactDslRootValue(); value.setValue(number); value.setMatcher(new NumberTypeMatcher(NumberTypeMatcher.NumberType.DECIMAL)); return value; }
/** * Adds a value that will have it's value injected from the provider state * @param expression Expression to be evaluated from the provider state * @param example Example value to be used in the consumer test */ public static PactDslRootValue valueFromProviderState(String expression, Object example) { PactDslRootValue value = new PactDslRootValue(); value.generators.addGenerator(Category.BODY, "", new ProviderStateGenerator(expression)); value.setValue(example); 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 an integer * @param number example integer value to use for generated bodies */ public static PactDslRootValue integerType(Long number) { PactDslRootValue value = new PactDslRootValue(); 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 PactDslRootValue integerType(Integer number) { PactDslRootValue value = new PactDslRootValue(); value.setValue(number); value.setMatcher(new NumberTypeMatcher(NumberTypeMatcher.NumberType.INTEGER)); 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 can be any string */ public static PactDslRootValue stringType() { PactDslRootValue value = new PactDslRootValue(); value.generators.addGenerator(Category.BODY, "", new RandomStringGenerator(20)); value.setValue("string"); value.setMatcher(TypeMatcher.INSTANCE); 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 match the given timestamp format * @param format timestamp format */ public static PactDslRootValue timestamp(String format) { PactDslRootValue value = new PactDslRootValue(); 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 be a decimal value */ public static PactDslRootValue decimalType() { PactDslRootValue value = new PactDslRootValue(); 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 provided date format * @param format date format to match * @param example example date to use for generated values */ public static PactDslRootValue date(String format, Date example) { FastDateFormat instance = FastDateFormat.getInstance(format); PactDslRootValue value = new PactDslRootValue(); value.setValue(instance.format(example)); value.setMatcher(value.matchDate(format)); return value; }
/** * Value that must be an integer */ public static PactDslRootValue integerType() { PactDslRootValue value = new PactDslRootValue(); value.generators.addGenerator(Category.BODY, "", new RandomIntGenerator(0, Integer.MAX_VALUE)); value.setValue(100); value.setMatcher(new NumberTypeMatcher(NumberTypeMatcher.NumberType.INTEGER)); 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 a decimal value */ public static PactDslRootValue decimalType() { PactDslRootValue value = new PactDslRootValue(); value.generators.addGenerator(Category.BODY, "", new RandomDecimalGenerator(10)); value.setValue(100); value.setMatcher(new NumberTypeMatcher(NumberTypeMatcher.NumberType.DECIMAL)); 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 given timestamp format * @param format timestamp format */ public static PactDslRootValue timestamp(String format) { PactDslRootValue value = new PactDslRootValue(); 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 timestamp format * @param format timestamp format * @param example example date and time to use for generated bodies */ public static PactDslRootValue timestamp(String format, Date example) { FastDateFormat instance = FastDateFormat.getInstance(format); PactDslRootValue value = new PactDslRootValue(); value.setValue(instance.format(example)); value.setMatcher(value.matchTimestamp(format)); return value; }