This is an automated email from the ASF dual-hosted git repository.

npeltier pushed a commit to branch master
in repository 
https://gitbox.apache.org/repos/asf/sling-org-apache-sling-pipes.git


The following commit(s) were added to refs/heads/master by this push:
     new 986cada  some more fixes
986cada is described below

commit 986cadad9a103abf6e27aa75cb539b3c99bbb635
Author: Nicolas Peltier <[email protected]>
AuthorDate: Wed Jul 8 22:14:55 2020 +0200

    some more fixes
---
 src/main/java/org/apache/sling/pipes/BasePipe.java |   4 +-
 src/main/java/org/apache/sling/pipes/Pipe.java     |   5 +-
 .../java/org/apache/sling/pipes/PipeBuilder.java   |  10 +-
 src/main/java/org/apache/sling/pipes/Plumber.java  |  14 +--
 .../java/org/apache/sling/pipes/SuperPipe.java     |   4 +-
 .../apache/sling/pipes/internal/GogoCommands.java  | 121 +++++++++---------
 .../apache/sling/pipes/internal/PackagePipe.java   |  11 +-
 .../sling/pipes/internal/PipeBuilderImpl.java      |  56 +++++----
 .../apache/sling/pipes/internal/PlumberImpl.java   | 139 ++++++++++++---------
 .../sling/pipes/internal/PlumberServlet.java       |   1 +
 .../org/apache/sling/pipes/internal/WritePipe.java |  29 +++--
 .../sling/pipes/internal/GogoCommandsTest.java     |   1 +
 .../apache/sling/pipes/internal/MovePipeTest.java  |  43 ++++---
 .../sling/pipes/internal/PlumberServletTest.java   |   5 +-
 src/test/resources/move.json                       |   6 -
 15 files changed, 250 insertions(+), 199 deletions(-)

diff --git a/src/main/java/org/apache/sling/pipes/BasePipe.java 
b/src/main/java/org/apache/sling/pipes/BasePipe.java
index c8416f8..450ec16 100644
--- a/src/main/java/org/apache/sling/pipes/BasePipe.java
+++ b/src/main/java/org/apache/sling/pipes/BasePipe.java
@@ -344,14 +344,14 @@ public class BasePipe implements Pipe {
     }
 
     @Override
