Pact C++ Consumer DSL  0.0.7
DSL to support writing consumer tests in C++
Classes | Functions
pact_consumer::matchers Namespace Reference

Classes

class  IMatcher
 
class  ObjectMatcher
 
class  IntegerMatcher
 
class  DecimalMatcher
 
class  TypeMatcher
 
class  NumberMatcher
 
class  EqualsMatcher
 
class  DateTimeMatcher
 
class  DateMatcher
 
class  TimeMatcher
 
class  RegexMatcher
 
class  EachlikeMatcher
 
class  ArrayContainsMatcher
 
class  HexadecimalMatcher
 
class  IPAddressMatcher
 
class  UuidMatcher
 
class  IncludesMatcher
 
class  NullMatcher
 
class  UrlMatcher
 

Functions

IMatcher::Ptr Object (const std::unordered_map< std::string, IMatcher::Ptr > &fields)
 
IMatcher::Ptr Integer (long value)
 
IMatcher::Ptr Integer (int value)
 
IMatcher::Ptr Integer ()
 
IMatcher::Ptr Like (long value)
 
IMatcher::Ptr Like (int value)
 
IMatcher::Ptr Like (double value)
 
IMatcher::Ptr Like (const std::string &value)
 
IMatcher::Ptr Like (const char *value)
 
IMatcher::Ptr Like (bool value)
 
IMatcher::Ptr DateTime (const std::string &format, const std::string &example)
 
IMatcher::Ptr DateTime (const std::string &format)
 
IMatcher::Ptr Date (const std::string &format, const std::string &example)
 
IMatcher::Ptr Date (const std::string &format)
 
IMatcher::Ptr Time (const std::string &format, const std::string &example)
 
IMatcher::Ptr Time (const std::string &format)
 
IMatcher::Ptr Matching (const std::string &regex, const std::string &example)
 
IMatcher::Ptr Matching (const std::string &regex)
 
IMatcher::Ptr EachLike (const IMatcher::Ptr obj)
 
IMatcher::Ptr EachLike (int examples, const IMatcher::Ptr obj)
 
IMatcher::Ptr AtLeastOneLike (const IMatcher::Ptr obj)
 
IMatcher::Ptr AtLeastOneLike (int examples, const IMatcher::Ptr obj)
 
IMatcher::Ptr HexValue (const std::string &example)
 
IMatcher::Ptr HexValue ()
 
IMatcher::Ptr IPAddress (const std::string &example)
 
IMatcher::Ptr IPAddress ()
 
IMatcher::Ptr Numeric (int example)
 
IMatcher::Ptr Numeric (long example)
 
IMatcher::Ptr Numeric (float example)
 
IMatcher::Ptr Numeric (double example)
 
IMatcher::Ptr Numeric ()
 
IMatcher::Ptr Decimal (float example)
 
IMatcher::Ptr Decimal (double example)
 
IMatcher::Ptr Decimal ()
 
IMatcher::Ptr Uuid (const std::string &example)
 
IMatcher::Ptr Uuid ()
 
IMatcher::Ptr AtMostLike (int max, const IMatcher::Ptr obj)
 
IMatcher::Ptr AtMostLike (int max, int examples, const IMatcher::Ptr obj)
 
IMatcher::Ptr MinArrayLike (int min, const IMatcher::Ptr obj)
 
IMatcher::Ptr MinArrayLike (int min, int examples, const IMatcher::Ptr obj)
 
IMatcher::Ptr ConstrainedArrayLike (int min, int max, const IMatcher::Ptr obj)
 
IMatcher::Ptr ConstrainedArrayLike (int min, int max, int examples, const IMatcher::Ptr obj)
 
IMatcher::Ptr EqualTo (int value)
 
IMatcher::Ptr EqualTo (long value)
 
IMatcher::Ptr EqualTo (float value)
 
IMatcher::Ptr EqualTo (double value)
 
IMatcher::Ptr EqualTo (const std::string &value)
 
IMatcher::Ptr EqualTo (const char *value)
 
IMatcher::Ptr EqualTo (bool value)
 
IMatcher::Ptr IncludesStr (const std::string &value)
 
