You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-commits@jackrabbit.apache.org by ju...@apache.org on 2012/10/01 12:48:44 UTC

svn commit: r1392274 - in /jackrabbit/oak/trunk: oak-mongomk-test/src/test/java/org/apache/jackrabbit/mongomk/test/it/ oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/impl/builder/ oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/impl/js...

Author: jukka
Date: Mon Oct  1 10:48:43 2012
New Revision: 1392274

URL: http://svn.apache.org/viewvc?rev=1392274&view=rev
Log:
OAK-349: [MongoMK] CommitImpl constructor with instructions list should be removed

Patch by Mete Atamel

Modified:
    jackrabbit/oak/trunk/oak-mongomk-test/src/test/java/org/apache/jackrabbit/mongomk/test/it/MongoMicroKernelFixture.java
    jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/impl/builder/CommitBuilder.java
    jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/impl/json/JsopParser.java
    jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/impl/model/CommitImpl.java
    jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/model/NodeMongo.java
    jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/util/MongoUtil.java
    jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/command/CommitCommandMongoTest.java
    jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/command/ConcurrentCommitCommandMongoTest.java
    jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/command/NodeExistsCommandMongoTest.java
    jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/query/FetchNodesByPathAndDepthQueryTest.java
    jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/query/FetchNodesForRevisionQueryTest.java
    jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/query/FetchValidCommitsQueryTest.java
    jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/scenario/SimpleNodeScenario.java

Modified: jackrabbit/oak/trunk/oak-mongomk-test/src/test/java/org/apache/jackrabbit/mongomk/test/it/MongoMicroKernelFixture.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mongomk-test/src/test/java/org/apache/jackrabbit/mongomk/test/it/MongoMicroKernelFixture.java?rev=1392274&r1=1392273&r2=1392274&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mongomk-test/src/test/java/org/apache/jackrabbit/mongomk/test/it/MongoMicroKernelFixture.java (original)
+++ jackrabbit/oak/trunk/oak-mongomk-test/src/test/java/org/apache/jackrabbit/mongomk/test/it/MongoMicroKernelFixture.java Mon Oct  1 10:48:43 2012
@@ -21,12 +21,12 @@ import java.util.Properties;
 
 import org.apache.jackrabbit.mk.api.MicroKernel;
 import org.apache.jackrabbit.mk.test.MicroKernelFixture;
-import org.apache.jackrabbit.mongomk.BlobStoreMongo;
-import org.apache.jackrabbit.mongomk.MongoConnection;
-import org.apache.jackrabbit.mongomk.NodeStoreMongo;
 import org.apache.jackrabbit.mongomk.api.BlobStore;
 import org.apache.jackrabbit.mongomk.api.NodeStore;
+import org.apache.jackrabbit.mongomk.impl.BlobStoreMongo;
+import org.apache.jackrabbit.mongomk.impl.MongoConnection;
 import org.apache.jackrabbit.mongomk.impl.MongoMicroKernel;
+import org.apache.jackrabbit.mongomk.impl.NodeStoreMongo;
 import org.apache.jackrabbit.mongomk.util.MongoUtil;
 import org.junit.Assert;
 

Modified: jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/impl/builder/CommitBuilder.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/impl/builder/CommitBuilder.java?rev=1392274&r1=1392273&r2=1392274&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/impl/builder/CommitBuilder.java (original)
+++ jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/impl/builder/CommitBuilder.java Mon Oct  1 10:48:43 2012
@@ -51,10 +51,11 @@ public class CommitBuilder {
      * @throws Exception If an error occurred while creating the {@code Commit}.
      */
     public static Commit build(String path, String diff, String message) throws Exception {
-        CommitHandler commitHandler = new CommitHandler(new CommitImpl(path, diff, message));
+        CommitImpl commit = new CommitImpl(path, diff, message);
+        CommitHandler commitHandler = new CommitHandler(commit);
         JsopParser jsopParser = new JsopParser(path, diff, commitHandler);
         jsopParser.parse();
-        return commitHandler.getCommit();
+        return commit;
     }
 
     private CommitBuilder() {
@@ -106,9 +107,5 @@ public class CommitBuilder {
             SetPropertyInstruction instruction = new SetPropertyInstructionImpl(path, key, value);
             commit.addInstruction(instruction);
         }
-
-        Commit getCommit() {
-            return commit;
-        }
     }
 }

