@Override public Iterator<T> iterator() { return readOnly(iterable.iterator()); } };
@Override public Iterator<T> iterator() { return readOnly(iterable.iterator(), conversion); } };
public static <V, T> Iterator<T> readOnly(final Iterable<V> iterable, Function<V, T> conversion) { return readOnly(iterable.iterator(), conversion); }
public static <T> Iterator<T> readOnly(final Iterable<T> iterable) { return readOnly(iterable.iterator()); }
/** * Create a new test specification that is a copy of this specification except with the test data read from * the specified input stream. The supplied stream is read and variables substituted when the {@link #testData() test * data} is {@link TestData#read() read}. * * @param stream the supplier to the stream of test data; may not be null * @return the new test specification; never null */ public TestSpecification readJsonTestData(InputStreamSupplier stream) { Function<TestSpecification, TestData> supplier = (spec) -> { // We need the variables from the TestSpecification that will own this data ... AvailableVariables variables = spec.variables(); return () -> { // Copy the content into a temporary file and replace variables line by line ... File tmpFile = replaceVariables(stream.get(), variables); Array arrayOfDocuments = ArrayReader.defaultReader().readArray(tmpFile); return Iterators.readOnly(arrayOfDocuments.iterator(), (entry) -> { Value value = entry.getValue(); return value.asDocument(); }); }; }; return new TestSpecification(name, config, env, supplier, variables); }
@Override public Iterator<T> iterator() { return readOnly(iterable.iterator()); } };
@Override public Iterator<T> iterator() { return readOnly(iterable.iterator(), conversion); } };
public static <T> Iterator<T> readOnly(final Iterable<T> iterable) { return readOnly(iterable.iterator()); }
public static <V, T> Iterator<T> readOnly(final Iterable<V> iterable, Function<V, T> conversion) { return readOnly(iterable.iterator(), conversion); }
/** * Create a new test specification that is a copy of this specification except with the test data read from * the specified input stream. The supplied stream is read and variables substituted when the {@link #testData() test * data} is {@link TestData#read() read}. * * @param stream the supplier to the stream of test data; may not be null * @return the new test specification; never null */ public TestSpecification readJsonTestData(InputStreamSupplier stream) { Function<TestSpecification, TestData> supplier = (spec) -> { // We need the variables from the TestSpecification that will own this data ... AvailableVariables variables = spec.variables(); return () -> { // Copy the content into a temporary file and replace variables line by line ... File tmpFile = replaceVariables(stream.get(), variables); Array arrayOfDocuments = ArrayReader.defaultReader().readArray(tmpFile); return Iterators.readOnly(arrayOfDocuments.iterator(), (entry) -> { Value value = entry.getValue(); return value.asDocument(); }); }; }; return new TestSpecification(name, config, env, supplier, variables); }