I want to test whether a specific field of an object matches a value I specify. In this case, it\'s the bucket name inside an S3Bucket object. As far as I can tell, I need t
Alternatively, for a more typesafe version, there's the FeatureMatcher. In this case, something like:
private Matcher bucketName(final String expected) {
return new FeatureMatcher(equalTo(expected),
"bucket called", "name") {
String featureValueOf(S3Bucket actual) {
return actual.getName();
}
};
}
giving:
mockery.checking(new Expectations() {{
one(query.s3).getObject(with(bucketName("bucket")), with(equalTo("key")));
...
}});
The purpose of the two string arguments is to make the mismatch report read well.