Modified: jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/impl/json/JsopParser.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/impl/json/JsopParser.java?rev=1392274&r1=1392273&r2=1392274&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/impl/json/JsopParser.java (original)
+++ jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/impl/json/JsopParser.java Mon Oct  1 10:48:43 2012
@@ -102,9 +102,8 @@ public class JsopParser {
 
     private void parseOpAdded(String currentPath) throws Exception {
         String subPath = tokenizer.readString();
-        String path = PathUtils.concat(currentPath, subPath);
-
         tokenizer.read(':');
+        String path = PathUtils.concat(currentPath, subPath);
 
         if (tokenizer.matches('{')) {
             String parentPath = PathUtils.denotesRoot(path) ? "" : PathUtils.getParentPath(path);
@@ -117,20 +116,26 @@ public class JsopParser {
                     String propName = tokenizer.readString();
                     tokenizer.read(':');
 
-                    if (tokenizer.matches('{')) { // parse a nested node
-                        tokenizer.setPos(pos); // resetting to last post b/c parseOpAdded expects the whole json
+                    if (tokenizer.matches('{')) { // Nested node.
+                        // Reset to last pos as parseOpAdded expected the whole JSON.
+                        tokenizer.setPos(pos);
                         tokenizer.read();
                         parseOpAdded(path);
-                    } else { // parse property
+                    } else { // Property.
                         String valueAsString = tokenizer.readRawValue().trim();
                         Object value = JsonUtil.convertJsonValue(valueAsString);
-
                         defaultHandler.propertyAdded(path, propName, value);
                     }
                 } while (tokenizer.matches(','));
 
                 tokenizer.read('}'); // explicitly close the bracket
             }
+        } else { // Property.
+            String parentPath = PathUtils.denotesRoot(path) ? "" : PathUtils.getParentPath(path);
+            String propName = PathUtils.denotesRoot(path) ? "/" : PathUtils.getName(path);
+            String valueAsString = tokenizer.readRawValue().trim();
+            Object value = JsonUtil.convertJsonValue(valueAsString);
+            defaultHandler.propertyAdded(parentPath, propName, value);
         }
     }
 

Modified: jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/impl/model/CommitImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/impl/model/CommitImpl.java?rev=1392274&r1=1392273&r2=1392274&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/impl/model/CommitImpl.java (original)
+++ jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/impl/model/CommitImpl.java Mon Oct  1 10:48:43 2012
@@ -24,7 +24,6 @@ import java.util.List;
 import org.apache.jackrabbit.mongomk.api.model.Commit;
 import org.apache.jackrabbit.mongomk.api.model.Instruction;
 
-
 /**
  * Implementation of {@link Commit}.
  *
@@ -37,6 +36,7 @@ public class CommitImpl implements Commi
     private final String message;
     private final String path;
     private final long timestamp;
+
     private Long revisionId;
 
     /**
@@ -47,22 +47,10 @@ public class CommitImpl implements Commi
      * @param message The message.
      */
     public CommitImpl(String path, String diff, String message) {
-        this(path, diff, message, new LinkedList<Instruction>());
-    }
-
-    /**
-     * Constructs a new {@code CommitImpl}.
-     *
-     * @param path The path.
-     * @param diff The diff.
-     * @param message The message.
-     * @param instructions The {@link Instruction}s.
-     */
-    public CommitImpl(String path, String diff, String message, List<Instruction> instructions) {
         this.path = path;
         this.diff = diff;
         this.message = message;
-        this.instructions = instructions;
+        this.instructions = new LinkedList<Instruction>();
         timestamp = new Date().getTime();
     }
 

Modified: jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/model/NodeMongo.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/model/NodeMongo.java?rev=1392274&r1=1392273&r2=1392274&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/model/NodeMongo.java (original)
+++ jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/model/NodeMongo.java Mon Oct  1 10:48:43 2012
@@ -169,7 +169,8 @@ public class NodeMongo extends BasicDBOb
                 return true;
             }
         }
