In hamcrest (1.3.RC2, without JUnit dependencies) I do not use iterableWithSize().
I have a (extension) a Iterator
parameterized with Content
, like this EndResult<Content> contents = contentRepository.findAllByPropertyValue("title", "*content*");
where EndResult
package org.springframework.data.neo4j.conversion;
public interface EndResult<R> extends Iterable<R> {...}
and Content
is my Pojo.
Now I would think that this would work assertThat(contents, iterableWithSize(1));
but this gives me an error: <B> The assertThat (T, Matcher) method in the Assert type is not applicable for arguments (EndResult <Content>, Matcher <Iterable <Object →)
I also tried these glitches:
assertThat(contents, iterableWithSize(equalTo(1));
assertThat(contents, IsIterableWithSize.<EndResult<Content>>.iterableWithSize(1));
This is my import:
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.collection.IsCollectionWithSize.hasSize;
import static org.hamcrest.collection.IsIterableWithSize.iterableWithSize;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
import org.hamcrest.collection.IsIterableWithSize;
hasSize for collections works as expected, but for iterators I can't even find a working example ...
source share