@Test public void createDrainForSource() throws Exception { File file = folder.newFile("file"); ProcessScript<StringBuilder> process = process("testing", driver(file.getName()), dummy()); FileResourceManipulator manipulator = new FileResourceManipulator(profile(), new ParameterList()); try (DrainDriver<StringBuilder> driver = manipulator.createDrainForSource(process)) { driver.prepare(); driver.put(new StringBuilder("Hello1, world!")); driver.put(new StringBuilder("Hello2, world!")); driver.put(new StringBuilder("Hello3, world!")); } test(file, "Hello1, world!", "Hello2, world!", "Hello3, world!"); }
@Override public <T> DrainDriver<T> createDrainForSource(ProcessScript<T> script) throws IOException { if (script == null) { throw new IllegalArgumentException("script must not be null"); } File path = FileResourceUtil.getPath(profile, script, arguments, DriverScript.Kind.SOURCE); DataModelStreamSupport<? super T> support = FileResourceUtil.loadSupport( profile, script, DriverScript.Kind.SOURCE); FileOutputStreamProvider provider = new FileOutputStreamProvider(path); return new StreamDrainDriver<>(profile.getResourceName(), script.getName(), provider, support); }
FileResourceManipulator extends ResourceManipulator { @Override public <T> DrainDriver<T> createDrainForSource(ProcessScript<T> script) throws IOException { if (script == null) { throw new IllegalArgumentException("script must not be null"); } File path = FileResourceUtil.getPath(profile, script, arguments, DriverScript.Kind.SOURCE); DataModelStreamSupport<? super T> support = FileResourceUtil.loadSupport( profile, script, DriverScript.Kind.SOURCE); FileOutputStreamProvider provider = new FileOutputStreamProvider(path); return new StreamDrainDriver<>(profile.getResourceName(), script.getName(), provider, support); } }
FileResourceManipulator extends ResourceManipulator { @Override public <T> DrainDriver<T> createDrainForSource(ProcessScript<T> script) throws IOException { if (script == null) { throw new IllegalArgumentException("script must not be null"); } File path = FileResourceUtil.getPath(profile, script, arguments, DriverScript.Kind.SOURCE); DataModelStreamSupport<? super T> support = FileResourceUtil.loadSupport( profile, script, DriverScript.Kind.SOURCE); FileOutputStreamProvider provider = new FileOutputStreamProvider(path); return new StreamDrainDriver<>(profile.getResourceName(), script.getName(), provider, support); } FileResourceManipulator(FileProfile profile, ParameterList arguments); }
FileResourceManipulator extends ResourceManipulator { @Override public <T> DrainDriver<T> createDrainForSource(ProcessScript<T> script) throws IOException { if (script == null) { throw new IllegalArgumentException("script must not be null"); } File path = FileResourceUtil.getPath(profile, script, arguments, DriverScript.Kind.SOURCE); DataModelStreamSupport<? super T> support = FileResourceUtil.loadSupport( profile, script, DriverScript.Kind.SOURCE); FileOutputStreamProvider provider = new FileOutputStreamProvider(path); return new StreamDrainDriver<>(profile.getResourceName(), script.getName(), provider, support); } FileResourceManipulator(FileProfile profile, ParameterList arguments); @Override String getName(); @Override void cleanupSource(ProcessScript<?> script); @Override void cleanupDrain(ProcessScript<?> script); @Override SourceDriver<T> createSourceForSource(ProcessScript<T> script); @Override DrainDriver<T> createDrainForSource(ProcessScript<T> script); @Override SourceDriver<T> createSourceForDrain(ProcessScript<T> script); @Override DrainDriver<T> createDrainForDrain(ProcessScript<T> script); }
FileResourceManipulator extends ResourceManipulator { @Override public <T> DrainDriver<T> createDrainForSource(ProcessScript<T> script) throws IOException { if (script == null) { throw new IllegalArgumentException("script must not be null"); } File path = FileResourceUtil.getPath(profile, script, arguments, DriverScript.Kind.SOURCE); DataModelStreamSupport<? super T> support = FileResourceUtil.loadSupport( profile, script, DriverScript.Kind.SOURCE); FileOutputStreamProvider provider = new FileOutputStreamProvider(path); return new StreamDrainDriver<>(profile.getResourceName(), script.getName(), provider, support); } FileResourceManipulator(FileProfile profile, ParameterList arguments); @Override String getName(); @Override void cleanupSource(ProcessScript<?> script); @Override void cleanupDrain(ProcessScript<?> script); @Override SourceDriver<T> createSourceForSource(ProcessScript<T> script); @Override DrainDriver<T> createDrainForSource(ProcessScript<T> script); @Override SourceDriver<T> createSourceForDrain(ProcessScript<T> script); @Override DrainDriver<T> createDrainForDrain(ProcessScript<T> script);  }