}
@Test
@FixFor( "MODE-1978" )
public void shouldAllowRemovingArtifactWithNoExistingTrash() throws Exception {
JcrTools tools = new JcrTools();
// print = true;
// Register the node types ...
registerNodeTypes("cnd/sramp.cnd");
UUID uuid = UUID.randomUUID();
Node artifacts = tools.findOrCreateNode(session, "/sramp/artifacts", "nt:folder");
session.save();
Node artifact = artifacts.addNode(uuid.toString(), "sramp:nonDocumentArtifactType");
printMessage("Added artifact node: " + artifact);
artifact.addMixin("sramp:xsdDocument");
artifact.setProperty("sramp:uuid", uuid.toString());
Node artifactChild = artifact.addNode("child", "sramp:derivedArtifactPrimaryType");
printMessage("Added child node: " + artifactChild);
artifactChild.addMixin("sramp:elementDeclaration");
artifactChild.setProperty("sramp:uuid", UUID.randomUUID().toString());
session.save();
// Now "remove" it by removing the doc type mixins, adding the "deleted" mixin, and moving it to a different area ...
artifact.addMixin("sramp:deletedArtifact");
artifact.removeMixin("sramp:xsdDocument");
artifactChild.addMixin("sramp:deletedArtifact");
artifactChild.removeMixin("sramp:elementDeclaration");
String srcPath = artifact.getPath();
String trashPath = srcPath.replace("sramp", "sramp-trash");
String parentSrcPath = artifacts.getPath();
String parentTrashPath = parentSrcPath.replace("sramp", "sramp-trash");
Node artifactTrash = tools.findOrCreateNode(session, parentTrashPath, "nt:folder");
print(artifactTrash);
session.move(srcPath, trashPath);
session.save();
}