0

I have a list of object responses and want to test that each block of object matches.Hence using tuple.

softAssertions.assertThat(resultArrayList)
                                  .extracting("title", "countryCode")
                                  .as("Title, CountryCode")
                                  .containsAnyOf(
                                          new Tuple(placeToSearch, expectedCountry));

So my query above, I need to check multiple values for field Title like anyOf(placeToSearch, placeToSearch1). Please suggest

Rejish R
  • 43
  • 1
  • 4
  • 0 @Joel Costigliola, above scenario works when you already knew different patterns. But in my case say, I know the "Title" may start with "Frankfurt" and country is "Germany" but title may return as "Frankfurt am Main" so how to put an contains check for the scenario. Actual Title = "Frankfurt am Main" Expected Title in tuple = Startwith "Frankfurt" Expected Country = "Gemany" – Rejish R Feb 11 '19 at 09:58

1 Answers1

0

If I understand correctly what you want, one option is to provide all the possible tuple combinations.

softAssertions.assertThat(resultArrayList)
                              .extracting("title", "countryCode")
                              .as("Title, CountryCode")
                              .containsAnyOf(
                                      tuple(placeToSearchA, expectedCountry),
                                      tuple(placeToSearchB, expectedCountry),
                                      tuple(placeToSearch1, expectedCountry2),
                                      tuple(placeToSearch2, expectedCountry2)
                              );

Note that you static import Assertions.tuple to create Tuple and keep your code nice and readable.

Joel Costigliola
  • 6,308
  • 27
  • 35