-        return addedChildExists(childName);
+        return false;
+        //return addedChildExists(childName);
     }
 
     private boolean addedChildExists(String childName) {

Modified: jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/util/MongoUtil.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/util/MongoUtil.java?rev=1392274&r1=1392273&r2=1392274&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/util/MongoUtil.java (original)
+++ jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/util/MongoUtil.java Mon Oct  1 10:48:43 2012
@@ -37,7 +37,7 @@ public class MongoUtil {
 
     public static final String INITIAL_COMMIT_MESSAGE = "This is an autogenerated initial commit";
     public static final String INITIAL_COMMIT_PATH = "";
-    public static final String INITIAL_COMMIT_DIFF = "+/ : {}";
+    public static final String INITIAL_COMMIT_DIFF = "+\"/\" : {}";
 
     public static void clearCommitCollection(MongoConnection mongoConnection) {
         DBCollection commitCollection = mongoConnection.getCommitCollection();

Modified: jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/command/CommitCommandMongoTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/command/CommitCommandMongoTest.java?rev=1392274&r1=1392273&r2=1392274&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/command/CommitCommandMongoTest.java (original)
+++ jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/command/CommitCommandMongoTest.java Mon Oct  1 10:48:43 2012
@@ -20,19 +20,12 @@ import static org.junit.Assert.assertEqu
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.fail;
 
-import java.util.LinkedList;
-import java.util.List;
-
 import org.apache.jackrabbit.mongomk.BaseMongoTest;
 import org.apache.jackrabbit.mongomk.MongoAssert;
 import org.apache.jackrabbit.mongomk.api.model.Commit;
-import org.apache.jackrabbit.mongomk.api.model.Instruction;
 import org.apache.jackrabbit.mongomk.api.model.Node;
+import org.apache.jackrabbit.mongomk.impl.builder.CommitBuilder;
 import org.apache.jackrabbit.mongomk.impl.builder.NodeBuilder;
-import org.apache.jackrabbit.mongomk.impl.model.AddNodeInstructionImpl;
-import org.apache.jackrabbit.mongomk.impl.model.AddPropertyInstructionImpl;
-import org.apache.jackrabbit.mongomk.impl.model.CommitImpl;
-import org.apache.jackrabbit.mongomk.impl.model.RemoveNodeInstructionImpl;
 import org.apache.jackrabbit.mongomk.scenario.SimpleNodeScenario;
 import org.apache.jackrabbit.mongomk.util.MongoUtil;
 import org.apache.jackrabbit.oak.commons.PathUtils;
@@ -48,13 +41,8 @@ public class CommitCommandMongoTest exte
 
     @Test
     public void addNodes() throws Exception {
-        List<Instruction> instructions = new LinkedList<Instruction>();
-        instructions.add(new AddNodeInstructionImpl("/", "a"));
-        instructions.add(new AddNodeInstructionImpl("/a", "b"));
-        instructions.add(new AddNodeInstructionImpl("/a", "c"));
-
-        Commit commit = new CommitImpl("/", "+a : { b : {} , c : {} }",
-                "This is a simple commit", instructions);
+        Commit commit = CommitBuilder.build("/", "+\"a\" : { \"b\" : {} , \"c\" : {} }",
+                "This is a simple commit");
         CommitCommandMongo command = new CommitCommandMongo(mongoConnection, commit);
         Long revisionId = command.execute();
 
@@ -70,50 +58,32 @@ public class CommitCommandMongoTest exte
 
     @Test
     public void addNodesToSameParent() throws Exception {
-        List<Instruction> instructions = new LinkedList<Instruction>();
-        instructions.add(new AddNodeInstructionImpl("/", "1"));
-
-        Commit commit = new CommitImpl("/", "+1 : {}", "This is the 1st commit", instructions);
+        Commit commit = CommitBuilder.build("/", "+\"a\" : {}", "This is the 1st commit");
         CommitCommandMongo command = new CommitCommandMongo(mongoConnection, commit);
         Long firstRevisionId = command.execute();
 
-        instructions = new LinkedList<Instruction>();
-        instructions.add(new AddNodeInstructionImpl("/", "2"));
-
-        commit = new CommitImpl("/", "+2 : {}", "This is the 2nd commit", instructions);
+        commit = CommitBuilder.build("/", "+\"b\" : {}", "This is the 2nd commit");
         command = new CommitCommandMongo(mongoConnection, commit);
         Long secondRevisionId = command.execute();
 
-        instructions = new LinkedList<Instruction>();
-        instructions.add(new AddNodeInstructionImpl("/", "3"));
-
-        commit = new CommitImpl("/", "+3 : {}", "This is the 3rd commit", instructions);
+        commit = CommitBuilder.build("/", "+\"c\" : {}", "This is the 3rd commit");
         command = new CommitCommandMongo(mongoConnection, commit);
         Long thirdRevisionId = command.execute();
 
         MongoAssert.assertNodesExist(NodeBuilder.build(String.format(
-                "{ \"/#%3$s\" : { \"1#%1$s\" : { } , \"2#%2$s\" : { } , \"3#%3$s\" : { } } }",
+                "{ \"/#%3$s\" : { \"a#%1$s\" : { } , \"b#%2$s\" : { } , \"c#%3$s\" : { } } }",
                 firstRevisionId, secondRevisionId, thirdRevisionId)));
     }
 
     @Test
     public void addIntermediataryNodes() throws Exception {
-        List<Instruction> instructions = new LinkedList<Instruction>();
-        instructions.add(new AddNodeInstructionImpl("/", "a"));
-        instructions.add(new AddNodeInstructionImpl("/a", "b"));
-        instructions.add(new AddNodeInstructionImpl("/a/b", "c"));
-
-        Commit commit = new CommitImpl("/", "+a : { b : { c: {} }",
-                "Add /a/b/c", instructions);
+        Commit commit = CommitBuilder.build("/", "+\"a\" : { \"b\" : { \"c\": {} }}",
+                "Add /a/b/c");
         CommitCommandMongo command = new CommitCommandMongo(mongoConnection, commit);
         Long revisionId1 = command.execute();
 
-        instructions = new LinkedList<Instruction>();
-        instructions.add(new AddNodeInstructionImpl("/a", "d"));
-        instructions.add(new AddNodeInstructionImpl("/a/b", "e"));
-
-        commit = new CommitImpl("/", "+a : { b : { e: {} }, d : {} }",
-                "Add /a/d and /a/b/e", instructions);
+        commit = CommitBuilder.build("/", "+\"a\" : { \"b\" : { \"e\": {} }, \"d\" : {} }",
+                "Add /a/d and /a/b/e");
         command = new CommitCommandMongo(mongoConnection, commit);
         Long revisionId2 = command.execute();
 
@@ -124,16 +94,11 @@ public class CommitCommandMongoTest exte
 
     @Test
     public void addDuplicateNode() throws Exception {
-        List<Instruction> instructions = new LinkedList<Instruction>();
-        instructions.add(new AddNodeInstructionImpl("/", "a"));
-        instructions.add(new AddNodeInstructionImpl("/a", "b"));
-        Commit commit = new CommitImpl("/", "+a : { \"b\" : {} }", "Add /a/b", instructions);
+        Commit commit = CommitBuilder.build("/", "+\"a\" : { \"b\" : {} }", "Add a/b");
         CommitCommandMongo command = new CommitCommandMongo(mongoConnection, commit);
         command.execute();
 
-        instructions = new LinkedList<Instruction>();
-        instructions.add(new AddNodeInstructionImpl("/a", "b"));
-        commit = new CommitImpl("/a", "+b", "Add /a/b again", instructions);
+        commit = CommitBuilder.build("/a", "+\"b\" : {}", "Add a/b again");
         command = new CommitCommandMongo(mongoConnection, commit);
         try {
             command.execute();
@@ -147,17 +112,10 @@ public class CommitCommandMongoTest exte
         SimpleNodeScenario scenario1 = new SimpleNodeScenario(mongoConnection);
         scenario1.create();
 
-        List<Instruction> instructions = new LinkedList<Instruction>();
-        instructions.add(new AddNodeInstructionImpl("/", "a"));
-        instructions.add(new AddPropertyInstructionImpl("/a", "key1", "value1"));
-        instructions.add(new AddNodeInstructionImpl("/a", "b"));
-        instructions.add(new AddPropertyInstructionImpl("/a/b", "key2", "value2"));
-        instructions.add(new AddNodeInstructionImpl("/a", "c"));
-        instructions.add(new AddPropertyInstructionImpl("/a/c", "key3", "value3"));
-
-        Commit commit = new CommitImpl("/",
-                "+a : { \"key1\" : \"value1\" , \"key2\" : \"value2\" , \"key3\" : \"value3\" }",
-                "This is a simple commit", instructions);
+        Commit commit = CommitBuilder.build("/",
+                "+\"a\" : { \"key1\" : \"value1\" , \"b\" : {\"key2\" : \"value2\"}"
+                + ", \"c\" : {\"key3\" : \"value3\"}}",
+                "This is a simple commit");
         CommitCommandMongo command = new CommitCommandMongo(mongoConnection, commit);
         Long revisionId = command.execute();
 
@@ -171,33 +129,6 @@ public class CommitCommandMongoTest exte
     }
 
     @Test
-    public void addNodesAndPropertiesOutOfOrder() throws Exception {
-        List<Instruction> instructions = new LinkedList<Instruction>();
-        instructions.add(new AddPropertyInstructionImpl("/a", "key1", "value1"));
-        instructions.add(new AddNodeInstructionImpl("/", "a"));
-        instructions.add(new AddNodeInstructionImpl("/a", "b"));
-        instructions.add(new AddPropertyInstructionImpl("/a/b", "key2", "value2"));
-        instructions.add(new AddPropertyInstructionImpl("/a/c", "key3", "value3"));
-        instructions.add(new AddNodeInstructionImpl("/a", "c"));
-
-        Commit commit = new CommitImpl("/",
-                "+a : { \"key1\" : \"value1\" , \"key2\" : \"value2\" , \"key3\" : \"value3\" }",
-                "This is a simple commit", instructions);
-        CommitCommandMongo command = new CommitCommandMongo(mongoConnection, commit);
-        Long revisionId = command.execute();
-
-        Assert.assertNotNull(revisionId);
-        MongoAssert.assertNodesExist(NodeBuilder.build(String.format(
-                "{ \"/#%1$s\" : { \"a#%1$s\" : { \"key1\" : \"value1\", \"b#%1$s\" : { \"key2\" : \"value2\" } , \"c#%1$s\" : { \"key3\" : \"value3\" } } } }",
-                revisionId)));
-
-        MongoAssert.assertCommitExists(commit);
-        MongoAssert.assertCommitContainsAffectedPaths(commit.getRevisionId(), "/", "/a", "/a/b", "/a/c");
-        MongoAssert.assertHeadRevision(1);
-        MongoAssert.assertNextRevision(2);
-    }
-
-    @Test
     @Ignore
     // FIXME - This currently fails due to some limit in property sizes in Mongo
     // which affects path property.
@@ -206,12 +137,9 @@ public class CommitCommandMongoTest exte
         String baseNodeName = "test";
         int numberOfCommits = 1000;
 
-        List<Instruction> instructions = new LinkedList<Instruction>();
         for (int i = 0; i < numberOfCommits; i++) {
-            instructions.clear();
-            instructions.add(new AddNodeInstructionImpl(path, baseNodeName + i));
-            Commit commit = new CommitImpl(path, "+" + baseNodeName + i + " : {}",
-                    "Add node n" + i, instructions);
+            Commit commit = CommitBuilder.build(path, "+\"" + baseNodeName + i + "\" : {}",
+                    "Add node n" + i);
             CommitCommandMongo command = new CommitCommandMongo(
                     mongoConnection, commit);
             command.execute();
@@ -256,13 +184,8 @@ public class CommitCommandMongoTest exte
 
     @Test
     public void existingParentContainsChildren() throws Exception {
-        List<Instruction> instructions = new LinkedList<Instruction>();
-        instructions.add(new AddNodeInstructionImpl("/", "a"));
-        instructions.add(new AddNodeInstructionImpl("/", "b"));
-        instructions.add(new AddNodeInstructionImpl("/", "c"));
-
-        Commit commit = new CommitImpl("/", "+a : { b : {} , c : {} }",
-                "This is a simple commit", instructions);
+        Commit commit = CommitBuilder.build("", "+ \"/\" : {\"a\" : {}, \"b\" : {}, \"c\" : {}}",
+                "This is a simple commit");
         CommitCommandMongo command = new CommitCommandMongo(mongoConnection, commit);
         Long revisionId = command.execute();
 
@@ -277,15 +200,9 @@ public class CommitCommandMongoTest exte
 
     @Test
     public void mergePropertiesAndChildrenNoneExistedAndNewAdded() throws Exception {
-        List<Instruction> instructions = new LinkedList<Instruction>();
-        instructions.add(new AddNodeInstructionImpl("/", "a"));
-        instructions.add(new AddPropertyInstructionImpl("/a", "key1", "value1"));
-        instructions.add(new AddPropertyInstructionImpl("/a", "key2", "value2"));
-        instructions.add(new AddPropertyInstructionImpl("/a", "key3", "value3"));
-
-        Commit commit = new CommitImpl("/",
-                "+a : { \"key1\" : \"value1\" , \"key2\" : \"value2\" , \"key3\" : \"value3\" }",
-                "This is a simple commit", instructions);
+        Commit commit = CommitBuilder.build("/",
+                "+\"a\" : { \"key1\" : \"value1\" , \"key2\" : \"value2\" , \"key3\" : \"value3\" }",
+                "This is a simple commit");
         CommitCommandMongo command = new CommitCommandMongo(mongoConnection, commit);
         Long revisionId = command.execute();
 
@@ -297,27 +214,15 @@ public class CommitCommandMongoTest exte
 
     @Test
     public void mergePropertiesAndChildrenSomeExistedAndNewAdded() throws Exception {
-        List<Instruction> instructions = new LinkedList<Instruction>();
-        instructions.add(new AddNodeInstructionImpl("/", "a"));
-        instructions.add(new AddPropertyInstructionImpl("/a", "existed_key1", "value1"));
-        instructions.add(new AddPropertyInstructionImpl("/a", "existed_key2", "value2"));
-        instructions.add(new AddPropertyInstructionImpl("/a", "existed_key3", "value3"));
-
-        Commit commit = new CommitImpl("/",
-                "+a : { \"existed_key1\" : \"value1\" , \"existed_key2\" : \"value2\" , \"existed_key3\" : \"value3\" }",
-                "This is a simple commit", instructions);
+        Commit commit = CommitBuilder.build("/",
+                "+\"a\" : { \"existed_key1\" : \"value1\" , \"existed_key2\" : \"value2\" , \"existed_key3\" : \"value3\" }",
+                "This is a simple commit");
         CommitCommandMongo command = new CommitCommandMongo(mongoConnection, commit);
         Long revisionId = command.execute();
 
-        instructions = new LinkedList<Instruction>();
-        instructions.add(new AddNodeInstructionImpl("/", "a"));
-        instructions.add(new AddPropertyInstructionImpl("/a", "key1", "value1"));
-        instructions.add(new AddPropertyInstructionImpl("/a", "key2", "value2"));
-        instructions.add(new AddPropertyInstructionImpl("/a", "key3", "value3"));
-
-        commit = new CommitImpl("/",
-                "+a : { \"key1\" : \"value1\" , \"key2\" : \"value2\" , \"key3\" : \"value3\" }",
-                "This is a simple commit", instructions);
+        commit = CommitBuilder.build("/",
+                "+\"a\" : { \"key1\" : \"value1\" , \"key2\" : \"value2\" , \"key3\" : \"value3\" }",
+                "This is a simple commit");
         command = new CommitCommandMongo(mongoConnection, commit);
         revisionId = command.execute();
 
@@ -328,21 +233,12 @@ public class CommitCommandMongoTest exte
 
     @Test
     public void noOtherNodesTouched() throws Exception {
-        List<Instruction> instructions = new LinkedList<Instruction>();
-        instructions.add(new AddNodeInstructionImpl("/", "a"));
-        instructions.add(new AddNodeInstructionImpl("/", "b"));
-        instructions.add(new AddNodeInstructionImpl("/", "c"));
-
-        Commit commit = new CommitImpl("/", "+a : { b : {} , c : {} }",
-                "This is a simple commit", instructions);
+        Commit commit = CommitBuilder.build("/", "+\"a\" : {}" +
+                "\n+\"b\" : {}" + "\n+\"c\" : {}", "Simple commit");
         CommitCommandMongo command = new CommitCommandMongo(mongoConnection, commit);
         Long firstRevisionId = command.execute();
 
-        instructions = new LinkedList<Instruction>();
-        instructions.add(new AddNodeInstructionImpl("/a", "d"));
-        instructions.add(new AddNodeInstructionImpl("/a", "e"));
-
-        commit = new CommitImpl("/a", "+d: {} \n+e : {}", "This is a simple commit", instructions);
+        commit = CommitBuilder.build("/a", "+\"d\": {} \n+\"e\" : {}", "This is a simple commit");
         command = new CommitCommandMongo(mongoConnection, commit);
         Long secondRevisionId = command.execute();
 
@@ -363,23 +259,15 @@ public class CommitCommandMongoTest exte
 
     @Test
     public void removeNode() throws Exception {
-        List<Instruction> instructions = new LinkedList<Instruction>();
-        instructions.add(new AddNodeInstructionImpl("/", "a"));
-        instructions.add(new AddNodeInstructionImpl("/a", "b"));
-        instructions.add(new AddNodeInstructionImpl("/a", "c"));
-
-        Commit commit = new CommitImpl("/", "+a : { b : {} , c : {} }",
-                "Add a and its children", instructions);
+        Commit commit = CommitBuilder.build("/", "+\"a\" : { \"b\" : {} , \"c\" : {} }",
+                "Add a and its children");
         CommitCommandMongo command = new CommitCommandMongo(mongoConnection, commit);
         Long revisionId = command.execute();
         assertNotNull(revisionId);
         MongoAssert.assertNodesExist(NodeBuilder.build(String.format(
                 "{ \"/#%1$s\" : { \"a#%1$s\" : { \"b#%1$s\" : {} , \"c#%1$s\" : {} } } }", revisionId)));
 
-        instructions = new LinkedList<Instruction>();
-        instructions.add(new RemoveNodeInstructionImpl("/", "a"));
-
-        commit = new CommitImpl("/", "-a", "Remove a", instructions);
+        commit = CommitBuilder.build("/", "-\"a\"", "Remove a");
         command = new CommitCommandMongo(mongoConnection, commit);
         revisionId = command.execute();
         assertNotNull(revisionId);
@@ -392,18 +280,11 @@ public class CommitCommandMongoTest exte
 
     @Test
     public void removeNonExistentNode() throws Exception {
-        List<Instruction> instructions = new LinkedList<Instruction>();
-        instructions.add(new AddNodeInstructionImpl("/", "a"));
-        instructions.add(new AddNodeInstructionImpl("/a", "b"));
-
-        Commit commit = new CommitImpl("/", "+a : { b : {}  }", "Add nodes", instructions);
+        Commit commit = CommitBuilder.build("/", "+\"a\" : { \"b\" : {}  }", "Add nodes");
         CommitCommandMongo command = new CommitCommandMongo(mongoConnection, commit);
         command.execute();
 
-        instructions = new LinkedList<Instruction>();
-        instructions.add(new RemoveNodeInstructionImpl("/a", "c"));
-
-        commit = new CommitImpl("/a", "-c", "Non-existent node delete", instructions);
+        commit = CommitBuilder.build("/a", "-\"c\"", "Non-existent node delete");
         command = new CommitCommandMongo(mongoConnection, commit);
         try {
             command.execute();
@@ -415,11 +296,8 @@ public class CommitCommandMongoTest exte
 
     @Test
     public void rootNodeHasEmptyRootPath() throws Exception {
-        List<Instruction> instructions = new LinkedList<Instruction>();
-        instructions.add(new AddNodeInstructionImpl("", "/"));
-
-        Commit commit = new CommitImpl(MongoUtil.INITIAL_COMMIT_PATH, MongoUtil.INITIAL_COMMIT_DIFF,
-                MongoUtil.INITIAL_COMMIT_MESSAGE, instructions);
+        Commit commit = CommitBuilder.build(MongoUtil.INITIAL_COMMIT_PATH, MongoUtil.INITIAL_COMMIT_DIFF,
+                MongoUtil.INITIAL_COMMIT_MESSAGE);
         CommitCommandMongo command = new CommitCommandMongo(mongoConnection, commit);
         Long revisionId = command.execute();
         assertNotNull(revisionId);

Modified: jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/command/ConcurrentCommitCommandMongoTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/command/ConcurrentCommitCommandMongoTest.java?rev=1392274&r1=1392273&r2=1392274&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/command/ConcurrentCommitCommandMongoTest.java (original)
+++ jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/command/ConcurrentCommitCommandMongoTest.java Mon Oct  1 10:48:43 2012
@@ -30,6 +30,7 @@ import org.apache.jackrabbit.mongomk.api
 import org.apache.jackrabbit.mongomk.api.model.Commit;
 import org.apache.jackrabbit.mongomk.api.model.Instruction;
 import org.apache.jackrabbit.mongomk.api.model.Node;
+import org.apache.jackrabbit.mongomk.impl.builder.CommitBuilder;
 import org.apache.jackrabbit.mongomk.impl.command.CommandExecutorImpl;
 import org.apache.jackrabbit.mongomk.impl.model.AddNodeInstructionImpl;
 import org.apache.jackrabbit.mongomk.impl.model.CommitImpl;
@@ -50,10 +51,8 @@ public class ConcurrentCommitCommandMong
         // create the commands
         List<CommitCommandMongo> commands = new ArrayList<CommitCommandMongo>(numOfConcurrentThreads);
         for (int i = 0; i < numOfConcurrentThreads; ++i) {
-            List<Instruction> instructions = new LinkedList<Instruction>();
-            instructions.add(new AddNodeInstructionImpl("/", String.valueOf(i)));
-            Commit commit = new CommitImpl("/", "+" + i + " : {}",
-                    "This is a concurrent commit", instructions);
+            Commit commit = CommitBuilder.build("/", "+\"" + i + "\" : {}",
+                    "This is a concurrent commit");
             CommitCommandMongo command = new CommitCommandMongo(mongoConnection, commit) {
                 @Override
                 protected boolean saveAndSetHeadRevision() throws Exception {

Modified: jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/command/NodeExistsCommandMongoTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/command/NodeExistsCommandMongoTest.java?rev=1392274&r1=1392273&r2=1392274&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/command/NodeExistsCommandMongoTest.java (original)
+++ jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/command/NodeExistsCommandMongoTest.java Mon Oct  1 10:48:43 2012
@@ -20,15 +20,9 @@ import static org.junit.Assert.assertFal
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
-import java.util.LinkedList;
-import java.util.List;
-
 import org.apache.jackrabbit.mongomk.BaseMongoTest;
 import org.apache.jackrabbit.mongomk.api.model.Commit;
-import org.apache.jackrabbit.mongomk.api.model.Instruction;
-import org.apache.jackrabbit.mongomk.impl.model.AddNodeInstructionImpl;
-import org.apache.jackrabbit.mongomk.impl.model.CommitImpl;
-import org.apache.jackrabbit.mongomk.impl.model.RemoveNodeInstructionImpl;
+import org.apache.jackrabbit.mongomk.impl.builder.CommitBuilder;
 import org.apache.jackrabbit.mongomk.scenario.SimpleNodeScenario;
 import org.junit.Test;
 
@@ -111,22 +105,12 @@ public class NodeExistsCommandMongoTest 
 
     @Test
     public void grandParentDelete() throws Exception {
-        // Add a->b->c->d.
-        List<Instruction> instructions = new LinkedList<Instruction>();
-        instructions.add(new AddNodeInstructionImpl("/", "a"));
-        instructions.add(new AddNodeInstructionImpl("/a", "b"));
-        instructions.add(new AddNodeInstructionImpl("/a/b", "c"));
-        instructions.add(new AddNodeInstructionImpl("/a/b/c", "d"));
-
-        Commit commit = new CommitImpl("/", "TODO", "Add nodes", instructions);
-        CommitCommandMongo command = new CommitCommandMongo(mongoConnection,
-                commit);
+        Commit commit = CommitBuilder.build("/", "+\"a\" : { \"b\" : { \"c\" : { \"d\" : {} } } }",
+                "Add /a/b/c/d");
+        CommitCommandMongo command = new CommitCommandMongo(mongoConnection, commit);
         command.execute();
 
-        // Remove b.
-        instructions = new LinkedList<Instruction>();
-        instructions.add(new RemoveNodeInstructionImpl("/a", "b"));
-        commit = new CommitImpl("/a", "-b", "Delete /b", instructions);
+        commit = CommitBuilder.build("/a", "-\"b\"", "Remove /b");
         command = new CommitCommandMongo(mongoConnection, commit);
         command.execute();
 
@@ -139,23 +123,12 @@ public class NodeExistsCommandMongoTest 
 
     @Test
     public void existsInHeadRevision() throws Exception {
-
-        List<Instruction> instructions = new LinkedList<Instruction>();
-
-        // Add /a
-        instructions.add(new AddNodeInstructionImpl("/", "a"));
-        Commit commit1 = new CommitImpl("/", "+a : {}", "Add node a",
-                instructions);
-        CommitCommandMongo command = new CommitCommandMongo(mongoConnection,
-                commit1);
+        Commit commit = CommitBuilder.build("/", "+\"a\" : {}", "Add /a");
+        CommitCommandMongo command = new CommitCommandMongo(mongoConnection, commit);
         command.execute();
 
-        // Add /a/b
-        instructions = new LinkedList<Instruction>();
-        instructions.add(new AddNodeInstructionImpl("/a", "b"));
-        Commit commit2 = new CommitImpl("/a", "+b : {}", "Add node a/b",
-                instructions);
-        command = new CommitCommandMongo(mongoConnection, commit2);
+        commit = CommitBuilder.build("/a", "+\"b\" : {}", "Add /a/b");
+        command = new CommitCommandMongo(mongoConnection, commit);
         command.execute();
 
         // Verify /a is visible in the head revision

Modified: jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/query/FetchNodesByPathAndDepthQueryTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/query/FetchNodesByPathAndDepthQueryTest.java?rev=1392274&r1=1392273&r2=1392274&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/query/FetchNodesByPathAndDepthQueryTest.java (original)
+++ jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/query/FetchNodesByPathAndDepthQueryTest.java Mon Oct  1 10:48:43 2012
@@ -16,19 +16,16 @@
  */
 package org.apache.jackrabbit.mongomk.query;
 
-import java.util.LinkedList;
 import java.util.List;
 import java.util.Set;
 
 import org.apache.jackrabbit.mongomk.BaseMongoTest;
 import org.apache.jackrabbit.mongomk.api.model.Commit;
-import org.apache.jackrabbit.mongomk.api.model.Instruction;
 import org.apache.jackrabbit.mongomk.api.model.Node;
 import org.apache.jackrabbit.mongomk.command.CommitCommandMongo;
 import org.apache.jackrabbit.mongomk.impl.NodeAssert;
+import org.apache.jackrabbit.mongomk.impl.builder.CommitBuilder;
 import org.apache.jackrabbit.mongomk.impl.builder.NodeBuilder;
-import org.apache.jackrabbit.mongomk.impl.model.AddNodeInstructionImpl;
-import org.apache.jackrabbit.mongomk.impl.model.CommitImpl;
 import org.apache.jackrabbit.mongomk.model.CommitMongo;
 import org.apache.jackrabbit.mongomk.model.NodeMongo;
 import org.apache.jackrabbit.mongomk.scenario.SimpleNodeScenario;
@@ -176,9 +173,7 @@ public class FetchNodesByPathAndDepthQue
     }
 
     private Long addNode(String nodeName) throws Exception {
-        List<Instruction> instructions = new LinkedList<Instruction>();
-        instructions.add(new AddNodeInstructionImpl("/", nodeName));
-        Commit commit = new CommitImpl("/", "+" + nodeName, "Add /" + nodeName, instructions);
+        Commit commit = CommitBuilder.build("/", "+\"" + nodeName + "\" : {}", "Add /" + nodeName);
         CommitCommandMongo command = new CommitCommandMongo(mongoConnection, commit);
         return command.execute();
     }

Modified: jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/query/FetchNodesForRevisionQueryTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/query/FetchNodesForRevisionQueryTest.java?rev=1392274&r1=1392273&r2=1392274&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/query/FetchNodesForRevisionQueryTest.java (original)
+++ jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/query/FetchNodesForRevisionQueryTest.java Mon Oct  1 10:48:43 2012
@@ -26,6 +26,7 @@ import org.apache.jackrabbit.mongomk.api
 import org.apache.jackrabbit.mongomk.api.model.Node;
 import org.apache.jackrabbit.mongomk.command.CommitCommandMongo;
 import org.apache.jackrabbit.mongomk.impl.NodeAssert;
+import org.apache.jackrabbit.mongomk.impl.builder.CommitBuilder;
 import org.apache.jackrabbit.mongomk.impl.builder.NodeBuilder;
 import org.apache.jackrabbit.mongomk.impl.model.AddNodeInstructionImpl;
 import org.apache.jackrabbit.mongomk.impl.model.CommitImpl;
@@ -157,9 +158,7 @@ public class FetchNodesForRevisionQueryT
     }
 
     private Long addNode(String nodeName) throws Exception {
-        List<Instruction> instructions = new LinkedList<Instruction>();
-        instructions.add(new AddNodeInstructionImpl("/", nodeName));
-        Commit commit = new CommitImpl("/", "+" + nodeName, "Add /" + nodeName, instructions);
+        Commit commit = CommitBuilder.build("/", "+\"" + nodeName + "\" : {}", "Add /" + nodeName);
         CommitCommandMongo command = new CommitCommandMongo(mongoConnection, commit);
         return command.execute();
     }

Modified: jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/query/FetchValidCommitsQueryTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/query/FetchValidCommitsQueryTest.java?rev=1392274&r1=1392273&r2=1392274&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/query/FetchValidCommitsQueryTest.java (original)
+++ jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/query/FetchValidCommitsQueryTest.java Mon Oct  1 10:48:43 2012
@@ -27,7 +27,6 @@ import org.apache.jackrabbit.mongomk.que
 import org.apache.jackrabbit.mongomk.scenario.SimpleNodeScenario;
 import org.junit.Test;
 
-
 public class FetchValidCommitsQueryTest extends BaseMongoTest {
 
     private static final int MIN_COMMITS = 1;

Modified: jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/scenario/SimpleNodeScenario.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/scenario/SimpleNodeScenario.java?rev=1392274&r1=1392273&r2=1392274&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/scenario/SimpleNodeScenario.java (original)
+++ jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/scenario/SimpleNodeScenario.java Mon Oct  1 10:48:43 2012
@@ -23,10 +23,9 @@ import org.apache.jackrabbit.mongomk.api
 import org.apache.jackrabbit.mongomk.api.model.Instruction;
 import org.apache.jackrabbit.mongomk.command.CommitCommandMongo;
 import org.apache.jackrabbit.mongomk.impl.MongoConnection;
+import org.apache.jackrabbit.mongomk.impl.builder.CommitBuilder;
 import org.apache.jackrabbit.mongomk.impl.model.AddNodeInstructionImpl;
 import org.apache.jackrabbit.mongomk.impl.model.AddPropertyInstructionImpl;
-import org.apache.jackrabbit.mongomk.impl.model.CommitImpl;
-import org.apache.jackrabbit.mongomk.impl.model.RemoveNodeInstructionImpl;
 
 /**
  * Creates a defined scenario in {@code MongoDB}.
@@ -57,17 +56,9 @@ public class SimpleNodeScenario {
      * @throws Exception If an error occurred.
      */
     public Long create() throws Exception {
-        List<Instruction> instructions = new LinkedList<Instruction>();
-        instructions.add(new AddNodeInstructionImpl("/", "a"));
-        instructions.add(new AddNodeInstructionImpl("/a", "b"));
-        instructions.add(new AddNodeInstructionImpl("/a", "c"));
-        instructions.add(new AddPropertyInstructionImpl("/a", "int", 1));
-        instructions.add(new AddPropertyInstructionImpl("/a/b", "string", "foo"));
-        instructions.add(new AddPropertyInstructionImpl("/a/c", "bool", true));
-
-        Commit commit = new CommitImpl("/",
-                "+a : { \"int\" : 1 , \"b\" : { \"string\" : \"foo\" } , \"c\" : { \"bool\" : true } } }",
-                "This is the simple node scenario with nodes /, /a, /a/b, /a/c", instructions);
+        Commit commit = CommitBuilder.build("/",
+                "+\"a\" : { \"int\" : 1 , \"b\" : { \"string\" : \"foo\" } , \"c\" : { \"bool\" : true } }",
+                "This is the simple node scenario with nodes /, /a, /a/b, /a/c");
         CommitCommandMongo command = new CommitCommandMongo(mongoConnection, commit);
         return command.execute();
     }
@@ -75,9 +66,7 @@ public class SimpleNodeScenario {
     public Long addChildrenToA(int count) throws Exception {
         Long revisionId = null;
         for (int i = 1; i <= count; i++) {
-            List<Instruction> instructions = new LinkedList<Instruction>();
-            instructions.add(new AddNodeInstructionImpl("/a", "child" + i));
-            Commit commit = new CommitImpl("/a", "TODO", "Add child" + i, instructions);
+            Commit commit = CommitBuilder.build("/a", "+\"child" + i + "\" : {}", "Add child" + i);
             CommitCommandMongo command = new CommitCommandMongo(mongoConnection, commit);
             revisionId = command.execute();
         }
@@ -85,20 +74,13 @@ public class SimpleNodeScenario {
     }
 
     public Long delete_A() throws Exception {
-        List<Instruction> instructions = new LinkedList<Instruction>();
-        instructions.add(new RemoveNodeInstructionImpl("/", "a"));
-
-        Commit commit = new CommitImpl("/", "-a", "This is a commit with deleted /a",
-                instructions);
+        Commit commit = CommitBuilder.build("/", "-\"a\"", "This is a commit with deleted /a");
         CommitCommandMongo command = new CommitCommandMongo(mongoConnection, commit);
         return command.execute();
     }
 
     public Long delete_B() throws Exception {
-        List<Instruction> instructions = new LinkedList<Instruction>();
-        instructions.add(new RemoveNodeInstructionImpl("/a", "b"));
-        Commit commit = new CommitImpl("/a", "-b", "This is a commit with deleted /a/b",
-                instructions);
+        Commit commit = CommitBuilder.build("/a", "-\"b\"", "This is a commit with deleted /a/b");
         CommitCommandMongo command = new CommitCommandMongo(mongoConnection, commit);
         return command.execute();
     }
@@ -112,8 +94,15 @@ public class SimpleNodeScenario {
         instructions.add(new AddPropertyInstructionImpl("/a/b/e", "array", new Object[] { 123, null, 123.456D,
                 "for:bar", Boolean.TRUE }));
 
-        Commit commit = new CommitImpl("", "TODO", "This is a commit with updated /a and added /a/d and /a/b/e",
-                instructions);
+        StringBuilder diff = new StringBuilder();
+        diff.append("+\"a/d\" : {}");
+        diff.append("+\"a/b/e\" : {}");
+        diff.append("+\"a/double\" : 0.123");
+        diff.append("+\"a/d/null\" :  null");
+        diff.append("+\"a/b/e/array\" : [ 123, null, 123.456, \"for:bar\", true ]");
+        Commit commit = CommitBuilder.build("/", diff.toString(),
+                "This is a commit with updated /a and added /a/d and /a/b/e");
+
         CommitCommandMongo command = new CommitCommandMongo(mongoConnection, commit);
         return command.execute();
     }