-    public void before() throws Exception {
+    public void before() {
         if (StringUtils.isNotBlank(beforeHook)){
             plumber.newPipe(resolver).ref(beforeHook).run();
         }
     }
 
     @Override
-    public void after() throws Exception {
+    public void after() {
         if (StringUtils.isNotBlank(afterHook)){
             plumber.newPipe(resolver).ref(afterHook).run();
         }
diff --git a/src/main/java/org/apache/sling/pipes/Pipe.java 
b/src/main/java/org/apache/sling/pipes/Pipe.java
index 1550a9f..d0830c7 100644
--- a/src/main/java/org/apache/sling/pipes/Pipe.java
+++ b/src/main/java/org/apache/sling/pipes/Pipe.java
@@ -20,7 +20,6 @@ import org.apache.sling.api.resource.Resource;
 import org.jetbrains.annotations.Nullable;
 import org.osgi.annotation.versioning.ConsumerType;
 
-import javax.script.ScriptException;
 import java.util.Iterator;
 
 /**
@@ -118,13 +117,13 @@ public interface Pipe {
      * to be executed before output is retrieved
      * @throws Exception in case anything goes wrong
      */
-    void before() throws Exception;
+    void before();
 
     /**
      * to be executed before output is retrieved
      * @throws Exception in case anything goes wrong
      */
-    void after() throws Exception;
+    void after();
 
     /**
      * Get Distribution agent
diff --git a/src/main/java/org/apache/sling/pipes/PipeBuilder.java 
b/src/main/java/org/apache/sling/pipes/PipeBuilder.java
index 811a319..7d54752 100644
--- a/src/main/java/org/apache/sling/pipes/PipeBuilder.java
+++ b/src/main/java/org/apache/sling/pipes/PipeBuilder.java
@@ -360,7 +360,7 @@ public interface PipeBuilder {
      * @return set of resource path, output of the pipe execution
      * @throws Exception exceptions thrown by the build or the pipe execution 
itself
      */
-    ExecutionResult run() throws Exception;
+    ExecutionResult run();
 
     /**
      * allow execution of a pipe, with more parameter
@@ -368,7 +368,7 @@ public interface PipeBuilder {
      * @return set of resource path, output of the pipe execution
      * @throws Exception in case something goes wrong with pipe execution
      */
-    ExecutionResult run(Map bindings) throws Exception;
+    ExecutionResult run(Map<String, Object> bindings);
 
     /**
      * allow execution of a pipe, with more parameter
@@ -376,7 +376,7 @@ public interface PipeBuilder {
      * @return set of resource path, output of the pipe execution
      * @throws Exception in case something goes wrong with pipe execution
      */
-    ExecutionResult runWith(Object... bindings) throws Exception;
+    ExecutionResult runWith(Object... bindings);
 
     /**
      * run a pipe asynchronously
@@ -384,7 +384,7 @@ public interface PipeBuilder {
      * @return registered job for the pipe execution
      * @throws PersistenceException in case something goes wrong in the job 
creation
      */
-    Job runAsync(Map bindings) throws PersistenceException;
+    Job runAsync(Map<String, Object> bindings) throws PersistenceException;
 
     /**
      * run referenced pipes in parallel
@@ -393,5 +393,5 @@ public interface PipeBuilder {
      * @return set of resource path, merged output of pipes execution (order 
is arbitrary)
      * @throws Exception in case something went wrong in run execution
      */
-    ExecutionResult runParallel(int numThreads, Map bindings) throws Exception;
+    ExecutionResult runParallel(int numThreads, Map<String, Object> bindings);
 }
diff --git a/src/main/java/org/apache/sling/pipes/Plumber.java 
b/src/main/java/org/apache/sling/pipes/Plumber.java
index 53f695d..9a3091c 100644
--- a/src/main/java/org/apache/sling/pipes/Plumber.java
+++ b/src/main/java/org/apache/sling/pipes/Plumber.java
@@ -61,7 +61,7 @@ public interface Plumber {
      *
      * @return Job if registered, null otherwise
      */
-    Job executeAsync(ResourceResolver resolver, String path, Map bindings);
+    Job executeAsync(ResourceResolver resolver, String path, Map<String, 
Object> bindings);
 
     /**
      * executes in a background thread
@@ -71,7 +71,7 @@ public interface Plumber {
      *
      * @return Job if registered, null otherwise
      */
-    Job executeAsync(String path, Map bindings);
+    Job executeAsync(String path, Map<String, Object> bindings);
 
     /**
      * Executes a pipe at a certain path
@@ -83,10 +83,8 @@ public interface Plumber {
      * @param save     in case that pipe writes anything, wether the plumber 
should save changes or not
      *
      * @return instance of <code>ExecutionResult</code>
-     *
-     * @throws Exception in case execution fails
      */
-    ExecutionResult execute(ResourceResolver resolver, String path, Map 
bindings, OutputWriter writer, boolean save) throws Exception;
+    ExecutionResult execute(ResourceResolver resolver, String path, 
Map<String, Object> bindings, OutputWriter writer, boolean save);
 
     /**
      * Executes a given pipe
@@ -98,10 +96,8 @@ public interface Plumber {
      * @param save     in case that pipe writes anything, wether the plumber 
should save changes or not
      *
      * @return instance of <code>ExecutionResult</code>
-     *
-     * @throws Exception in case execution fails
      */
-    ExecutionResult execute(ResourceResolver resolver, Pipe pipe, Map 
bindings, OutputWriter writer, boolean save) throws Exception;
+    ExecutionResult execute(ResourceResolver resolver, Pipe pipe, Map<String, 
Object> bindings, OutputWriter writer, boolean save);
 
     /**
      * Registers
@@ -151,5 +147,5 @@ public interface Plumber {
     /**
      * @return service user that has been configured for executing pipes;
      */
-    Map getServiceUser();
+    Map<String, Object> getServiceUser();
 }
diff --git a/src/main/java/org/apache/sling/pipes/SuperPipe.java 
b/src/main/java/org/apache/sling/pipes/SuperPipe.java
index f6008f8..93f8ad8 100644
--- a/src/main/java/org/apache/sling/pipes/SuperPipe.java
+++ b/src/main/java/org/apache/sling/pipes/SuperPipe.java
@@ -126,7 +126,7 @@ public abstract class SuperPipe extends BasePipe {
     }
 
     @Override
-    public void before() throws Exception {
+    public void before() {
         LOG.debug("entering {} before", getName());
         super.before();
         if (subpipes.isEmpty()){
@@ -139,7 +139,7 @@ public abstract class SuperPipe extends BasePipe {
     }
 
     @Override
-    public void after() throws Exception {
+    public void after() {
         LOG.debug("entering {} after", getName());
         super.after();
         for (Pipe pipe : subpipes){
diff --git a/src/main/java/org/apache/sling/pipes/internal/GogoCommands.java 
b/src/main/java/org/apache/sling/pipes/internal/GogoCommands.java
index b52cb69..54824ca 100644
--- a/src/main/java/org/apache/sling/pipes/internal/GogoCommands.java
+++ b/src/main/java/org/apache/sling/pipes/internal/GogoCommands.java
@@ -18,11 +18,14 @@ package org.apache.sling.pipes.internal;
 
 import org.apache.commons.io.IOUtils;
 import org.apache.commons.lang3.StringUtils;
+import org.apache.sling.api.resource.LoginException;
+import org.apache.sling.api.resource.PersistenceException;
 import org.apache.sling.api.resource.Resource;
 import org.apache.sling.api.resource.ResourceResolver;
 import org.apache.sling.api.resource.ResourceResolverFactory;
 import org.apache.sling.pipes.ExecutionResult;
 import org.apache.sling.pipes.OutputWriter;
+import org.apache.sling.pipes.Pipe;
 import org.apache.sling.pipes.PipeBuilder;
 import org.apache.sling.pipes.PipeExecutor;
 import org.apache.sling.pipes.Plumber;
@@ -31,6 +34,8 @@ import org.osgi.service.component.annotations.Reference;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import java.io.IOException;
+import java.io.PrintStream;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.util.ArrayList;
@@ -50,17 +55,16 @@ import static 
org.apache.sling.pipes.internal.CommandUtil.writeToMap;
             "osgi.command.function=execute",
             "osgi.command.function=help"
         })
-
 public class GogoCommands {
     final Logger log = LoggerFactory.getLogger(GogoCommands.class);
 
-    protected final static String SEPARATOR = "/";
-    protected final static String PARAMS = "@";
-    protected final static String INPUT = "-";
-    protected final static String KEY_VALUE_SEP = "=";
-    protected final static String KEY_NAME = "name";
-    protected final static String KEY_PATH = "path";
-    protected final static String KEY_EXPR = "expr";
+    protected static final String SEPARATOR = "/";
+    protected static final String PARAMS = "@";
+    protected static final String INPUT = "-";
+    protected static final String KEY_VALUE_SEP = "=";
+    protected static final String KEY_NAME = "name";
+    protected static final String KEY_PATH = "path";
+    protected static final String KEY_EXPR = "expr";
 
 
     @Reference
@@ -72,16 +76,21 @@ public class GogoCommands {
     Map<String, Method> methodMap;
 
     Map<String, PipeExecutor> executorMap;
+    
+    
+    PrintStream print() {
+        return System.out;
+    }
 
     /**
      * run command handler
      * @param cmds string tokens coming with run command
      * @throws Exception in case anything went wrong
      */
-    public void run(String... cmds) throws Exception {
+    public void run(String... cmds) throws LoginException, 
InvocationTargetException, IllegalAccessException {
         try (ResourceResolver resolver = 
factory.getServiceResourceResolver(plumber.getServiceUser())) {
             PipeBuilder builder = parse(resolver, cmds);
-            System.out.println(builder.run());
+            print().println(builder.run());
         }
     }
 
@@ -90,10 +99,10 @@ public class GogoCommands {
      * @param cmds string tokens coming with build command
      * @throws Exception in case anything went wrong
      */
-    public void build(String... cmds) throws Exception {
+    public void build(String... cmds) throws LoginException, 
InvocationTargetException, IllegalAccessException, PersistenceException {
         try (ResourceResolver resolver = 
factory.getServiceResourceResolver(plumber.getServiceUser())) {
             PipeBuilder builder = parse(resolver, cmds);
-            System.out.println(builder.build().getResource().getPath());
+            print().println(builder.build().getResource().getPath());
         }
     }
 
@@ -103,13 +112,10 @@ public class GogoCommands {
      * @param options string tokens coming with run command
      * @throws Exception in case anything went wrong
      */
-    public void execute(String path, String... options) throws Exception {
+    public void execute(String path, String... options) throws IOException, 
LoginException {
         String computedPath = INPUT.equals(path) ? 
IOUtils.toString(System.in).trim() : path;
         try (ResourceResolver resolver = 
factory.getServiceResourceResolver(plumber.getServiceUser())) {
-            System.out.println(executeInternal(resolver, computedPath, 
options));
-        } catch(Exception e){
-            log.error("Unable to execute {}", path, e);
-            throw(e);
+            print().println(executeInternal(resolver, computedPath, options));
         }
     }
 
@@ -121,15 +127,15 @@ public class GogoCommands {
      * @return Execution results
      * @throws Exception exception in case something goes wrong
      */
-    protected ExecutionResult executeInternal(ResourceResolver resolver, 
String path, String... optionTokens) throws Exception {
+    protected ExecutionResult executeInternal(ResourceResolver resolver, 
String path, String... optionTokens) {
         Resource resource = resolver.getResource(path);
         if (resource == null){
             throw new IllegalArgumentException(String.format("%s resource does 
not exist", path));
         }
         Options options = getOptions(optionTokens);
-        Map bMap = null;
+        Map<String, Object> bMap = null;
         if (options.with != null) {
-            bMap = new HashMap();
+            bMap = new HashMap<>();
             writeToMap(bMap, options.with);
         }
         OutputWriter writer = new NopWriter();
@@ -144,21 +150,21 @@ public class GogoCommands {
      * help command handler
      */
     public void help(){
-        System.out.format("\nSling Pipes Help\nAvailable commands are \n\n- 
execute <path> <options>(execute a pipe already built at a given path), if path 
is '-' then previous pipe token is used," +
-                                                    "\n- build (build pipe as 
configured in arguments)" +
-                                                    "\n- run (run pipe as 
configured in arguments)" +
-                                                    "\n- help (print this 
help)" +
-                                                    "\n\nfor pipe configured 
in argument, do 'pipe:<run|build|runAsync> <pipe token> (/ <pipe token> )*\n" +
-                                                    "\n a <pipe token> is 
<pipe> <expr|conf>? (<options>)?" +
-                                                    "\n <options> are (@ 
<option>)* form with <option> being either" +
-                                                    "\n\t'name pipeName' (used 
in bindings), " +
-                                                    "\n\t'expr pipeExpression' 
(when not directly as <args>)" +
-                                                    "\n\t'path pipePath' (when 
not directly as <args>)" +
-                                                    "\n\t'with key=value ...'" 
+
-                                                    "\n\t'outputs key=value 
...'" +
-                                                    "\n and <pipe> is one of 
the following :\n");
+        print().format("\nSling Pipes Help\nAvailable commands are \n\n- 
execute <path> <options>(execute a pipe already built at a given path), if path 
is '-' then previous pipe token is used," +
+                                "\n- build (build pipe as configured in 
arguments)" +
+                                "\n- run (run pipe as configured in 
arguments)" +
+                                "\n- help (print(). this help)" +
+                                "\n\nfor pipe configured in argument, do 
'pipe:<run|build|runAsync> <pipe token> (/ <pipe token> )*\n" +
+                                "\n a <pipe token> is <pipe> <expr|conf>? 
(<options>)?" +
+                                "\n <options> are (@ <option>)* form with 
<option> being either" +
+                                "\n\t'name pipeName' (used in bindings), " +
+                                "\n\t'expr pipeExpression' (when not directly 
as <args>)" +
+                                "\n\t'path pipePath' (when not directly as 
<args>)" +
+                                "\n\t'with key=value ...'" +
+                                "\n\t'outputs key=value ...'" +
+                                "\n and <pipe> is one of the following :\n");
         for (Map.Entry<String, PipeExecutor> entry : 
getExecutorMap().entrySet()){
-            System.out.format("\t%s\t\t:\t%s\n", entry.getKey(), 
entry.getValue().description() );
+            print().format("\t%s\t\t:\t%s%n", entry.getKey(), 
entry.getValue().description() );
         }
     }
 
@@ -269,10 +275,10 @@ public class GogoCommands {
      * @return Token list corresponding to the string ones
      */
     protected List<Token> parseTokens(String... commands) {
-        List<Token> returnValue = new ArrayList();
+        List<Token> returnValue = new ArrayList<>();
         Token currentToken = new Token();
         returnValue.add(currentToken);
-        List currentList = new ArrayList();
+        List<String> currentList = new ArrayList<>();
         for (String token : commands){
             if (currentToken.pipeKey == null){
                 currentToken.pipeKey = token;
@@ -280,14 +286,14 @@ public class GogoCommands {
                 switch (token){
                     case GogoCommands.SEPARATOR:
                         finishToken(currentToken, currentList);
-                        currentList = new ArrayList();
+                        currentList = new ArrayList<>();
                         currentToken = new Token();
                         returnValue.add(currentToken);
                         break;
                     case GogoCommands.PARAMS:
                         if (currentToken.args == null){
                             currentToken.args = currentList;
-                            currentList = new ArrayList();
+                            currentList = new ArrayList<>();
                         }
                         currentList.add(PARAMS);
                         break;
@@ -320,7 +326,7 @@ public class GogoCommands {
      */
     protected class Token {
         String pipeKey;
-        List args;
+        List<String> args;
         Options options;
 
         @Override
@@ -355,6 +361,7 @@ public class GogoCommands {
     protected class Options {
         String name;
         String path;
+
         String expr;
         String[] with;
         OutputWriter writer;
@@ -370,6 +377,16 @@ public class GogoCommands {
                     '}';
         }
 
+
+
+        void setOutputs(List<String> values) {
+            this.writer = new JsonWriter();
+            String[] list = keyValuesToArray(values);
+            Map<String, Object> outputs = new HashMap<>();
+            CommandUtil.writeToMap(outputs, list);
+            this.writer.setCustomOutputs(outputs);
+        }
+
         /**
          * Constructor
          * @param options string list from where options will be built
@@ -378,6 +395,8 @@ public class GogoCommands {
             Map<String, Object> optionMap = new HashMap<>();
             String currentKey = null;
             List<String> currentList = null;
+
+
             for (String optionToken : options) {
                 if (PARAMS.equals(optionToken)){
                     finishOption(currentKey, currentList, optionMap);
@@ -392,33 +411,23 @@ public class GogoCommands {
             finishOption(currentKey, currentList, optionMap);
             for (Map.Entry<String, Object> entry : optionMap.entrySet()){
                 switch (entry.getKey()) {
-                    case "name" : {
+                    case Pipe.PN_NAME :
                         this.name = (String)entry.getValue();
                         break;
-                    }
-                    case "path" : {
+                    case Pipe.PN_PATH :
                         this.path = (String)entry.getValue();
                         break;
-                    }
-                    case "expr" : {
+                    case Pipe.PN_EXPR :
                         this.expr = (String)entry.getValue();
                         break;
-                    }
-                    case "with" : {
+                    case "with" :
                         this.with = 
keyValuesToArray((List<String>)entry.getValue());
                         break;
-                    }
-                    case "outputs" : {
-                        this.writer = new JsonWriter();
-                        String[] list = 
keyValuesToArray((List<String>)entry.getValue());
-                        Map outputs = new HashMap();
-                        CommandUtil.writeToMap(outputs, list);
-                        this.writer.setCustomOutputs(outputs);
+                    case "outputs" :
+                        setOutputs((List<String>)entry.getValue());
                         break;
-                    }
-                    default: {
+                    default:
                         throw new IllegalArgumentException(String.format("%s 
is an unknown option", entry.getKey()));
-                    }
                 }
             }
 
diff --git a/src/main/java/org/apache/sling/pipes/internal/PackagePipe.java 
b/src/main/java/org/apache/sling/pipes/internal/PackagePipe.java
index 4858f5c..368f1da 100644
--- a/src/main/java/org/apache/sling/pipes/internal/PackagePipe.java
+++ b/src/main/java/org/apache/sling/pipes/internal/PackagePipe.java
@@ -23,6 +23,7 @@ import 
org.apache.jackrabbit.vault.fs.config.DefaultWorkspaceFilter;
 import org.apache.jackrabbit.vault.packaging.JcrPackage;
 import org.apache.jackrabbit.vault.packaging.JcrPackageDefinition;
 import org.apache.jackrabbit.vault.packaging.JcrPackageManager;
+import org.apache.jackrabbit.vault.packaging.PackageException;
 import org.apache.jackrabbit.vault.packaging.PackagingService;
 import org.apache.jackrabbit.vault.util.Text;
 import org.apache.sling.api.resource.Resource;
@@ -149,11 +150,15 @@ public class PackagePipe extends BasePipe {
     }
 
     @Override
-    public void after() throws Exception {
+    public void after() {
         super.after();
         if (assemble) {
-            JcrPackageManager mgr = 
PackagingService.getPackageManager(resolver.adaptTo(Session.class));
-            mgr.assemble(jcrPackage, null);
+            try {
+                JcrPackageManager mgr = 
PackagingService.getPackageManager(resolver.adaptTo(Session.class));
+                mgr.assemble(jcrPackage, null);
+            } catch (PackageException | RepositoryException | IOException e) {
+                throw new IllegalStateException(e);
+            }
         }
     }
 }
diff --git a/src/main/java/org/apache/sling/pipes/internal/PipeBuilderImpl.java 
b/src/main/java/org/apache/sling/pipes/internal/PipeBuilderImpl.java
index 3d092ec..e0e89b4 100644
--- a/src/main/java/org/apache/sling/pipes/internal/PipeBuilderImpl.java
+++ b/src/main/java/org/apache/sling/pipes/internal/PipeBuilderImpl.java
@@ -62,11 +62,11 @@ public class PipeBuilderImpl implements PipeBuilder {
 
     public static final String PIPES_REPOSITORY_PATH = "/var/pipes";
 
-    public static final String[] DEFAULT_NAMES = new String[]{"one", "two", 
"three", "four", "five", "six", "seven", "eight", "nine", "ten"};
+    private static final String[] DEFAULT_NAMES = new String[]{"one", "two", 
"three", "four", "five", "six", "seven", "eight", "nine", "ten"};
 
     List<Step> steps;
 
-    Map outputs;
+    Map<String, Object> outputs;
 
     Step containerStep = new Step(ContainerPipe.RESOURCE_TYPE);
 
@@ -274,9 +274,9 @@ public class PipeBuilderImpl implements PipeBuilder {
      */
     protected PipeBuilder writeToCurrentStep(String name, Object... params) 
throws IllegalAccessException {
         checkArguments(params);
-        Map props = name != null ? currentStep.confs.get(name) : 
currentStep.properties;
+        Map<String, Object> props = name != null ? currentStep.confs.get(name) 
: currentStep.properties;
         if (props == null){
-            props = new HashMap();
+            props = new HashMap<>();
             if (name != null){
                 currentStep.confs.put(name, props);
             }
@@ -320,13 +320,13 @@ public class PipeBuilderImpl implements PipeBuilder {
      * @throws PersistenceException in case configuration resource couldn't be 
persisted
      * @return resource created
      */
-    protected Resource createResource(ResourceResolver resolver, String path, 
String type, Map data) throws PersistenceException {
+    protected Resource createResource(ResourceResolver resolver, String path, 
String type, Map<String, Object> data) throws PersistenceException {
         return ResourceUtil.getOrCreateResource(resolver, path, data, type, 
false);
     }
 
     @Override
     public PipeBuilder outputs(String... keys) {
-        outputs = new HashMap();
+        outputs = new HashMap<>();
         writeToMap(outputs, keys);
         return this;
     }
@@ -346,10 +346,11 @@ public class PipeBuilderImpl implements PipeBuilder {
      */
     protected Resource persistStep(String path, String parentType, Step step) 
throws PersistenceException {
         Resource resource = createResource(resolver, path, parentType, 
step.properties);
-        if (StringUtils.isNotBlank(step.name)){
-            resource.adaptTo(ModifiableValueMap.class).put(BasePipe.PN_NAME, 
step.name);
+        ModifiableValueMap mvm = resource.adaptTo(ModifiableValueMap.class);
+        if (StringUtils.isNotBlank(step.name) && mvm != null){
+            mvm.put(Pipe.PN_NAME, step.name);
         }
-        for (Map.Entry<String, Map> entry : step.confs.entrySet()){
+        for (Map.Entry<String, Map<String, Object>> entry : 
step.confs.entrySet()){
             createResource(resolver, path + "/" + entry.getKey(), 
NT_SLING_FOLDER, entry.getValue());
             logger.debug("built pipe {}'s {} node", path, entry.getKey());
         }
@@ -364,7 +365,10 @@ public class PipeBuilderImpl implements PipeBuilder {
         }
         int index = 0;
         for (Step step : steps){
-            String name = StringUtils.isNotBlank(step.name) ? step.name : 
DEFAULT_NAMES.length > index ? DEFAULT_NAMES[index] : Integer.toString(index);
+            String name = DEFAULT_NAMES.length > index ? DEFAULT_NAMES[index] 
: Integer.toString(index);
+            if (StringUtils.isNotBlank(step.name)) {
+                name = step.name;
+            }
             index++;
             persistStep(path + "/" + Pipe.NN_CONF + "/" + name, 
NT_SLING_ORDERED_FOLDER, step);
         }
@@ -374,36 +378,42 @@ public class PipeBuilderImpl implements PipeBuilder {
     }
 
     @Override
-    public ExecutionResult run() throws Exception {
+    public ExecutionResult run() {
         return run(null);
     }
 
     @Override
-    public ExecutionResult runWith(Object... bindings) throws Exception {
+    public ExecutionResult runWith(Object... bindings) {
         checkArguments(bindings);
-        Map bindingsMap = new HashMap();
+        Map<String, Object> bindingsMap = new HashMap<>();
         writeToMap(bindingsMap, bindings);
         return run(bindingsMap);
     }
 
     @Override
-    public ExecutionResult run(Map bindings) throws Exception {
+    public ExecutionResult run(Map<String, Object> bindings) {
         JsonWriter writer = new JsonWriter();
-        writer.starts();
-        Pipe pipe = this.build();
-        return plumber.execute(resolver, pipe, bindings,  writer , true);
+        try {
+            writer.starts();
+            Pipe pipe = this.build();
+            return plumber.execute(resolver, pipe, bindings, writer, true);
+        } catch (PersistenceException e) {
+            logger.error("unable to build the pipe", e);
+        }
+        return new ExecutionResult(writer);
     }
 
     @Override
-    public Job runAsync(Map bindings) throws PersistenceException {
+    public Job runAsync(Map<String, Object> bindings) throws 
PersistenceException {
         Pipe pipe = this.build();
         return plumber.executeAsync(resolver, pipe.getResource().getPath(), 
bindings);
     }
 
     @Override
-    public ExecutionResult runParallel(int numThreads, Map additionalBindings) 
throws Exception {
+    public ExecutionResult runParallel(int numThreads, Map<String, Object> 
additionalBindings) {
         containerStep.setType(ManifoldPipe.RESOURCE_TYPE);
-        Map bindings = new HashMap() {{put(PN_NUM_THREADS, numThreads);}};
+        Map<String, Object> bindings = new HashMap<>();
+        bindings.put(PN_NUM_THREADS, numThreads);
         if (additionalBindings != null){
             bindings.putAll(additionalBindings);
         }
@@ -415,10 +425,10 @@ public class PipeBuilderImpl implements PipeBuilder {
      */
     public class Step {
         String name;
-        Map properties;
-        Map<String, Map> confs = new HashMap<>();
+        Map<String, Object> properties;
+        Map<String, Map<String, Object>> confs = new HashMap<>();
         Step(String type){
-            properties = new HashMap();
+            properties = new HashMap<>();
             setType(type);
         }
 
diff --git a/src/main/java/org/apache/sling/pipes/internal/PlumberImpl.java 
b/src/main/java/org/apache/sling/pipes/internal/PlumberImpl.java
index 2249b77..034bed4 100644
--- a/src/main/java/org/apache/sling/pipes/internal/PlumberImpl.java
+++ b/src/main/java/org/apache/sling/pipes/internal/PlumberImpl.java
@@ -89,10 +89,10 @@ public class PlumberImpl implements Plumber, JobConsumer, 
PlumberMXBean {
     private final Logger log = LoggerFactory.getLogger(this.getClass());
     public static final int DEFAULT_BUFFER_SIZE = 1000;
 
-    protected final static String PN_MONITORED = "monitored";
-    protected final static String MONITORED_PIPES_QUERY = 
String.format("//element(*,nt:base)[@sling:resourceType='%s' and @%s]", 
ContainerPipe.RESOURCE_TYPE, PN_MONITORED);
+    protected static final String PN_MONITORED = "monitored";
+    protected static final String MONITORED_PIPES_QUERY = 
String.format("//element(*,nt:base)[@sling:resourceType='%s' and @%s]", 
ContainerPipe.RESOURCE_TYPE, PN_MONITORED);
 
-    protected final static String MBEAN_NAME_FORMAT = 
"org.apache.sling.pipes:name=%s";
+    protected static final String MBEAN_NAME_FORMAT = 
"org.apache.sling.pipes:name=%s";
 
     @ObjectClassDefinition(name="Apache Sling Pipes : Plumber configuration")
     public @interface Configuration {
@@ -115,7 +115,7 @@ public class PlumberImpl implements Plumber, JobConsumer, 
PlumberMXBean {
 
     private Configuration configuration;
 
-    private Map serviceUser;
+    private Map<String, Object> serviceUser;
 
     private List<String> allowedUsers;
 
@@ -211,7 +211,7 @@ public class PlumberImpl implements Plumber, JobConsumer, 
PlumberMXBean {
     }
 
     @Override
-    public Job executeAsync(ResourceResolver resolver, String path, Map 
bindings) {
+    public Job executeAsync(ResourceResolver resolver, String path, 
Map<String, Object> bindings) {
         if (allowedUsers.contains(resolver.getUserID())) {
             return executeAsync(path, bindings);
         }
@@ -219,40 +219,53 @@ public class PlumberImpl implements Plumber, JobConsumer, 
PlumberMXBean {
     }
 
     @Override
-    public Job executeAsync(String path, Map bindings) {
+    public Job executeAsync(String path, Map<String, Object> bindings) {
         if (StringUtils.isBlank((String)serviceUser.get(SUBSERVICE))) {
             log.error("please configure plumber service user");
         }
-        final Map props = new HashMap();
+        final Map<String, Object> props = new HashMap<>();
         props.put(SlingConstants.PROPERTY_PATH, path);
         props.put(PipeBindings.NN_ADDITIONALBINDINGS, bindings);
         return jobManager.addJob(SLING_EVENT_TOPIC, props);
     }
 
     @Override
-    public ExecutionResult execute(ResourceResolver resolver, String path, Map 
additionalBindings, OutputWriter writer, boolean save) throws Exception {
+    public ExecutionResult execute(ResourceResolver resolver, String path, Map 
additionalBindings, OutputWriter writer, boolean save) {
         Resource pipeResource = resolver.getResource(path);
         Pipe pipe = getPipe(pipeResource);
         if (pipe == null) {
-            throw new Exception("unable to build pipe based on configuration 
at " + path);
+            throw new IllegalArgumentException("unable to build pipe based on 
configuration at " + path);
         }
         return execute(resolver, pipe, additionalBindings, writer, save);
     }
 
+    private ExecutionResult internalExecute(ResourceResolver resolver, 
OutputWriter writer, Pipe pipe) throws InterruptedException, 
PersistenceException {
+        ExecutionResult result = new ExecutionResult(writer);
+        for (Iterator<Resource> it = pipe.getOutput(); it.hasNext();){
+            Resource resource = it.next();
+            checkError(pipe, result);
+            if (resource != null) {
+                log.debug("[{}] retrieved {}", pipe.getName(), 
resource.getPath());
+                result.addResultItem(resource);
+                persist(resolver, pipe, result, resource);
+            }
+        }
+        checkError(pipe, result);
+        return result;
+    }
     @Override
-    public ExecutionResult execute(ResourceResolver resolver, Pipe pipe, Map 
additionalBindings, OutputWriter writer, boolean save) throws Exception {
+    public ExecutionResult execute(ResourceResolver resolver, Pipe pipe, Map 
additionalBindings, OutputWriter writer, boolean save) {
         boolean success = false;
         PipeMonitor monitor = null;
         long start = System.currentTimeMillis();
         try {
+            boolean readOnly = false;
             if (additionalBindings != null){
                 pipe.getBindings().addBindings(additionalBindings);
+                readOnly = 
(Boolean)additionalBindings.getOrDefault(BasePipe.READ_ONLY, false);
             }
-            if (additionalBindings != null && 
additionalBindings.containsKey(BasePipe.READ_ONLY)){
-                //this execution comes from a request
-                if ((Boolean)additionalBindings.get(BasePipe.READ_ONLY) && 
pipe.modifiesContent() && !pipe.isDryRun()) {
-                    throw new Exception("This pipe modifies content, you 
should use a POST request");
-                }
+            if (! pipe.isDryRun() && readOnly && pipe.modifiesContent()) {
+                throw new IllegalArgumentException("This pipe modifies 
content, you should use a POST request");
             }
             log.debug("[{}] before execution hook is called", pipe);
             pipe.before();
@@ -260,7 +273,7 @@ public class PlumberImpl implements Plumber, JobConsumer, 
PlumberMXBean {
             Resource confResource = pipe.getResource();
             writer.setPipe(pipe);
             if (isRunning(confResource)){
-                throw new RuntimeException("Pipe is already running");
+                throw new IllegalStateException("Pipe is already running");
             }
             monitor = monitoredPipes.get(confResource.getPath());
             writeStatus(pipe, STATUS_STARTED);
@@ -268,17 +281,7 @@ public class PlumberImpl implements Plumber, JobConsumer, 
PlumberMXBean {
             if (monitor != null){
                 monitor.starts();
             }
-            ExecutionResult result = new ExecutionResult(writer);
-            for (Iterator<Resource> it = pipe.getOutput(); it.hasNext();){
-                Resource resource = it.next();
-                checkError(pipe, result);
-                if (resource != null) {
-                    log.debug("[{}] retrieved {}", pipe.getName(), 
resource.getPath());
-                    result.addResultItem(resource);
-                    persist(resolver, pipe, result, resource);
-                }
-            }
-            checkError(pipe, result);
+            ExecutionResult result = internalExecute(resolver, writer, pipe);
             if (save && pipe.modifiesContent()) {
                 persist(resolver, pipe, result, null);
             }
@@ -289,9 +292,19 @@ public class PlumberImpl implements Plumber, JobConsumer, 
PlumberMXBean {
             }
             success = true;
             return result;
+        } catch (PersistenceException e) {
+            log.error("error while executing pipe", e);
+            throw new IllegalStateException(e);
+        } catch (InterruptedException ie) {
+            log.error("execution interrupted", ie);
+            Thread.currentThread().interrupt();
         } finally {
-            writeStatus(pipe, STATUS_FINISHED);
-            resolver.commit();
+            try {
+                writeStatus(pipe, STATUS_FINISHED);
+                resolver.commit();
+            } catch (PersistenceException e) {
+                log.error("unable to make final save", e);
+            }
             long length = System.currentTimeMillis() - start;
             String time = length < 1000 ? length + "ms" : (length / 1000) + 
"s";
             log.info("[{}] done executing in {}.", pipe.getName(), time);
@@ -301,6 +314,8 @@ public class PlumberImpl implements Plumber, JobConsumer, 
PlumberMXBean {
                 monitor.failed();
             }
         }
+        //returning void result if we get there
+        return new ExecutionResult(writer);
     }
 
     /**
@@ -315,6 +330,13 @@ public class PlumberImpl implements Plumber, JobConsumer, 
PlumberMXBean {
         }
     }
 
+    private boolean shouldSave(ResourceResolver resolver, Pipe pipe, 
ExecutionResult result, Resource currentResource) {
+        return  pipe.modifiesContent()
+            && resolver.hasChanges()
+            && !pipe.isDryRun()
+            && (currentResource == null || result.size() % 
configuration.bufferSize() == 0);
+    }
+
     /**
      * Persists pipe change if big enough, or ended, and eventually distribute 
changes
      * @param resolver resolver to use
@@ -323,26 +345,24 @@ public class PlumberImpl implements Plumber, JobConsumer, 
PlumberMXBean {
      * @param currentResource if running, null if ended
      * @throws PersistenceException in case save fails
      */
-    protected void persist(ResourceResolver resolver, Pipe pipe, 
ExecutionResult result, Resource currentResource) throws Exception {
-        if  (pipe.modifiesContent() && resolver.hasChanges() && 
!pipe.isDryRun()){
-            if (currentResource == null || result.size() % 
configuration.bufferSize() == 0){
-                log.info("[{}] saving changes...", pipe.getName());
-                writeStatus(pipe, currentResource == null ? STATUS_FINISHED : 
currentResource.getPath());
-                resolver.commit();
-                if (currentResource == null && distributor != null && 
StringUtils.isNotBlank(pipe.getDistributionAgent())) {
-                    log.info("a distribution agent is configured, will try to 
distribute the changes");
-                    DistributionRequest request = new 
SimpleDistributionRequest(DistributionRequestType.ADD, true, 
result.getCurrentPathSet().toArray(new 
String[result.getCurrentPathSet().size()]));
-                    DistributionResponse response = 
distributor.distribute(pipe.getDistributionAgent(), resolver, request);
-                    log.info("distribution response : {}", response);
-                }
-                if (result.size() > configuration.bufferSize()){
-                    //avoid too big foot print
-                    result.emptyCurrentSet();
-                }
-                if (configuration.sleep() > 0){
-                    log.debug("sleeping for {}ms", configuration.sleep());
-                    Thread.sleep(configuration.sleep());
-                }
+    protected void persist(ResourceResolver resolver, Pipe pipe, 
ExecutionResult result, Resource currentResource) throws PersistenceException, 
InterruptedException {
+        if (shouldSave(resolver, pipe, result, currentResource)) {
+            log.info("[{}] saving changes...", pipe.getName());
+            writeStatus(pipe, currentResource == null ? STATUS_FINISHED : 
currentResource.getPath());
+            resolver.commit();
+            if (currentResource == null && distributor != null && 
StringUtils.isNotBlank(pipe.getDistributionAgent())) {
+                log.info("a distribution agent is configured, will try to 
distribute the changes");
+                DistributionRequest request = new 
SimpleDistributionRequest(DistributionRequestType.ADD, true, 
result.getCurrentPathSet().toArray(new 
String[result.getCurrentPathSet().size()]));
+                DistributionResponse response = 
distributor.distribute(pipe.getDistributionAgent(), resolver, request);
+                log.info("distribution response : {}", response);
+            }
+            if (result.size() > configuration.bufferSize()) {
+                //avoid too big foot print
+                result.emptyCurrentSet();
+            }
+            if (configuration.sleep() > 0) {
+                log.debug("sleeping for {}ms", configuration.sleep());
+                Thread.sleep(configuration.sleep());
             }
         }
     }
@@ -363,13 +383,15 @@ public class PlumberImpl implements Plumber, JobConsumer, 
PlumberMXBean {
      * @param status status to write
      * @throws RepositoryException in case write goes wrong
      */
-    protected void writeStatus(Pipe pipe, String status) throws 
RepositoryException {
+    protected void writeStatus(Pipe pipe, String status){
         if (StringUtils.isNotBlank(status)){
             ModifiableValueMap vm = 
pipe.getResource().adaptTo(ModifiableValueMap.class);
-            vm.put(PN_STATUS, status);
-            Calendar cal = new GregorianCalendar();
-            cal.setTime(new Date());
-            vm.put(PN_STATUS_MODIFIED, cal);
+            if( vm != null) {
+                vm.put(PN_STATUS, status);
+                Calendar cal = new GregorianCalendar();
+                cal.setTime(new Date());
+                vm.put(PN_STATUS_MODIFIED, cal);
+            }
         }
     }
 
@@ -387,8 +409,7 @@ public class PlumberImpl implements Plumber, JobConsumer, 
PlumberMXBean {
 
     @Override
     public PipeBuilder newPipe(ResourceResolver resolver) {
-        PipeBuilder builder = new PipeBuilderImpl(resolver, this);
-        return builder;
+        return new PipeBuilderImpl(resolver, this);
     }
 
     @Override
@@ -400,7 +421,7 @@ public class PlumberImpl implements Plumber, JobConsumer, 
PlumberMXBean {
     public JobResult process(Job job) {
         try(ResourceResolver resolver = 
factory.getServiceResourceResolver(serviceUser)){
             String path = 
(String)job.getProperty(SlingConstants.PROPERTY_PATH);
-            Map bindings = 
(Map)job.getProperty(PipeBindings.NN_ADDITIONALBINDINGS);
+            Map<String, Object> bindings = 
(Map)job.getProperty(PipeBindings.NN_ADDITIONALBINDINGS);
             OutputWriter writer = new JsonWriter();
             writer.starts();
             execute(resolver, path, bindings, writer, true);
@@ -424,8 +445,8 @@ public class PlumberImpl implements Plumber, JobConsumer, 
PlumberMXBean {
             }
         }
         monitoredPipes = map;
-        for (String path : monitoredPipes.keySet()){
-            toggleJmxRegistration(monitoredPipes.get(path), path, true);
+        for (Map.Entry<String, PipeMonitor> entry : monitoredPipes.entrySet()){
+            toggleJmxRegistration(entry.getValue(), entry.getKey(), true);
         }
     }
 
diff --git a/src/main/java/org/apache/sling/pipes/internal/PlumberServlet.java 
b/src/main/java/org/apache/sling/pipes/internal/PlumberServlet.java
index aa8f235..d174058 100644
--- a/src/main/java/org/apache/sling/pipes/internal/PlumberServlet.java
+++ b/src/main/java/org/apache/sling/pipes/internal/PlumberServlet.java
@@ -59,6 +59,7 @@ import java.util.Map;
                 ServletResolverConstants.SLING_SERVLET_EXTENSIONS + "=csv"
         })
 public class PlumberServlet extends SlingAllMethodsServlet {
+
     Logger log = LoggerFactory.getLogger(this.getClass());
 
     protected static final String PARAM_PATH = "path";
diff --git a/src/main/java/org/apache/sling/pipes/internal/WritePipe.java 
b/src/main/java/org/apache/sling/pipes/internal/WritePipe.java
index f01654c..a6d89af 100644
--- a/src/main/java/org/apache/sling/pipes/internal/WritePipe.java
+++ b/src/main/java/org/apache/sling/pipes/internal/WritePipe.java
@@ -22,6 +22,7 @@ import org.apache.sling.api.resource.ValueMap;
 import org.apache.sling.pipes.BasePipe;
 import org.apache.sling.pipes.PipeBindings;
 import org.apache.sling.pipes.Plumber;
+import org.jetbrains.annotations.Nullable;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -138,8 +139,8 @@ public class WritePipe extends BasePipe {
      * @param conf configured resource that holds all properties to write (and 
subpipes)
      * @param target target resource on which configured values will be written
      */
-    private void copyProperties(Resource conf, Resource target)  {
-        ValueMap writeMap = conf.adaptTo(ValueMap.class);
+    private void copyProperties(@Nullable Resource conf, Resource target)  {
+        ValueMap writeMap = conf != null ? conf.adaptTo(ValueMap.class) : null;
         ModifiableValueMap properties = 
target.adaptTo(ModifiableValueMap.class);
 
         //writing current node
@@ -186,17 +187,19 @@ public class WritePipe extends BasePipe {
         NodeIterator childrenConf = conf.getNodes();
         if (childrenConf.hasNext()){
             Node targetNode = target.adaptTo(Node.class);
-            logger.info("dubbing {} at {}", conf.getPath(), target.getPath());
-            while (childrenConf.hasNext()){
-                Node childConf = childrenConf.nextNode();
-                String name = childConf.getName();
-                name = bindings.conditionalString(name);
-                if (name == null){
-                    logger.debug("name has been instantiated as null, not 
writing that tree");
-                } else if (!isDryRun()){
-                    Node childTarget = targetNode.hasNode(name) ? 
targetNode.getNode(name) : targetNode.addNode(name, 
childConf.getPrimaryNodeType().getName());
-                    logger.debug("writing tree {}", childTarget.getPath());
-                    writeTree(childConf, 
resolver.getResource(childTarget.getPath()));
+            if (targetNode != null) {
+                logger.info("dubbing {} at {}", conf.getPath(), 
target.getPath());
+                while (childrenConf.hasNext()){
+                    Node childConf = childrenConf.nextNode();
+                    String name = childConf.getName();
+                    name = bindings.conditionalString(name);
+                    if (name == null){
+                        logger.debug("name has been instantiated as null, not 
writing that tree");
+                    } else if (!isDryRun()){
+                        Node childTarget = targetNode.hasNode(name) ? 
targetNode.getNode(name) : targetNode.addNode(name, 
childConf.getPrimaryNodeType().getName());
+                        logger.debug("writing tree {}", childTarget.getPath());
+                        writeTree(childConf, 
resolver.getResource(childTarget.getPath()));
+                    }
                 }
             }
         }
diff --git 
a/src/test/java/org/apache/sling/pipes/internal/GogoCommandsTest.java 
b/src/test/java/org/apache/sling/pipes/internal/GogoCommandsTest.java
index b8fe57b..6bf25b6 100644
--- a/src/test/java/org/apache/sling/pipes/internal/GogoCommandsTest.java
+++ b/src/test/java/org/apache/sling/pipes/internal/GogoCommandsTest.java
@@ -22,6 +22,7 @@ import org.apache.sling.pipes.AbstractPipeTest;
 import org.apache.sling.pipes.ExecutionResult;
 import org.apache.sling.pipes.PipeBuilder;
 import org.junit.Before;
+import org.junit.Ignore;
 import org.junit.Test;
 
 import java.util.Arrays;
diff --git a/src/test/java/org/apache/sling/pipes/internal/MovePipeTest.java 
b/src/test/java/org/apache/sling/pipes/internal/MovePipeTest.java
index f02b509..ca9e526 100644
--- a/src/test/java/org/apache/sling/pipes/internal/MovePipeTest.java
+++ b/src/test/java/org/apache/sling/pipes/internal/MovePipeTest.java
@@ -16,10 +16,14 @@
  */
 package org.apache.sling.pipes.internal;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
 import org.apache.commons.collections.IteratorUtils;
 import org.apache.sling.api.resource.PersistenceException;
 import org.apache.sling.api.resource.Resource;
 import org.apache.sling.pipes.AbstractPipeTest;
+import org.apache.sling.pipes.ExecutionResult;
 import org.apache.sling.pipes.Pipe;
 import org.apache.sling.testing.mock.sling.ResourceResolverType;
 import org.apache.sling.testing.mock.sling.junit.SlingContext;
@@ -38,7 +42,6 @@ import java.util.List;
 public class MovePipeTest extends AbstractPipeTest {
 
     static final String MOVENODE_PIPE = "/moveNode";
-    static final String MOVENODEOVERWRITE_PIPE = "/moveNodeOverwrite";
     static final String MOVENODEORDER_PIPE = "/moveNodeOrder";
     static final String MOVEPROPERTY_PIPE = "/moveProperty";
     static final String APPLE_NODE_PATH = "/apple";
@@ -57,40 +60,50 @@ public class MovePipeTest extends AbstractPipeTest {
     }
 
     @Test
+    public void modifiesContent() {
+        
assertTrue(plumber.getPipe(oak.resourceResolver().getResource(PATH_PIPE + 
MOVEPROPERTY_PIPE)).modifiesContent());
+    }
+
+    @Test
     public void testMoveNode() throws Exception {
         Pipe pipe = 
plumber.getPipe(oak.resourceResolver().getResource(PATH_PIPE + MOVENODE_PIPE));
         Iterator<Resource> output = pipe.getOutput();
-        Assert.assertTrue(output.hasNext());
+        assertTrue(output.hasNext());
         output.next();
         Session session = oak.resourceResolver().adaptTo(Session.class);
         session.save();
-        Assert.assertTrue("new node path should exists", 
session.nodeExists(PATH_FRUITS + MOVED_NODE_PATH));
+        assertTrue("new node path should exists", 
session.nodeExists(PATH_FRUITS + MOVED_NODE_PATH));
     }
 
     @Test
     public void testMoveNodeWithOverwrite() throws Exception {
-        Pipe pipe = 
plumber.getPipe(oak.resourceResolver().getResource(PATH_PIPE + 
MOVENODEOVERWRITE_PIPE));
-        Iterator<Resource> output = pipe.getOutput();
-        Assert.assertTrue(output.hasNext());
-        output.next();
+        String bananaPath = PATH_FRUITS + BANANA_NODE_PATH;
+        String applePath = PATH_FRUITS + APPLE_NODE_PATH;
+        ExecutionResult result = plumber.newPipe(oak.resourceResolver())
+            .echo(applePath)
+            .mv(bananaPath).run();
+        assertEquals("there should be no overwrite if not specified", 0, 
result.size());
+        result = plumber.newPipe(oak.resourceResolver())
+            .echo(applePath)
+            .mv(bananaPath).with("overwriteTarget", true).run();
+        assertEquals("there should be no overwrite if not specified", 1, 
result.size());
         Session session = oak.resourceResolver().adaptTo(Session.class);
-        session.save();
-        Assert.assertTrue("target node path should exist", 
session.nodeExists(PATH_FRUITS + BANANA_NODE_PATH));
-        Assert.assertFalse("source node path should have gone", 
session.nodeExists(PATH_FRUITS + APPLE_NODE_PATH));
+        assertTrue("target node path should exist", 
session.nodeExists(bananaPath));
+        Assert.assertFalse("source node path should have gone", 
session.nodeExists(applePath));
     }
 
     @Test
     public void testMoveNodeWithOrdering() throws Exception {
         Pipe pipe = 
plumber.getPipe(oak.resourceResolver().getResource(PATH_PIPE + 
MOVENODEORDER_PIPE));
         Iterator<Resource> output = pipe.getOutput();
-        Assert.assertTrue(output.hasNext());
+        assertTrue(output.hasNext());
         Resource resource = output.next();
         Resource parent = resource.getParent();
         List<Resource> allFruits = IteratorUtils.toList(parent.listChildren());
         Session session = oak.resourceResolver().adaptTo(Session.class);
         session.save();
-        Assert.assertTrue("target node path should exist", 
session.nodeExists(PATH_FRUITS + APPLE_NODE_PATH));
-        Assert.assertTrue("source node path also should exist", 
session.nodeExists(resource.getPath()));
+        assertTrue("target node path should exist", 
session.nodeExists(PATH_FRUITS + APPLE_NODE_PATH));
+        assertTrue("source node path also should exist", 
session.nodeExists(resource.getPath()));
         Assert.assertEquals("banana should be at first position", 
allFruits.get(0).getName(), resource.getName());
         Assert.assertEquals("apple should be at first position", 
allFruits.get(1).getName(), "apple");
     }
@@ -99,11 +112,11 @@ public class MovePipeTest extends AbstractPipeTest {
     public void testMoveProperty() throws Exception {
         Pipe pipe = 
plumber.getPipe(oak.resourceResolver().getResource(PATH_PIPE + 
MOVEPROPERTY_PIPE));
         Iterator<Resource> output = pipe.getOutput();
-        Assert.assertTrue(output.hasNext());
+        assertTrue(output.hasNext());
         output.next();
         Session session = oak.resourceResolver().adaptTo(Session.class);
         session.save();
-        Assert.assertTrue("new property path should exists", 
session.propertyExists(PATH_FRUITS + MOVED_PROPERTY_PATH));
+        assertTrue("new property path should exists", 
session.propertyExists(PATH_FRUITS + MOVED_PROPERTY_PATH));
         Assert.assertFalse("old property path should not", 
session.propertyExists(PATH_FRUITS + PN_INDEX));
     }
 }
diff --git 
a/src/test/java/org/apache/sling/pipes/internal/PlumberServletTest.java 
b/src/test/java/org/apache/sling/pipes/internal/PlumberServletTest.java
index a22a1db..1b161f9 100644
--- a/src/test/java/org/apache/sling/pipes/internal/PlumberServletTest.java
+++ b/src/test/java/org/apache/sling/pipes/internal/PlumberServletTest.java
@@ -123,7 +123,7 @@ public class PlumberServletTest extends AbstractPipeTest {
      * the execution should fail.
      */
     @Test
-    public void testGetOnWriteExecute() throws ServletException {
+    public void testGetOnWriteExecute() {
         SlingHttpServletRequest request = 
mockPlumberServletRequest(context.resourceResolver(), "json", pipedWritePath, 
null, null, null, null, null);
         boolean hasFailed = true;
         try {
@@ -146,8 +146,7 @@ public class PlumberServletTest extends AbstractPipeTest {
         try {
             servlet.execute(request, response, false);
             hasFailed = false;
-        } catch (Exception e){
-        }
+        } catch (Exception e){}
         assertFalse("Execution should not have failed", hasFailed);
     }
 
diff --git a/src/test/resources/move.json b/src/test/resources/move.json
index 36b777f..1f267f6 100644
--- a/src/test/resources/move.json
+++ b/src/test/resources/move.json
@@ -10,12 +10,6 @@
     "path": "/content/fruits/apple",
     "expr": "/content/fruits/granny"
   },
-  "moveNodeOverwrite": {
-    "sling:resourceType":"slingPipes/mv",
-    "path": "/content/fruits/apple",
-    "expr": "/content/fruits/banana",
-    "overwriteTarget": true
-  },
   "moveNodeOrder": {
     "sling:resourceType":"slingPipes/mv",
     "path": "/content/fruits/banana",

Reply via email to