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);
CommitCommandMongo command = new CommitCommandMongo(mongoConnection, commit);
String revisionId = command.execute();
Assert.assertNotNull(revisionId);
MongoAssert
.assertNodesExist(
"",
NodeBuilder.build(String
.format("{ \"/#%1$s\" : { \"a#%1$s\" : { \"int\" : 1 , \"key1\" : \"value1\", \"b#%1$s\" : { \"string\" : \"foo\" , \"key2\" : \"value2\" } , \"c#%1$s\" : { \"bool\" : true , \"key3\" : \"value3\" } } } }",
revisionId)));
MongoAssert.assertCommitExists(commit);
// MongoAssert.assertCommitContainsAffectedPaths(commit.getRevisionId(), "/a", "/a/b", "/a/c"); TODO think about
// whether / should really be included since it already contained /a
MongoAssert.assertCommitContainsAffectedPaths(commit.getRevisionId(), "/", "/a", "/a/b", "/a/c");
}