IMatcher::Ptr NullValue ()
 
IMatcher::Ptr Url (const std::string &basePath, const std::vector< IMatcher::Ptr > &pathFragments)
 
IMatcher::Ptr Url (const std::vector< IMatcher::Ptr > &pathFragments)
 
IMatcher::Ptr ArrayContaining (const std::vector< IMatcher::Ptr > &variants)
 

Function Documentation

◆ ArrayContaining()

IMatcher::Ptr pact_consumer::matchers::ArrayContaining ( const std::vector< IMatcher::Ptr > &  variants)

Matches the items in an array against a number of variants. Matching is successful if each variant occurs once in the array. Variants may be objects containing matching rules.

Parameters
minThe minimum size of the array
maxThe maximum size of the array
examplesnumber of examples to generate.

◆ AtLeastOneLike() [1/2]

IMatcher::Ptr pact_consumer::matchers::AtLeastOneLike ( const IMatcher::Ptr  obj)

Array of values that must have at least one value and each item in the array must match the provided template.

◆ AtLeastOneLike() [2/2]

IMatcher::Ptr pact_consumer::matchers::AtLeastOneLike ( int  examples,
const IMatcher::Ptr  obj 
)

Array of values that must have at least one value and each item in the array must match the provided template.

Parameters
examplesThe number of example values to generate

◆ AtMostLike() [1/2]

IMatcher::Ptr pact_consumer::matchers::AtMostLike ( int  max,
const IMatcher::Ptr  obj 
)

Array with maximum size and each element like the template object.

Parameters
maxThe maximum size of the array

◆ AtMostLike() [2/2]

IMatcher::Ptr pact_consumer::matchers::AtMostLike ( int  max,
int  examples,
const IMatcher::Ptr  obj 
)

Array with maximum size and each element like the template object.

Parameters
maxThe maximum size of the array
examplesNumber of examples to generate.

◆ ConstrainedArrayLike() [1/2]

IMatcher::Ptr pact_consumer::matchers::ConstrainedArrayLike ( int  min,
int  max,
const IMatcher::Ptr  obj 
)

Array with minimum and maximum size and each element like the template object.

Parameters
minThe minimum size of the array
maxThe maximum size of the array

◆ ConstrainedArrayLike() [2/2]

IMatcher::Ptr pact_consumer::matchers::ConstrainedArrayLike ( int  min,
int  max,
int  examples,
const IMatcher::Ptr  obj 
)

Array with minimum and maximum size and each element like the template object.

Parameters
minThe minimum size of the array
maxThe maximum size of the array
examplesnumber of examples to generate.

◆ Date() [1/2]

IMatcher::Ptr pact_consumer::matchers::Date ( const std::string &  format)

String value that must match the provided date format string. Example values will be generated using the current system date and time.

Parameters
formatDatetime format string. See Java SimpleDateFormat

◆ Date() [2/2]

IMatcher::Ptr pact_consumer::matchers::Date ( const std::string &  format,
const std::string &  example 
)

String value that must match the provided date format string.

Parameters
formatDatetime format string. See Java SimpleDateFormat
exampleExample value to use

◆ DateTime() [1/2]

IMatcher::Ptr pact_consumer::matchers::DateTime ( const std::string &  format)

String value that must match the provided datetime format string. Example values will be generated using the current system date and time.

Parameters
formatDatetime format string. See Java SimpleDateFormat

◆ DateTime() [2/2]

IMatcher::Ptr pact_consumer::matchers::DateTime ( const std::string &  format,
const std::string &  example 
)

String value that must match the provided datetime format string.

Parameters
formatDatetime format string. See Java SimpleDateFormat
exampleExample value to use

◆ Decimal() [1/3]

IMatcher::Ptr pact_consumer::matchers::Decimal ( )

Match a decimal value (number with atleast one digit after the decimal point). Random values will be generated for examples.

◆ Decimal() [2/3]

IMatcher::Ptr pact_consumer::matchers::Decimal ( double  example)

Match a decimal value (number with atleast one digit after the decimal point)

Parameters
exampleExample value

◆ Decimal() [3/3]

