/** * Creates a matcher for {@link Iterable}s that matches when a single pass over the * examined {@link Iterable} yields an item count that is equal to the specified * <code>size</code> argument. * <p/> * For example: * <pre>assertThat(Arrays.asList("foo", "bar"), iterableWithSize(2))</pre> * * @param size * the number of items that should be yielded by an examined {@link Iterable} */ public static <E> org.hamcrest.Matcher<java.lang.Iterable<E>> iterableWithSize(int size) { return org.hamcrest.collection.IsIterableWithSize.<E>iterableWithSize(size); }
/** * Creates a matcher for {@link Iterable}s that matches when a single pass over the * examined {@link Iterable} yields an item count that satisfies the specified * matcher. * <p/> * For example: * <pre>assertThat(Arrays.asList("foo", "bar"), iterableWithSize(equalTo(2)))</pre> * * @param sizeMatcher * a matcher for the number of items that should be yielded by an examined {@link Iterable} */ public static <E> org.hamcrest.Matcher<java.lang.Iterable<E>> iterableWithSize(org.hamcrest.Matcher<? super java.lang.Integer> sizeMatcher) { return org.hamcrest.collection.IsIterableWithSize.<E>iterableWithSize(sizeMatcher); }
/** * Creates a matcher for {@link Iterable}s that matches when a single pass over the * examined {@link Iterable} yields an item count that is equal to the specified * <code>size</code> argument. * For example: * <pre>assertThat(Arrays.asList("foo", "bar"), iterableWithSize(2))</pre> * * @param size * the number of items that should be yielded by an examined {@link Iterable} */ public static <E> org.hamcrest.Matcher<java.lang.Iterable<E>> iterableWithSize(int size) { return org.hamcrest.collection.IsIterableWithSize.iterableWithSize(size); }
/** * Creates a matcher for {@link Iterable}s that matches when a single pass over the * examined {@link Iterable} yields an item count that satisfies the specified * matcher. * For example: * <pre>assertThat(Arrays.asList("foo", "bar"), iterableWithSize(equalTo(2)))</pre> * * @param sizeMatcher * a matcher for the number of items that should be yielded by an examined {@link Iterable} */ public static <E> org.hamcrest.Matcher<java.lang.Iterable<E>> iterableWithSize(org.hamcrest.Matcher<? super java.lang.Integer> sizeMatcher) { return org.hamcrest.collection.IsIterableWithSize.iterableWithSize(sizeMatcher); }
/** * Creates a matcher for {@link Iterable}s that matches when a single pass over the * examined {@link Iterable} yields an item count that is equal to the specified * <code>size</code> argument. * <p/> * For example: * <pre>assertThat(Arrays.asList("foo", "bar"), iterableWithSize(2))</pre> * * @param size * the number of items that should be yielded by an examined {@link Iterable} */ @Factory public static <E> Matcher<Iterable<E>> iterableWithSize(int size) { return iterableWithSize(equalTo(size)); } }
/** * Creates a matcher for {@link Iterable}s that matches when a single pass over the * examined {@link Iterable} yields an item count that is equal to the specified * <code>size</code> argument. * For example: * <pre>assertThat(Arrays.asList("foo", "bar"), iterableWithSize(2))</pre> * * @param size * the number of items that should be yielded by an examined {@link Iterable} */ public static <E> Matcher<Iterable<E>> iterableWithSize(int size) { return iterableWithSize(equalTo(size)); } }
@Override protected Matcher<?> createMatcher() { return iterableWithSize(7); }
public void testMatchesEmptyIterable() throws Exception { assertMatches("Empty iterable", iterableWithSize(0), Collections.emptyList()); }
public void testHasAReadableDescription() { assertDescription("an iterable with size <4>", iterableWithSize(4)); } }
public void testMatchingSingleItemIterable() throws Exception { assertMatches("Single item iterable", iterableWithSize(1), Arrays.<Object>asList(1)); }
public void testMatchingMultipleItemIterable() throws Exception { assertMatches("Multiple item iterable", iterableWithSize(3), Arrays.<Object>asList(1, 2, 3)); }
public void testDoesNotMatchIncorrectSize() throws Exception { assertDoesNotMatch("Incorrect size", iterableWithSize(3), Arrays.<Object>asList(1)); }
/** * Creates a matcher for {@link Iterable}s that matches when a single pass over the * examined {@link Iterable} yields an item count that satisfies the specified * matcher. * For example: * <pre>assertThat(Arrays.asList("foo", "bar"), iterableWithSize(equalTo(2)))</pre> * * @param sizeMatcher * a matcher for the number of items that should be yielded by an examined {@link Iterable} */ public static <E> org.hamcrest.Matcher<java.lang.Iterable<E>> iterableWithSize(org.hamcrest.Matcher<? super java.lang.Integer> sizeMatcher) { return org.hamcrest.collection.IsIterableWithSize.<E>iterableWithSize(sizeMatcher); }
/** * Creates a matcher for {@link Iterable}s that matches when a single pass over the * examined {@link Iterable} yields an item count that is equal to the specified * <code>size</code> argument. * For example: * <pre>assertThat(Arrays.asList("foo", "bar"), iterableWithSize(2))</pre> * * @param size * the number of items that should be yielded by an examined {@link Iterable} */ public static <E> org.hamcrest.Matcher<java.lang.Iterable<E>> iterableWithSize(int size) { return org.hamcrest.collection.IsIterableWithSize.<E>iterableWithSize(size); }
/** * Creates a matcher for {@link Iterable}s that matches when a single pass over the * examined {@link Iterable} yields an item count that is equal to the specified * <code>size</code> argument. * For example: * <pre>assertThat(Arrays.asList("foo", "bar"), iterableWithSize(2))</pre> * * @param size * the number of items that should be yielded by an examined {@link Iterable} */ public static <E> Matcher<Iterable<E>> iterableWithSize(int size) { return iterableWithSize(equalTo(size)); } }
@Test public void test1Neighborhood() { Graph graph = graphApi.getNeighbors(newHashSet(b), 1, Collections.<DirectedRelationshipType>emptySet(), absent); assertThat(graph.getVertices(), IsIterableWithSize.<Vertex>iterableWithSize(4)); assertThat(graph.getEdges(), IsIterableWithSize.<Edge>iterableWithSize(3)); }
@Test public void testKNeighborhood() { Graph graph = graphApi.getNeighbors(newHashSet(b), 10, Collections.<DirectedRelationshipType>emptySet(), absent); assertThat(graph.getVertices(), IsIterableWithSize.<Vertex>iterableWithSize(5)); assertThat(graph.getEdges(), IsIterableWithSize.<Edge>iterableWithSize(4)); }
@Test public void testSingleNodeNeighborhood() { Graph graph = graphApi.getNeighbors(newHashSet(f), 1, Collections.<DirectedRelationshipType>emptySet(), absent); assertThat(graph.getVertices(), IsIterableWithSize.<Vertex>iterableWithSize(1)); assertThat(graph.getEdges(), IsIterableWithSize.<Edge>iterableWithSize(0)); }
@Test public void multipleAncestors_areReturned() { Graph graph = graphApi.getNeighbors(newHashSet(i), 10, newHashSet(new DirectedRelationshipType(OwlRelationships.RDFS_SUBCLASS_OF, Direction.OUTGOING)), absent); assertThat(graph.getVertices(), IsIterableWithSize.<Vertex>iterableWithSize(4)); assertThat(graph.getEdges(), IsIterableWithSize.<Edge>iterableWithSize(4)); }
@Test public void testSubclass() { Node subclass = getNode("http://example.org/subclass"); Node superclass = getNode("http://example.org/superclass"); assertThat("classes should be labeled as such", subclass.hasLabel(OwlLabels.OWL_CLASS) && superclass.hasLabel(OwlLabels.OWL_CLASS)); assertThat("subclass should be a directed relationship", GraphUtil.getRelationships(subclass, superclass, OwlRelationships.RDFS_SUBCLASS_OF), is(IsIterableWithSize.<Relationship> iterableWithSize(1))); }