From 1eece2559a6cf16f5732d128c1cb6e43c5f60fbc Mon Sep 17 00:00:00 2001 From: Benjamin Paassen Date: Fri, 9 Jan 2015 15:28:13 +0100 Subject: Refactored building convenience methods to TestDocumentBuilder, added error logging and changed TestDocument and TestAdvanced as well as all users of those files accordingly. --- test/core/model/TestDocument.hpp | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'test/core/model/TestDocument.hpp') diff --git a/test/core/model/TestDocument.hpp b/test/core/model/TestDocument.hpp index 6b0267a..eaec42c 100644 --- a/test/core/model/TestDocument.hpp +++ b/test/core/model/TestDocument.hpp @@ -23,6 +23,8 @@ #include #include +#include "TestDocumentBuilder.hpp" + namespace ousia { namespace model { @@ -30,57 +32,58 @@ namespace model { * This constructs a fairly simple test document for the "book" domain. The * structure of the document can be seen in the Code below. */ -static Rooted constructBookDocument(Manager &mgr, +static Rooted constructBookDocument(Manager &mgr, Logger &logger, Rooted bookDomain) { // Start with the (empty) document. Rooted doc{new Document(mgr, "myDoc.oxd")}; + doc->addDomain(bookDomain); // Add the root. Rooted root = - StructuredEntity::buildRootEntity(doc, {bookDomain}, "book"); + buildRootStructuredEntity(doc, logger, {"book"}); if (root.isNull()) { return {nullptr}; } // Add a paragraph. Rooted foreword = - StructuredEntity::buildEntity(root, {bookDomain}, "paragraph"); + buildStructuredEntity(doc, logger, root, {"paragraph"}); if (foreword.isNull()) { return {nullptr}; } // Add its text. Rooted foreword_text = - StructuredEntity::buildEntity(foreword, {bookDomain}, "text"); + buildStructuredEntity(doc, logger, foreword, {"text"}); if (foreword_text.isNull()) { return {nullptr}; } // And its primitive content Variant text{"Some introductory text"}; Rooted foreword_primitive = - DocumentPrimitive::buildEntity(foreword_text, text, "content"); + buildPrimitiveEntity(logger, foreword_text, text, "content"); if (foreword_primitive.isNull()) { return {nullptr}; } // Add a section. Rooted section = - StructuredEntity::buildEntity(root, {bookDomain}, "section"); + buildStructuredEntity(doc, logger, root, {"section"}); // Add a paragraph for it. Rooted main = - StructuredEntity::buildEntity(section, {bookDomain}, "paragraph"); + buildStructuredEntity(doc, logger, section, {"paragraph"}); if (main.isNull()) { return {nullptr}; } // Add its text. Rooted main_text = - StructuredEntity::buildEntity(main, {bookDomain}, "text"); + buildStructuredEntity(doc, logger, main, {"text"}); if (main_text.isNull()) { return {nullptr}; } // And its primitive content text = Variant{"Some actual text"}; Rooted main_primitive = - DocumentPrimitive::buildEntity(main_text, text, "content"); + buildPrimitiveEntity(logger, main_text, text, "content"); if (main_primitive.isNull()) { return {nullptr}; } -- cgit v1.2.3