0

I have this array structure:

{
Array1 : ["A","B","C"],
Array2: ["D","E","F"] 
}

And I was validated it like this:

array("array1")
 .string("A")
 .string("B")
 .string("C")
.closeArray()
array("array2")
 .string("D")
 .string("E")
 .string("F")
.closeArray()

But my problem is that sometimes the elements inside array aren't returned by provider in the same order, so, my question is: How is the best way to validate it? Considering that it will always return an array of 4 elements but with strings value in inconsistent order. I also tried on this way:

.minArrayLike("array1", 1, PactDslJsonRootValue.stringMatcher("A|B|C", "A"))
.minArrayLike("array2", 1, PactDslJsonRootValue.stringMatcher("D|E|F", "D"))

But pact generate a contract like:

array1 : [A,A,A],
array2: [D,D,D]
Pedro Henrique
  • 609
  • 2
  • 9
  • 26

1 Answers1

0

What about:

PactDslJsonArray.arrayEachLike()
    .stringType("A")
    .closeObject()

See https://github.com/DiUS/pact-jvm/tree/master/pact-jvm-consumer-junit#dsl-matching-methods

Matthew Fellows
  • 3,669
  • 1
  • 15
  • 18