i am writing a pact test and I need a variability.
this is my actual method for defining an price object:
private static LambdaDslObject definePrice(LambdaDslObject object) {
return object
.stringType("type") // <--- could be empty or has 2 different values
.stringType("currencyCode", "EUR")
.numberType("centAmount")
.numberType("fractionDigits");
}
but this price object could look like this in JSON:
if type is "centPrecision" or empty:
"value": {
"type": "centPrecision",
"currencyCode": "EUR",
"preciseAmount": 2800,
"fractionDigits": 2 // <--- is not mandatory in this case
}
or
"value": {
"currencyCode": "EUR",
"preciseAmount": 2800,
"fractionDigits": 2 // <--- is not mandatory in this case
}
or if type is "highPrecision"
"value": {
"type": "highPrecision",
"currencyCode": "EUR",
"centAmount": 2800, // <--- is not mandatory in this case
"preciseAmount": 2800,
"fractionDigits": 2
}
so I need a distinction according to type of the price.
I found this or() method but actually don't know how to implement it.
how can I implement this for pact?