@Override void assertValue(List<T> value, Supplier<Stream<T>> source, boolean ordered) throws ReflectiveOperationException { if (!List.class.isAssignableFrom(value.getClass())) fail(String.format("Class mismatch in ListAssertion: %s", value.getClass())); Stream<T> stream = source.get(); List<T> result = new ArrayList<>(); for (Iterator<T> it = stream.iterator(); it.hasNext(); ) // avoid capturing result::add result.add(it.next()); if (StreamOpFlagTestHelper.isStreamOrdered(stream) && ordered) assertContents(value, result); else assertContentsUnordered(value, result); }
@Override void assertValue(Collection<T> value, Supplier<Stream<T>> source, boolean ordered) throws ReflectiveOperationException { if (!clazz.isAssignableFrom(value.getClass())) fail(String.format("Class mismatch in CollectionAssertion: %s, %s", clazz, value.getClass())); Stream<T> stream = source.get(); Collection<T> result = clazz.newInstance(); for (Iterator<T> it = stream.iterator(); it.hasNext(); ) // avoid capturing result::add result.add(it.next()); if (StreamOpFlagTestHelper.isStreamOrdered(stream) && targetOrdered && ordered) assertContents(value, result); else assertContentsUnordered(value, result); }
@Override void assertValue(List<T> value, Supplier<Stream<T>> source, boolean ordered) throws ReflectiveOperationException { if (!List.class.isAssignableFrom(value.getClass())) fail(String.format("Class mismatch in ToListAssertion: %s", value.getClass())); Stream<T> stream = source.get(); List<T> result = new ArrayList<>(); for (Iterator<T> it = stream.iterator(); it.hasNext(); ) // avoid capturing result::add result.add(it.next()); if (StreamOpFlagTestHelper.isStreamOrdered(stream) && ordered) assertContents(value, result); else assertContentsUnordered(value, result); }
@Override void assertValue(Collection<T> value, Supplier<Stream<T>> source, boolean ordered) throws ReflectiveOperationException { if (!clazz.isAssignableFrom(value.getClass())) fail(String.format("Class mismatch in ToCollectionAssertion: %s, %s", clazz, value.getClass())); Stream<T> stream = source.get(); Collection<T> result = clazz.newInstance(); for (Iterator<T> it = stream.iterator(); it.hasNext(); ) // avoid capturing result::add result.add(it.next()); if (StreamOpFlagTestHelper.isStreamOrdered(stream) && targetOrdered && ordered) assertContents(value, result); else assertContentsUnordered(value, result); }