IMatcher::Ptr pact_consumer::matchers::Decimal ( float  example)

Match a decimal value (number with atleast one digit after the decimal point)

Parameters
exampleExample value

◆ EachLike() [1/2]

IMatcher::Ptr pact_consumer::matchers::EachLike ( const IMatcher::Ptr  obj)

Array of values where each item in the array must match the provided template.

◆ EachLike() [2/2]

IMatcher::Ptr pact_consumer::matchers::EachLike ( int  examples,
const IMatcher::Ptr  obj 
)

Array of values where each item in the array must match the provided template.

Parameters
examplesThe number of example values to generate

◆ EqualTo() [1/7]

IMatcher::Ptr pact_consumer::matchers::EqualTo ( bool  value)

Match by equality. This is mainly used to reset the cascading type matchers.

Parameters
valueValue to match to

◆ EqualTo() [2/7]

IMatcher::Ptr pact_consumer::matchers::EqualTo ( const char *  value)

Match by equality. This is mainly used to reset the cascading type matchers.

Parameters
valueValue to match to

◆ EqualTo() [3/7]

IMatcher::Ptr pact_consumer::matchers::EqualTo ( const std::string &  value)

Match by equality. This is mainly used to reset the cascading type matchers.

Parameters
valueValue to match to

◆ EqualTo() [4/7]

IMatcher::Ptr pact_consumer::matchers::EqualTo ( double  value)

Match by equality. This is mainly used to reset the cascading type matchers.

Parameters
valueValue to match to

◆ EqualTo() [5/7]

IMatcher::Ptr pact_consumer::matchers::EqualTo ( float  value)

Match by equality. This is mainly used to reset the cascading type matchers.

Parameters
valueValue to match to

◆ EqualTo() [6/7]

IMatcher::Ptr pact_consumer::matchers::EqualTo ( int  value)

Match by equality. This is mainly used to reset the cascading type matchers.

Parameters
valueValue to match to

◆ EqualTo() [7/7]

IMatcher::Ptr pact_consumer::matchers::EqualTo ( long  value)

Match by equality. This is mainly used to reset the cascading type matchers.

Parameters
valueValue to match to

◆ HexValue() [1/2]

IMatcher::Ptr pact_consumer::matchers::HexValue ( )

Match a hexadecimal value. Random examples will be generated.

◆ HexValue() [2/2]

IMatcher::Ptr pact_consumer::matchers::HexValue ( const std::string &  example)

Match a hexadecimal value

Parameters
exampleExample value

◆ IncludesStr()

IMatcher::Ptr pact_consumer::matchers::IncludesStr ( const std::string &  value)

Matches if the string value contains the given value

Parameters
valueString value that must be present

◆ Integer() [1/3]

IMatcher::Ptr pact_consumer::matchers::Integer ( )

Matchers an integer value (must be a number and have no decimal places). A random example value will be generated.

◆ Integer() [2/3]

IMatcher::Ptr pact_consumer::matchers::Integer ( int  value)

Matchers an integer value (must be a number and have no decimal places).

◆ Integer() [3/3]

IMatcher::Ptr pact_consumer::matchers::Integer ( long  value)

Matchers an integer value (must be a number and have no decimal places).

◆ IPAddress() [1/2]

IMatcher::Ptr pact_consumer::matchers::IPAddress ( )

Match an IP Address. Will use 127.0.0.1 for examples.

◆ IPAddress() [2/2]

IMatcher::Ptr pact_consumer::matchers::IPAddress ( const std::string &  example)

Match an IP Address

Parameters
exampleExample value

◆ Like() [1/6]

IMatcher::Ptr pact_consumer::matchers::Like ( bool  value)

Matchers value based on the value type

◆ Like() [2/6]

IMatcher::Ptr pact_consumer::matchers::Like ( const char *  value)

Matchers value based on the value type

◆ Like() [3/6]

IMatcher::Ptr pact_consumer::matchers::Like ( const std::string &  value)

Matchers value based on the value type

◆ Like() [4/6]

IMatcher::Ptr pact_consumer::matchers::Like ( double  value)

Matchers value based on the value type

◆ Like() [5/6]

