Repository navigation
Conversation
|
|
||
| You can also apply general functions/lambdas for matches: | ||
| ```java | ||
| assertThat("A string", MapMatcher.map(s -> s.charAt(0), equalTo('A'))) |
There was a problem hiding this comment.
I'm curious if you could describe the intended uses a little bit more or provide some more examples - couldn't this example also be solved with assertThat("A string", startsWith("a"))?
http://hamcrest.org/JavaHamcrest/javadoc/1.3/org/hamcrest/Matchers.html#startsWith(java.lang.String)
Just curious what other uses you have in mind
There was a problem hiding this comment.
The real usecase that made me look for something like this is:
assertThat(protobufObj, map(UserAttributesMutated::getAttributesList, hasItem(map(AttributeMutation::getName, equalTo("country")))))));There was a problem hiding this comment.
I would say that this use-case is already fulfilled by the POJO matcher.
assertThat(protobufObj, is(pojo(UserAttributesMutated.class).where(UserAttributesMutated::getAttributesList, hasItem(...)))
We can probably make it more concise but that should be a PR for the POJO matcher.
Also, MapMatcher to me sounds like something matching on Map objects, and using the word map goes a bit against the declarative wording of hamcrest. I would in any case prefer the wording resultOf or something.
|
closing old PR that has not been reviewed/merged in years. Feel free to re-open if you believe it's still relevant |
No description provided.