// Path: src/main/java/net/kimleo/rec/v2/model/Source.java
// public interface Source<T> {
//     Stream<T> stream();
//     default Source<T> tee(Tee<T> tee) {
//         return () -> this.stream().map(tee::emit);
//     }
// 
//     default Source<T> filter(Predicate<T> predicate) {
//         return () -> this.stream().filter(predicate);
//     }
// 
//     default Source<T> skip(int n) {
//         return from(stream().skip(n));
//     }
// 
//     static <T> Source<T> from(Stream<T> records) {
//         return () -> records;
//     }
// 
//     default void to(Target<T> target) {
//         target.putAll(this);
//     }
// }
// 
// Path: src/main/java/net/kimleo/rec/v2/scripting/Scripting.java
// public class Scripting {
//     public static void runfile(File file,
//                                String filename,
//                                boolean enableRetry,
//                                String retryFile) throws Exception {
//         Context ctx = Context.enter();
//         ctx.putThreadLocal("SCRIPT_PATH", file.getAbsoluteFile().getParent());
// 
//         ScriptableObject scope = ctx.initStandardObjects();
// 
//         NativeExecutionContext executionContext = initializeNativeExecutionContext(
//                 file,
//                 enableRetry,
//                 retryFile,
//                 ctx);
// 
//         scope.putConst("context", scope, javaToJS(executionContext, scope));
// 
//         ctx.setLanguageVersion(VERSION_1_8);
//         Require require = new RequireBuilder()
//                 .setModuleScriptProvider(new SoftCachingModuleScriptProvider(new NativeModuleSourceProvider()))
//                 .createRequire(ctx, scope);
//         require.install(scope);
//         require.requireMain(ctx, filename);
//     }
// 
//     private static NativeExecutionContext initializeNativeExecutionContext(File file,
//                                                                            boolean enableRetry,
//                                                                            String retryFile,
//                                                                            Context ctx) {
//         NativeExecutionContext executionContext = initialContext();
// 
//         executionContext.setScriptPath(file.getAbsoluteFile().getParent());
//         executionContext.setJsContext(ctx);
//         executionContext.setEnableRetry(enableRetry);
//         executionContext.setRetryFile(retryFile);
//         return executionContext;
//     }
// 
// }
// 
// Path: src/main/java/net/kimleo/rec/v2/utils/Persistence.java
// public class Persistence {
//     public static void saveObjectToFile(Object serializable, String file) throws IOException {
//         ObjectOutputStream stream = new ObjectOutputStream(new FileOutputStream(file));
//         stream.writeObject(serializable);
//     }
// 
//     public static Object loadObjectFromFile(String file) throws IOException, ClassNotFoundException {
//         ObjectInputStream in = new ObjectInputStream(new FileInputStream(file));
// 
//         return in.readObject();
//     }
// }


import net.kimleo.rec.v2.model.Source;
import net.kimleo.rec.v2.scripting.Scripting;
import net.kimleo.rec.v2.utils.Persistence;
import org.junit.Test;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.function.Consumer;
import java.util.stream.Stream;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
package net.kimleo.rec.v2.execution.impl;




public class CountBasedRestartableSourceTest {
    @Test
    public void shouldJustRunAsExpected() throws Exception {
        Stream<Integer> stream = Stream.of(1, 2, 3, 4, 5);
// Path: src/main/java/net/kimleo/rec/v2/model/Source.java
// public interface Source<T> {
//     Stream<T> stream();
//     default Source<T> tee(Tee<T> tee) {
//         return () -> this.stream().map(tee::emit);
//     }
// 
//     default Source<T> filter(Predicate<T> predicate) {
//         return () -> this.stream().filter(predicate);
//     }
// 
//     default Source<T> skip(int n) {
//         return from(stream().skip(n));
//     }
// 
//     static <T> Source<T> from(Stream<T> records) {
//         return () -> records;
//     }
// 
//     default void to(Target<T> target) {
//         target.putAll(this);
//     }
// }
// 
// Path: src/main/java/net/kimleo/rec/v2/scripting/Scripting.java
// public class Scripting {
//     public static void runfile(File file,
//                                String filename,
//                                boolean enableRetry,
//                                String retryFile) throws Exception {
//         Context ctx = Context.enter();
//         ctx.putThreadLocal("SCRIPT_PATH", file.getAbsoluteFile().getParent());
// 
//         ScriptableObject scope = ctx.initStandardObjects();
// 
//         NativeExecutionContext executionContext = initializeNativeExecutionContext(
//                 file,
//                 enableRetry,
//                 retryFile,
//                 ctx);
// 
//         scope.putConst("context", scope, javaToJS(executionContext, scope));
// 
//         ctx.setLanguageVersion(VERSION_1_8);
//         Require require = new RequireBuilder()
//                 .setModuleScriptProvider(new SoftCachingModuleScriptProvider(new NativeModuleSourceProvider()))
//                 .createRequire(ctx, scope);
//         require.install(scope);
//         require.requireMain(ctx, filename);
//     }
// 
//     private static NativeExecutionContext initializeNativeExecutionContext(File file,
//                                                                            boolean enableRetry,
//                                                                            String retryFile,
//                                                                            Context ctx) {
//         NativeExecutionContext executionContext = initialContext();
// 
//         executionContext.setScriptPath(file.getAbsoluteFile().getParent());
//         executionContext.setJsContext(ctx);
//         executionContext.setEnableRetry(enableRetry);
//         executionContext.setRetryFile(retryFile);
//         return executionContext;
//     }
// 
// }
// 
// Path: src/main/java/net/kimleo/rec/v2/utils/Persistence.java
// public class Persistence {
//     public static void saveObjectToFile(Object serializable, String file) throws IOException {
//         ObjectOutputStream stream = new ObjectOutputStream(new FileOutputStream(file));
//         stream.writeObject(serializable);
//     }
// 
//     public static Object loadObjectFromFile(String file) throws IOException, ClassNotFoundException {
//         ObjectInputStream in = new ObjectInputStream(new FileInputStream(file));
// 
//         return in.readObject();
//     }
// }


// Path: src/test/java/net/kimleo/rec/v2/execution/impl/CountBasedRestartableSourceTest.java
import net.kimleo.rec.v2.model.Source;
import net.kimleo.rec.v2.scripting.Scripting;
import net.kimleo.rec.v2.utils.Persistence;
import org.junit.Test;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.function.Consumer;
import java.util.stream.Stream;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

package net.kimleo.rec.v2.execution.impl;




public class CountBasedRestartableSourceTest {
    @Test
    public void shouldJustRunAsExpected() throws Exception {
        Stream<Integer> stream = Stream.of(1, 2, 3, 4, 5);
        Source<Integer> restartable = CountBasedRestartableSource.from(stream);