isIn() deprecation: replacement syntax is(in()) conflicts with Groovy membership operator

132 views
Skip to first unread message

Trey Turner

unread,
Oct 9, 2019, 11:52:42 AM10/9/19
to Hamcrest Java Users
Hi there,
I'm new to Hamcrest matchers, having discovered them via the Rest Assured library which I happen to be implementing in a Groovy context.

I'm trying to achieve this (which works, but is pretty verbose):

everyItem(anyOf(equalTo('Y'), equalTo('N')))

I've tried this, which seems to work, but I'm warned is deprecated:

everyItem(isIn(['Y', 'N']))

To switch to the non-deprecated version, I tried:

everyItem(is(in(['Y', 'N']))

However this conflicts with Groovy's membership operator as it employs the word 'in': http://docs.groovy-lang.org/latest/html/documentation/#_membership_operator

Is there a way to make use of is(in()) in a Groovy context, or am I limited to my first example due to this apparent conflict and the forthcoming deprecation?

Thanks,
Trey
Reply all
Reply to author
Forward
0 new messages