I have a specific method that provides an Restriction-object (where Restrictionis the interface). And since its implementation is already testet, I just want to check if my method really provides an object RestrictionImpl.
I saw that there are helpers that I can use with assertThat, and I thought that isA-matcher is what I need for this task.
My simplified code is as follows:
public static Restriction getRestriction() {
return new RestrictionImpl();
}
and my test looks like this:
@Test
public void getRestriction_returnsRestrictionImpl() {
assertThat(getRestriction(), isA(RestrictionImpl.class));
}
However, this does not compile. All I could do was check if it RestrictionImplis Restriction... but that makes no sense.
Do I really not understand the purpose isA? And what does it really mean?
UPDATE:
assertThat(getRestriction(), is(instanceOf(RestrictionImpl.class))) , , isA .
assertThat , , , assertThat(T, Matcher<? extends T>), assertThat(T, Matcher<? super T>)