Hi I am writing a custom matcher to validate two different object, and my code is:
public class DetailsMatcher extends ArgumentMatcher <Details> {
private final Details expected;
private DetailsMatcher(Details expected) {
this.expected = expected;
}
@Override
public boolean matches(Object actual) {
return ((Request) actual).getId().equals(expected.getId());
}
@Override
public void describeTo(Description description) {
description.appendText(expected == null ? null : expected.toString());
}
public static Details valueObjectEq(Details expected) {
return argThat(new DetailsMatcher(expected));
}
}
And I want to use it in my test as:
assertThat(requestModel, DetailsMatcher.valueObjectEq(response));
But these are two different object so that it doesn't work. I don't want to change my objects just for testing purpose, so do we have some api like assertThat, which allows passing different object to simply relies on the output of matches, rather than forcing the actual and expected of same type?