IMatcher::Ptr pact_consumer::matchers::Like ( int  value)

Matchers value based on the value type

◆ Like() [6/6]

IMatcher::Ptr pact_consumer::matchers::Like ( long  value)

Matchers value based on the value type

◆ Matching() [1/2]

IMatcher::Ptr pact_consumer::matchers::Matching ( const std::string &  regex)

String value that must match the regular expression. Random values will be generated for the examples.

◆ Matching() [2/2]

IMatcher::Ptr pact_consumer::matchers::Matching ( const std::string &  regex,
const std::string &  example 
)

String value that must match the regular expression

◆ MinArrayLike() [1/2]

IMatcher::Ptr pact_consumer::matchers::MinArrayLike ( int  min,
const IMatcher::Ptr  obj 
)

Array with minimum size and each element like the template object.

Parameters
minThe minimum size of the array

◆ MinArrayLike() [2/2]

IMatcher::Ptr pact_consumer::matchers::MinArrayLike ( int  min,
int  examples,
const IMatcher::Ptr  obj 
)

Array with minimum size and each element like the template object.

Parameters
minThe minimum size of the array
examplesNumber of examples to generate.

◆ NullValue()

IMatcher::Ptr pact_consumer::matchers::NullValue ( )

Matches a JSON null value

◆ Numeric() [1/5]

IMatcher::Ptr pact_consumer::matchers::Numeric ( )

Match a numeric value. Random decimal values will be generated for examples.

◆ Numeric() [2/5]

IMatcher::Ptr pact_consumer::matchers::Numeric ( double  example)

Match a numeric value. This will match any numeric type (integer or floating point).

Parameters
valueExample value

◆ Numeric() [3/5]

IMatcher::Ptr pact_consumer::matchers::Numeric ( float  example)

Match a numeric value. This will match any numeric type (integer or floating point).

Parameters
valueExample value

◆ Numeric() [4/5]

IMatcher::Ptr pact_consumer::matchers::Numeric ( int  example)

Match a numeric value. This will match any numeric type (integer or floating point).

Parameters
valueExample value

◆ Numeric() [5/5]

IMatcher::Ptr pact_consumer::matchers::Numeric ( long  example)

Match a numeric value. This will match any numeric type (integer or floating point).

Parameters
valueExample value

◆ Object()

IMatcher::Ptr pact_consumer::matchers::Object ( const std::unordered_map< std::string, IMatcher::Ptr > &  fields)

Represents a JSON object (map of string fields)

◆ Time() [1/2]

IMatcher::Ptr pact_consumer::matchers::Time ( const std::string &  format)

String value that must match the provided time format string. Example values will be generated using the current system date and time.

Parameters
formatDatetime format string. See Java SimpleDateFormat

◆ Time() [2/2]

IMatcher::Ptr pact_consumer::matchers::Time ( const std::string &  format,
const std::string &  example 
)

String value that must match the provided time format string.

Parameters
formatDatetime format string. See Java SimpleDateFormat
exampleExample value to use

◆ Url() [1/2]

IMatcher::Ptr pact_consumer::matchers::Url ( const std::string &  basePath,
const std::vector< IMatcher::Ptr > &  pathFragments 
)

Matches a URL composed of a base path and a list of path fragments

Parameters
basePathBase path of the URL
pathFragmentslist of path fragments, can be regular expressions. Only the Equals and Matching matchers will work.

◆ Url() [2/2]

IMatcher::Ptr pact_consumer::matchers::Url ( const std::vector< IMatcher::Ptr > &  pathFragments)

Matches a URL composed of a base path and a list of path fragments. The base URL from the mock server will be used.

Parameters
pathFragmentslist of path fragments, can be regular expressions. Only the Equals and Matching matchers will work.

◆ Uuid() [1/2]

IMatcher::Ptr pact_consumer::matchers::Uuid ( )

Match a universally unique identifier (UUID). Random values will be used for examples.

◆ Uuid() [2/2]

IMatcher::Ptr pact_consumer::matchers::Uuid ( const std::string &  example)

Match a universally unique identifier (UUID)

Parameters
examplevalue to use for examples