diff options
Diffstat (limited to 'test/core')
-rw-r--r-- | test/core/RegistryTest.cpp | 4 | ||||
-rw-r--r-- | test/core/frontend/TerminalLoggerTest.cpp | 4 | ||||
-rw-r--r-- | test/core/model/DocumentTest.cpp | 42 | ||||
-rw-r--r-- | test/core/model/OntologyTest.cpp (renamed from test/core/model/DomainTest.cpp) | 260 | ||||
-rw-r--r-- | test/core/model/TestAdvanced.hpp | 68 | ||||
-rw-r--r-- | test/core/model/TestDocument.hpp | 8 | ||||
-rw-r--r-- | test/core/model/TestDocumentBuilder.hpp | 12 | ||||
-rw-r--r-- | test/core/model/TestOntology.hpp (renamed from test/core/model/TestDomain.hpp) | 24 | ||||
-rw-r--r-- | test/core/resource/ResourceRequestTest.cpp | 52 |
9 files changed, 237 insertions, 237 deletions
diff --git a/test/core/RegistryTest.cpp b/test/core/RegistryTest.cpp index 4e8fc6a..b557169 100644 --- a/test/core/RegistryTest.cpp +++ b/test/core/RegistryTest.cpp @@ -100,9 +100,9 @@ TEST(Registry, locateResource) Resource res; ASSERT_TRUE( - registry.locateResource(res, "path", ResourceType::DOMAIN_DESC)); + registry.locateResource(res, "path", ResourceType::ONTOLOGY)); ASSERT_TRUE(res.isValid()); - ASSERT_EQ(ResourceType::DOMAIN_DESC, res.getType()); + ASSERT_EQ(ResourceType::ONTOLOGY, res.getType()); ASSERT_EQ("path", res.getLocation()); } } diff --git a/test/core/frontend/TerminalLoggerTest.cpp b/test/core/frontend/TerminalLoggerTest.cpp index 99e8f29..acc379d 100644 --- a/test/core/frontend/TerminalLoggerTest.cpp +++ b/test/core/frontend/TerminalLoggerTest.cpp @@ -35,8 +35,8 @@ struct Pos { }; static const std::string testStr = - "\\link[domain]{book}\n" // 1 - "\\link[domain]{meta}\n" // 2 + "\\link[ontology]{book}\n" // 1 + "\\link[ontology]{meta}\n" // 2 "\n" // 3 "\\meta{\n" // 4 "\t\\title{The Adventures Of Tom Sawyer}\n" // 5 diff --git a/test/core/model/DocumentTest.cpp b/test/core/model/DocumentTest.cpp index 1bb2356..8ed59f5 100644 --- a/test/core/model/DocumentTest.cpp +++ b/test/core/model/DocumentTest.cpp @@ -23,10 +23,10 @@ #include <core/common/Rtti.hpp> #include <core/frontend/TerminalLogger.hpp> #include <core/model/Document.hpp> -#include <core/model/Domain.hpp> +#include <core/model/Ontology.hpp> #include "TestDocument.hpp" -#include "TestDomain.hpp" +#include "TestOntology.hpp" namespace ousia { @@ -36,10 +36,10 @@ TEST(Document, construct) TerminalLogger logger{std::cerr, true}; Manager mgr{1}; Rooted<SystemTypesystem> sys{new SystemTypesystem(mgr)}; - // Get the domain. - Rooted<Domain> domain = constructBookDomain(mgr, sys, logger); + // Get the ontology. + Rooted<Ontology> ontology = constructBookOntology(mgr, sys, logger); // Construct the document. - Rooted<Document> doc = constructBookDocument(mgr, logger, domain); + Rooted<Document> doc = constructBookDocument(mgr, logger, ontology); // Check the document content. ASSERT_FALSE(doc.isNull()); @@ -111,22 +111,22 @@ TEST(Document, construct) TEST(Document, validate) { - // Let's start with a trivial domain and a trivial document. + // Let's start with a trivial ontology and a trivial document. TerminalLogger logger{std::cerr, true}; Manager mgr{1}; Rooted<SystemTypesystem> sys{new SystemTypesystem(mgr)}; - Rooted<Domain> domain{new Domain(mgr, sys, "trivial")}; + Rooted<Ontology> ontology{new Ontology(mgr, sys, "trivial")}; Cardinality single; single.merge({1}); // Set up the "root" StructuredClass. Rooted<StructuredClass> rootClass{new StructuredClass( - mgr, "root", domain, single, {nullptr}, false, true)}; + mgr, "root", ontology, single, {nullptr}, false, true)}; // set up a document for it. { // first an invalid one, which is empty. Rooted<Document> doc{new Document(mgr, "myDoc.oxd")}; - doc->referenceDomain(domain); + doc->referenceOntology(ontology); ASSERT_EQ(ValidationState::UNKNOWN, doc->getValidationState()); ASSERT_FALSE(doc->validate(logger)); // then add a root, which should make it valid. @@ -138,7 +138,7 @@ TEST(Document, validate) { // A root with an invalid name, however, should make it invalid Rooted<Document> doc{new Document(mgr, "myDoc.oxd")}; - doc->referenceDomain(domain); + doc->referenceOntology(ontology); Rooted<StructuredEntity> root = buildRootStructuredEntity( doc, logger, {"root"}, {}, "my invalid root"); ASSERT_EQ(ValidationState::UNKNOWN, doc->getValidationState()); @@ -150,7 +150,7 @@ TEST(Document, validate) rootClass->createFieldDescriptor(logger).first; // and add a child class for it. Rooted<StructuredClass> childClass{ - new StructuredClass(mgr, "child", domain, single)}; + new StructuredClass(mgr, "child", ontology, single)}; rootField->addChild(childClass); { /* @@ -158,7 +158,7 @@ TEST(Document, validate) * document should be invalid again. */ Rooted<Document> doc{new Document(mgr, "myDoc.oxd")}; - doc->referenceDomain(domain); + doc->referenceOntology(ontology); Rooted<StructuredEntity> root = buildRootStructuredEntity(doc, logger, {"root"}); ASSERT_EQ(ValidationState::UNKNOWN, doc->getValidationState()); @@ -173,16 +173,16 @@ TEST(Document, validate) ASSERT_FALSE(doc->validate(logger)); } /* - * Add a further extension to the domain: We add a subclass to child. + * Add a further extension to the ontology: We add a subclass to child. */ Rooted<StructuredClass> childSubClass{ - new StructuredClass(mgr, "childSub", domain, single, childClass)}; + new StructuredClass(mgr, "childSub", ontology, single, childClass)}; { /* * A document with one instance of the Child subclass should be valid. */ Rooted<Document> doc{new Document(mgr, "myDoc.oxd")}; - doc->referenceDomain(domain); + doc->referenceOntology(ontology); Rooted<StructuredEntity> root = buildRootStructuredEntity(doc, logger, {"root"}); buildStructuredEntity(doc, logger, root, {"childSub"}); @@ -202,7 +202,7 @@ TEST(Document, validate) * invalid, because it has no children of itself. */ Rooted<Document> doc{new Document(mgr, "myDoc.oxd")}; - doc->referenceDomain(domain); + doc->referenceOntology(ontology); Rooted<StructuredEntity> root = buildRootStructuredEntity(doc, logger, {"root"}); buildStructuredEntity(doc, logger, root, {"childSub"}); @@ -223,7 +223,7 @@ TEST(Document, validate) * valid, because of the override. */ Rooted<Document> doc{new Document(mgr, "myDoc.oxd")}; - doc->referenceDomain(domain); + doc->referenceOntology(ontology); Rooted<StructuredEntity> root = buildRootStructuredEntity(doc, logger, {"root"}); buildStructuredEntity(doc, logger, root, {"childSub"}); @@ -241,7 +241,7 @@ TEST(Document, validate) * invalid again, because we are missing the primitive content. */ Rooted<Document> doc{new Document(mgr, "myDoc.oxd")}; - doc->referenceDomain(domain); + doc->referenceOntology(ontology); Rooted<StructuredEntity> root = buildRootStructuredEntity(doc, logger, {"root"}); Rooted<StructuredEntity> child = @@ -259,14 +259,14 @@ TEST(Document, validate) ASSERT_TRUE(doc->validate(logger)); } - // Now add an Annotation class to the domain. - Rooted<AnnotationClass> annoClass{new AnnotationClass(mgr, "anno", domain)}; + // Now add an Annotation class to the ontology. + Rooted<AnnotationClass> annoClass{new AnnotationClass(mgr, "anno", ontology)}; { /* * Create a valid document in itself. */ Rooted<Document> doc{new Document(mgr, "myDoc.oxd")}; - doc->referenceDomain(domain); + doc->referenceOntology(ontology); Rooted<StructuredEntity> root = buildRootStructuredEntity(doc, logger, {"root"}); Rooted<Anchor> start{new Anchor(mgr, root)}; diff --git a/test/core/model/DomainTest.cpp b/test/core/model/OntologyTest.cpp index 6bbf26d..764dcb4 100644 --- a/test/core/model/DomainTest.cpp +++ b/test/core/model/OntologyTest.cpp @@ -22,9 +22,9 @@ #include <core/common/Rtti.hpp> #include <core/frontend/TerminalLogger.hpp> -#include <core/model/Domain.hpp> +#include <core/model/Ontology.hpp> -#include "TestDomain.hpp" +#include "TestOntology.hpp" namespace ousia { @@ -38,45 +38,45 @@ void assert_path(const ResolutionResult &res, const Rtti *expected_type, ASSERT_EQ(expected_path, res.node->path()); } -TEST(Domain, testDomainResolving) +TEST(Ontology, testOntologyResolving) { // Construct Manager Logger logger; Manager mgr{1}; Rooted<SystemTypesystem> sys{new SystemTypesystem(mgr)}; - // Get the domain. - Rooted<Domain> domain = constructBookDomain(mgr, sys, logger); + // Get the ontology. + Rooted<Ontology> ontology = constructBookOntology(mgr, sys, logger); std::vector<ResolutionResult> res; - // There is one domain called "book" - res = domain->resolve(&RttiTypes::Domain, "book"); + // There is one ontology called "book" + res = ontology->resolve(&RttiTypes::Ontology, "book"); ASSERT_EQ(1U, res.size()); - assert_path(res[0], &RttiTypes::Domain, {"book"}); + assert_path(res[0], &RttiTypes::Ontology, {"book"}); - // There is one domain called "book" - res = domain->resolve(&RttiTypes::StructuredClass, "book"); + // There is one ontology called "book" + res = ontology->resolve(&RttiTypes::StructuredClass, "book"); ASSERT_EQ(1U, res.size()); assert_path(res[0], &RttiTypes::StructuredClass, {"book", "book"}); // If we explicitly ask for the "book, book" path, then only the // StructuredClass should be returned. - res = domain->resolve(&RttiTypes::Domain, + res = ontology->resolve(&RttiTypes::Ontology, std::vector<std::string>{"book", "book"}); ASSERT_EQ(0U, res.size()); - res = domain->resolve(&RttiTypes::StructuredClass, + res = ontology->resolve(&RttiTypes::StructuredClass, std::vector<std::string>{"book", "book"}); ASSERT_EQ(1U, res.size()); // If we ask for "section" the result should be unique as well. - res = domain->resolve(&RttiTypes::StructuredClass, "section"); + res = ontology->resolve(&RttiTypes::StructuredClass, "section"); ASSERT_EQ(1U, res.size()); assert_path(res[0], &RttiTypes::StructuredClass, {"book", "section"}); - // If we ask for "paragraph" it is referenced two times in the Domain graph, + // If we ask for "paragraph" it is referenced two times in the Ontology graph, // but should be returned only once. - res = domain->resolve(&RttiTypes::StructuredClass, "paragraph"); + res = ontology->resolve(&RttiTypes::StructuredClass, "paragraph"); ASSERT_EQ(1U, res.size()); assert_path(res[0], &RttiTypes::StructuredClass, {"book", "paragraph"}); } @@ -115,10 +115,10 @@ TEST(StructuredClass, getFieldDescriptors) TerminalLogger logger{std::cout}; Manager mgr{1}; Rooted<SystemTypesystem> sys{new SystemTypesystem(mgr)}; - Rooted<Domain> domain{new Domain(mgr, sys, "myDomain")}; + Rooted<Ontology> ontology{new Ontology(mgr, sys, "myOntology")}; Rooted<StructuredClass> A{new StructuredClass( - mgr, "A", domain, Cardinality::any(), nullptr, false, true)}; + mgr, "A", ontology, Cardinality::any(), nullptr, false, true)}; Rooted<FieldDescriptor> A_a = createUnsortedPrimitiveField( A, sys->getStringType(), logger, false, "a"); Rooted<FieldDescriptor> A_b = createUnsortedPrimitiveField( @@ -127,7 +127,7 @@ TEST(StructuredClass, getFieldDescriptors) A, sys->getStringType(), logger, true, "somename"); Rooted<StructuredClass> B{new StructuredClass( - mgr, "B", domain, Cardinality::any(), A, false, true)}; + mgr, "B", ontology, Cardinality::any(), A, false, true)}; Rooted<FieldDescriptor> B_b = createUnsortedPrimitiveField( B, sys->getStringType(), logger, false, "b"); Rooted<FieldDescriptor> B_c = createUnsortedPrimitiveField( @@ -136,11 +136,11 @@ TEST(StructuredClass, getFieldDescriptors) B, sys->getStringType(), logger, true, "othername"); Rooted<StructuredClass> C{new StructuredClass( - mgr, "C", domain, Cardinality::any(), B, false, true)}; + mgr, "C", ontology, Cardinality::any(), B, false, true)}; Rooted<FieldDescriptor> C_a = createUnsortedPrimitiveField( C, sys->getStringType(), logger, false, "a"); - ASSERT_TRUE(domain->validate(logger)); + ASSERT_TRUE(ontology->validate(logger)); // check all FieldDescriptors { @@ -176,21 +176,21 @@ TEST(StructuredClass, getFieldDescriptorsCycles) Logger logger; Manager mgr{1}; Rooted<SystemTypesystem> sys{new SystemTypesystem(mgr)}; - Rooted<Domain> domain{new Domain(mgr, sys, "myDomain")}; + Rooted<Ontology> ontology{new Ontology(mgr, sys, "myOntology")}; Rooted<StructuredClass> A{new StructuredClass( - mgr, "A", domain, Cardinality::any(), nullptr, false, true)}; + mgr, "A", ontology, Cardinality::any(), nullptr, false, true)}; A->addSubclass(A, logger); Rooted<FieldDescriptor> A_a = createUnsortedPrimitiveField( A, sys->getStringType(), logger, false, "a"); - ASSERT_FALSE(domain->validate(logger)); + ASSERT_FALSE(ontology->validate(logger)); // if we call getFieldDescriptors that should still return a valid result. NodeVector<FieldDescriptor> fds = A->getFieldDescriptors(); ASSERT_EQ(1, fds.size()); ASSERT_EQ(A_a, fds[0]); } -Rooted<StructuredClass> getClass(const std::string name, Handle<Domain> dom) +Rooted<StructuredClass> getClass(const std::string name, Handle<Ontology> dom) { std::vector<ResolutionResult> res = dom->resolve(&RttiTypes::StructuredClass, name); @@ -199,23 +199,23 @@ Rooted<StructuredClass> getClass(const std::string name, Handle<Domain> dom) TEST(Descriptor, pathTo) { - // Start with some easy examples from the book domain. + // Start with some easy examples from the book ontology. TerminalLogger logger{std::cout}; Manager mgr{1}; Rooted<SystemTypesystem> sys{new SystemTypesystem(mgr)}; - // Get the domain. - Rooted<Domain> domain = constructBookDomain(mgr, sys, logger); + // Get the ontology. + Rooted<Ontology> ontology = constructBookOntology(mgr, sys, logger); // get the book node and the section node. - Rooted<StructuredClass> book = getClass("book", domain); - Rooted<StructuredClass> section = getClass("section", domain); + Rooted<StructuredClass> book = getClass("book", ontology); + Rooted<StructuredClass> section = getClass("section", ontology); // get the path in between. NodeVector<Node> path = book->pathTo(section, logger); ASSERT_EQ(1U, path.size()); ASSERT_TRUE(path[0]->isa(&RttiTypes::FieldDescriptor)); // get the text node. - Rooted<StructuredClass> text = getClass("text", domain); + Rooted<StructuredClass> text = getClass("text", ontology); // get the path between book and text via paragraph. path = book->pathTo(text, logger); ASSERT_EQ(3U, path.size()); @@ -225,7 +225,7 @@ TEST(Descriptor, pathTo) ASSERT_TRUE(path[2]->isa(&RttiTypes::FieldDescriptor)); // get the subsection node. - Rooted<StructuredClass> subsection = getClass("subsection", domain); + Rooted<StructuredClass> subsection = getClass("subsection", ontology); // try to get the path between book and subsection. path = book->pathTo(subsection, logger); // this should be impossible. @@ -247,7 +247,7 @@ TEST(Descriptor, pathTo) TEST(Descriptor, pathToAdvanced) { /* - * Now we build a really nasty domain with lots of transparency + * Now we build a really nasty ontology with lots of transparency * and inheritance. The basic idea is to have three paths from start to * finish, where one is blocked by overriding fields and the longer valid * one is found first such that it has to be replaced by the shorter one @@ -269,30 +269,30 @@ TEST(Descriptor, pathToAdvanced) Manager mgr{1}; TerminalLogger logger{std::cout}; Rooted<SystemTypesystem> sys{new SystemTypesystem(mgr)}; - // Construct the domain - Rooted<Domain> domain{new Domain(mgr, sys, "nasty")}; + // Construct the ontology + Rooted<Ontology> ontology{new Ontology(mgr, sys, "nasty")}; // Let's create the classes that we need first Rooted<StructuredClass> A{new StructuredClass( - mgr, "A", domain, Cardinality::any(), {nullptr}, false, true)}; + mgr, "A", ontology, Cardinality::any(), {nullptr}, false, true)}; Rooted<StructuredClass> start{new StructuredClass( - mgr, "start", domain, Cardinality::any(), A, false, false)}; + mgr, "start", ontology, Cardinality::any(), A, false, false)}; Rooted<StructuredClass> B{new StructuredClass( - mgr, "B", domain, Cardinality::any(), {nullptr}, true, false)}; + mgr, "B", ontology, Cardinality::any(), {nullptr}, true, false)}; Rooted<StructuredClass> C{new StructuredClass( - mgr, "C", domain, Cardinality::any(), B, true, false)}; + mgr, "C", ontology, Cardinality::any(), B, true, false)}; Rooted<StructuredClass> D{new StructuredClass( - mgr, "D", domain, Cardinality::any(), {nullptr}, true, false)}; + mgr, "D", ontology, Cardinality::any(), {nullptr}, true, false)}; Rooted<StructuredClass> E{new StructuredClass( - mgr, "E", domain, Cardinality::any(), {nullptr}, true, false)}; + mgr, "E", ontology, Cardinality::any(), {nullptr}, true, false)}; Rooted<StructuredClass> target{ - new StructuredClass(mgr, "target", domain, Cardinality::any())}; + new StructuredClass(mgr, "target", ontology, Cardinality::any())}; // We create a field for A Rooted<FieldDescriptor> A_field = A->createFieldDescriptor(logger).first; @@ -312,11 +312,11 @@ TEST(Descriptor, pathToAdvanced) Rooted<FieldDescriptor> E_field = E->createFieldDescriptor(logger).first; E_field->addChild(target); - ASSERT_TRUE(domain->validate(logger)); + ASSERT_TRUE(ontology->validate(logger)); #ifdef MANAGER_GRAPHVIZ_EXPORT // dump the manager state - mgr.exportGraphviz("nastyDomain.dot"); + mgr.exportGraphviz("nastyOntology.dot"); #endif // and now we should be able to find the shortest path as suggested @@ -332,18 +332,18 @@ TEST(Descriptor, pathToAdvanced) TEST(Descriptor, pathToCycles) { - // build a domain with a cycle. + // build a ontology with a cycle. Manager mgr{1}; Logger logger; Rooted<SystemTypesystem> sys{new SystemTypesystem(mgr)}; - // Construct the domain - Rooted<Domain> domain{new Domain(mgr, sys, "cycles")}; + // Construct the ontology + Rooted<Ontology> ontology{new Ontology(mgr, sys, "cycles")}; Rooted<StructuredClass> A{new StructuredClass( - mgr, "A", domain, Cardinality::any(), {nullptr}, true, true)}; + mgr, "A", ontology, Cardinality::any(), {nullptr}, true, true)}; A->addSubclass(A, logger); - ASSERT_FALSE(domain->validate(logger)); + ASSERT_FALSE(ontology->validate(logger)); Rooted<StructuredClass> B{new StructuredClass( - mgr, "B", domain, Cardinality::any(), {nullptr}, false, true)}; + mgr, "B", ontology, Cardinality::any(), {nullptr}, false, true)}; Rooted<FieldDescriptor> A_field = A->createFieldDescriptor(logger).first; A_field->addChild(B); /* @@ -360,16 +360,16 @@ TEST(Descriptor, pathToCycles) TEST(Descriptor, getDefaultFields) { - // construct a domain with lots of default fields to test. + // construct a ontology with lots of default fields to test. // start with a single structure class. Manager mgr{1}; TerminalLogger logger{std::cout}; Rooted<SystemTypesystem> sys{new SystemTypesystem(mgr)}; - // Construct the domain - Rooted<Domain> domain{new Domain(mgr, sys, "nasty")}; + // Construct the ontology + Rooted<Ontology> ontology{new Ontology(mgr, sys, "nasty")}; Rooted<StructuredClass> A{new StructuredClass( - mgr, "A", domain, Cardinality::any(), nullptr, false, true)}; + mgr, "A", ontology, Cardinality::any(), nullptr, false, true)}; // in this trivial case no field should be found. ASSERT_TRUE(A->getDefaultFields().empty()); @@ -385,7 +385,7 @@ TEST(Descriptor, getDefaultFields) // remove that field from A and add it to another class. Rooted<StructuredClass> B{new StructuredClass( - mgr, "B", domain, Cardinality::any(), nullptr, false, true)}; + mgr, "B", ontology, Cardinality::any(), nullptr, false, true)}; B->moveFieldDescriptor(A_prim_field, logger); @@ -405,7 +405,7 @@ TEST(Descriptor, getDefaultFields) // add a transparent child class. Rooted<StructuredClass> C{new StructuredClass( - mgr, "C", domain, Cardinality::any(), nullptr, true, false)}; + mgr, "C", ontology, Cardinality::any(), nullptr, true, false)}; A_field->addChild(C); // add a primitive field for it. @@ -420,14 +420,14 @@ TEST(Descriptor, getDefaultFields) // add another transparent child class to A with a daughter class that has // in turn a subclass with a primitive field. Rooted<StructuredClass> D{new StructuredClass( - mgr, "D", domain, Cardinality::any(), nullptr, true, false)}; + mgr, "D", ontology, Cardinality::any(), nullptr, true, false)}; A_field->addChild(D); Rooted<FieldDescriptor> D_field = D->createFieldDescriptor(logger).first; Rooted<StructuredClass> E{new StructuredClass( - mgr, "E", domain, Cardinality::any(), nullptr, true, false)}; + mgr, "E", ontology, Cardinality::any(), nullptr, true, false)}; D_field->addChild(E); Rooted<StructuredClass> F{new StructuredClass( - mgr, "E", domain, Cardinality::any(), E, true, false)}; + mgr, "E", ontology, Cardinality::any(), E, true, false)}; Rooted<FieldDescriptor> F_field = F->createPrimitiveFieldDescriptor(sys->getStringType(), logger).first; @@ -440,16 +440,16 @@ TEST(Descriptor, getDefaultFields) TEST(Descriptor, getDefaultFieldsCycles) { - // build a domain with a cycle. + // build a ontology with a cycle. Manager mgr{1}; Logger logger; Rooted<SystemTypesystem> sys{new SystemTypesystem(mgr)}; - // Construct the domain - Rooted<Domain> domain{new Domain(mgr, sys, "cycles")}; + // Construct the ontology + Rooted<Ontology> ontology{new Ontology(mgr, sys, "cycles")}; Rooted<StructuredClass> A{new StructuredClass( - mgr, "A", domain, Cardinality::any(), {nullptr}, true, true)}; + mgr, "A", ontology, Cardinality::any(), {nullptr}, true, true)}; A->addSubclass(A, logger); - ASSERT_FALSE(domain->validate(logger)); + ASSERT_FALSE(ontology->validate(logger)); Rooted<FieldDescriptor> A_field = A->createPrimitiveFieldDescriptor(sys->getStringType(), logger).first; /* @@ -463,17 +463,17 @@ TEST(Descriptor, getDefaultFieldsCycles) TEST(Descriptor, getPermittedChildren) { - // analyze the book domain. + // analyze the book ontology. TerminalLogger logger{std::cout}; Manager mgr{1}; Rooted<SystemTypesystem> sys{new SystemTypesystem(mgr)}; - // Get the domain. - Rooted<Domain> domain = constructBookDomain(mgr, sys, logger); + // Get the ontology. + Rooted<Ontology> ontology = constructBookOntology(mgr, sys, logger); // get the relevant classes. - Rooted<StructuredClass> book = getClass("book", domain); - Rooted<StructuredClass> section = getClass("section", domain); - Rooted<StructuredClass> paragraph = getClass("paragraph", domain); - Rooted<StructuredClass> text = getClass("text", domain); + Rooted<StructuredClass> book = getClass("book", ontology); + Rooted<StructuredClass> section = getClass("section", ontology); + Rooted<StructuredClass> paragraph = getClass("paragraph", ontology); + Rooted<StructuredClass> text = getClass("text", ontology); /* * as permitted children we expect section, paragraph and text in exactly * that order. section should be before paragraph because of declaration @@ -488,7 +488,7 @@ TEST(Descriptor, getPermittedChildren) // Now we add a subclass to text. Rooted<StructuredClass> sub{new StructuredClass( - mgr, "Subclass", domain, Cardinality::any(), text, true, false)}; + mgr, "Subclass", ontology, Cardinality::any(), text, true, false)}; // And that should be in the result list as well now. children = book->getPermittedChildren(); ASSERT_EQ(4U, children.size()); @@ -500,16 +500,16 @@ TEST(Descriptor, getPermittedChildren) TEST(Descriptor, getPermittedChildrenCycles) { - // build a domain with a cycle. + // build a ontology with a cycle. Manager mgr{1}; Logger logger; Rooted<SystemTypesystem> sys{new SystemTypesystem(mgr)}; - // Construct the domain - Rooted<Domain> domain{new Domain(mgr, sys, "cycles")}; + // Construct the ontology + Rooted<Ontology> ontology{new Ontology(mgr, sys, "cycles")}; Rooted<StructuredClass> A{new StructuredClass( - mgr, "A", domain, Cardinality::any(), {nullptr}, true, true)}; + mgr, "A", ontology, Cardinality::any(), {nullptr}, true, true)}; A->addSubclass(A, logger); - ASSERT_FALSE(domain->validate(logger)); + ASSERT_FALSE(ontology->validate(logger)); Rooted<FieldDescriptor> A_field = A->createFieldDescriptor(logger).first; // we make the cycle worse by adding A as child of itself. A_field->addChild(A); @@ -528,21 +528,21 @@ TEST(StructuredClass, isSubclassOf) // create an inheritance hierarchy. Manager mgr{1}; Rooted<SystemTypesystem> sys{new SystemTypesystem(mgr)}; - Rooted<Domain> domain{new Domain(mgr, sys, "inheritance")}; + Rooted<Ontology> ontology{new Ontology(mgr, sys, "inheritance")}; Rooted<StructuredClass> A{new StructuredClass( - mgr, "A", domain, Cardinality::any(), {nullptr}, false, true)}; + mgr, "A", ontology, Cardinality::any(), {nullptr}, false, true)}; // first branch Rooted<StructuredClass> B{ - new StructuredClass(mgr, "B", domain, Cardinality::any(), A)}; + new StructuredClass(mgr, "B", ontology, Cardinality::any(), A)}; Rooted<StructuredClass> C{ - new StructuredClass(mgr, "C", domain, Cardinality::any(), B)}; + new StructuredClass(mgr, "C", ontology, Cardinality::any(), B)}; // second branch Rooted<StructuredClass> D{ - new StructuredClass(mgr, "D", domain, Cardinality::any(), A)}; + new StructuredClass(mgr, "D", ontology, Cardinality::any(), A)}; Rooted<StructuredClass> E{ - new StructuredClass(mgr, "E", domain, Cardinality::any(), D)}; + new StructuredClass(mgr, "E", ontology, Cardinality::any(), D)}; Rooted<StructuredClass> F{ - new StructuredClass(mgr, "F", domain, Cardinality::any(), D)}; + new StructuredClass(mgr, "F", ontology, Cardinality::any(), D)}; // check function results ASSERT_FALSE(A->isSubclassOf(A)); @@ -588,102 +588,102 @@ TEST(StructuredClass, isSubclassOf) ASSERT_FALSE(F->isSubclassOf(F)); } -TEST(Domain, validate) +TEST(Ontology, validate) { TerminalLogger logger{std::cerr, true}; Manager mgr{1}; Rooted<SystemTypesystem> sys{new SystemTypesystem(mgr)}; - // start with an easy example: Our book domain should be valid. + // start with an easy example: Our book ontology should be valid. { - Rooted<Domain> domain = constructBookDomain(mgr, sys, logger); - ASSERT_EQ(ValidationState::UNKNOWN, domain->getValidationState()); - ASSERT_TRUE(domain->validate(logger)); + Rooted<Ontology> ontology = constructBookOntology(mgr, sys, logger); + ASSERT_EQ(ValidationState::UNKNOWN, ontology->getValidationState()); + ASSERT_TRUE(ontology->validate(logger)); } { - // Even easier: An empty domain should be valid. - Rooted<Domain> domain{new Domain(mgr, sys, "domain")}; - ASSERT_EQ(ValidationState::UNKNOWN, domain->getValidationState()); - ASSERT_TRUE(domain->validate(logger)); + // Even easier: An empty ontology should be valid. + Rooted<Ontology> ontology{new Ontology(mgr, sys, "ontology")}; + ASSERT_EQ(ValidationState::UNKNOWN, ontology->getValidationState()); + ASSERT_TRUE(ontology->validate(logger)); // if we add a StructureClass it should be valid still. Rooted<StructuredClass> base{ - new StructuredClass(mgr, "myClass", domain)}; - ASSERT_EQ(ValidationState::UNKNOWN, domain->getValidationState()); - ASSERT_TRUE(domain->validate(logger)); + new StructuredClass(mgr, "myClass", ontology)}; + ASSERT_EQ(ValidationState::UNKNOWN, ontology->getValidationState()); + ASSERT_TRUE(ontology->validate(logger)); // if we tamper with the name, however, it shouldn't be valid anymore. base->setName(""); - ASSERT_EQ(ValidationState::UNKNOWN, domain->getValidationState()); - ASSERT_FALSE(domain->validate(logger)); + ASSERT_EQ(ValidationState::UNKNOWN, ontology->getValidationState()); + ASSERT_FALSE(ontology->validate(logger)); base->setName("my class"); - ASSERT_EQ(ValidationState::UNKNOWN, domain->getValidationState()); - ASSERT_FALSE(domain->validate(logger)); + ASSERT_EQ(ValidationState::UNKNOWN, ontology->getValidationState()); + ASSERT_FALSE(ontology->validate(logger)); base->setName("myClass"); - ASSERT_EQ(ValidationState::UNKNOWN, domain->getValidationState()); - ASSERT_TRUE(domain->validate(logger)); + ASSERT_EQ(ValidationState::UNKNOWN, ontology->getValidationState()); + ASSERT_TRUE(ontology->validate(logger)); // Let's add a primitive field (without a primitive type at first) Rooted<FieldDescriptor> base_field = base->createPrimitiveFieldDescriptor(nullptr, logger).first; // this should not be valid. - ASSERT_EQ(ValidationState::UNKNOWN, domain->getValidationState()); - ASSERT_FALSE(domain->validate(logger)); + ASSERT_EQ(ValidationState::UNKNOWN, ontology->getValidationState()); + ASSERT_FALSE(ontology->validate(logger)); // but it should be if we set the type. base_field->setPrimitiveType(sys->getStringType()); - ASSERT_EQ(ValidationState::UNKNOWN, domain->getValidationState()); - ASSERT_TRUE(domain->validate(logger)); + ASSERT_EQ(ValidationState::UNKNOWN, ontology->getValidationState()); + ASSERT_TRUE(ontology->validate(logger)); // add a subclass for our base class. - Rooted<StructuredClass> sub{new StructuredClass(mgr, "sub", domain)}; + Rooted<StructuredClass> sub{new StructuredClass(mgr, "sub", ontology)}; // this should be valid in itself. - ASSERT_EQ(ValidationState::UNKNOWN, domain->getValidationState()); - ASSERT_TRUE(domain->validate(logger)); + ASSERT_EQ(ValidationState::UNKNOWN, ontology->getValidationState()); + ASSERT_TRUE(ontology->validate(logger)); // and still if we add a superclass. sub->setSuperclass(base, logger); - ASSERT_EQ(ValidationState::UNKNOWN, domain->getValidationState()); - ASSERT_TRUE(domain->validate(logger)); + ASSERT_EQ(ValidationState::UNKNOWN, ontology->getValidationState()); + ASSERT_TRUE(ontology->validate(logger)); // and still if we remove the subclass from the base class. base->removeSubclass(sub, logger); - ASSERT_EQ(ValidationState::UNKNOWN, domain->getValidationState()); - ASSERT_TRUE(domain->validate(logger)); + ASSERT_EQ(ValidationState::UNKNOWN, ontology->getValidationState()); + ASSERT_TRUE(ontology->validate(logger)); ASSERT_EQ(nullptr, sub->getSuperclass()); // and still if we re-add it. base->addSubclass(sub, logger); - ASSERT_EQ(ValidationState::UNKNOWN, domain->getValidationState()); - ASSERT_TRUE(domain->validate(logger)); + ASSERT_EQ(ValidationState::UNKNOWN, ontology->getValidationState()); + ASSERT_TRUE(ontology->validate(logger)); ASSERT_EQ(base, sub->getSuperclass()); // add a non-primitive field to the child class. Rooted<FieldDescriptor> sub_field = sub->createFieldDescriptor(logger).first; // this should not be valid because we allow no children. - ASSERT_EQ(ValidationState::UNKNOWN, domain->getValidationState()); - ASSERT_FALSE(domain->validate(logger)); + ASSERT_EQ(ValidationState::UNKNOWN, ontology->getValidationState()); + ASSERT_FALSE(ontology->validate(logger)); // we should also be able to add a child and make it valid. sub_field->addChild(base); - ASSERT_EQ(ValidationState::UNKNOWN, domain->getValidationState()); - ASSERT_TRUE(domain->validate(logger)); + ASSERT_EQ(ValidationState::UNKNOWN, ontology->getValidationState()); + ASSERT_TRUE(ontology->validate(logger)); // it should be invalid if we add it twice. sub_field->addChild(base); - ASSERT_EQ(ValidationState::UNKNOWN, domain->getValidationState()); - ASSERT_FALSE(domain->validate(logger)); + ASSERT_EQ(ValidationState::UNKNOWN, ontology->getValidationState()); + ASSERT_FALSE(ontology->validate(logger)); // and valid again if we remove it once. sub_field->removeChild(base); - ASSERT_EQ(ValidationState::UNKNOWN, domain->getValidationState()); - ASSERT_TRUE(domain->validate(logger)); + ASSERT_EQ(ValidationState::UNKNOWN, ontology->getValidationState()); + ASSERT_TRUE(ontology->validate(logger)); // if we set a primitive type it should be invalid sub_field->setPrimitiveType(sys->getStringType()); - ASSERT_EQ(ValidationState::UNKNOWN, domain->getValidationState()); - ASSERT_FALSE(domain->validate(logger)); + ASSERT_EQ(ValidationState::UNKNOWN, ontology->getValidationState()); + ASSERT_FALSE(ontology->validate(logger)); // and valid again if we unset it. sub_field->setPrimitiveType(nullptr); - ASSERT_EQ(ValidationState::UNKNOWN, domain->getValidationState()); - ASSERT_TRUE(domain->validate(logger)); + ASSERT_EQ(ValidationState::UNKNOWN, ontology->getValidationState()); + ASSERT_TRUE(ontology->validate(logger)); // It should be invalid if we set another TREE field. Rooted<FieldDescriptor> sub_field2 = sub->createFieldDescriptor(logger, FieldDescriptor::FieldType::TREE, "test", false).first; - ASSERT_EQ(ValidationState::UNKNOWN, domain->getValidationState()); - ASSERT_FALSE(domain->validate(logger)); + ASSERT_EQ(ValidationState::UNKNOWN, ontology->getValidationState()); + ASSERT_FALSE(ontology->validate(logger)); // but valid again if we remove it sub->removeFieldDescriptor(sub_field2); - ASSERT_EQ(ValidationState::UNKNOWN, domain->getValidationState()); - ASSERT_TRUE(domain->validate(logger)); + ASSERT_EQ(ValidationState::UNKNOWN, ontology->getValidationState()); + ASSERT_TRUE(ontology->validate(logger)); } } }
\ No newline at end of file diff --git a/test/core/model/TestAdvanced.hpp b/test/core/model/TestAdvanced.hpp index 71379d2..c92effa 100644 --- a/test/core/model/TestAdvanced.hpp +++ b/test/core/model/TestAdvanced.hpp @@ -20,19 +20,19 @@ #define _MODEL_TEST_ADVANCED_HPP_ #include <core/model/Document.hpp> -#include <core/model/Domain.hpp> +#include <core/model/Ontology.hpp> #include <core/model/Typesystem.hpp> #include "TestDocumentBuilder.hpp" namespace ousia { -static Rooted<StructuredClass> resolveDescriptor(Handle<Domain> domain, +static Rooted<StructuredClass> resolveDescriptor(Handle<Ontology> ontology, const std::string &className) { // use the actual resolve method. std::vector<ResolutionResult> resolved = - domain->resolve(&RttiTypes::StructuredClass, className); + ontology->resolve(&RttiTypes::StructuredClass, className); // take the first valid result. for (auto &r : resolved) { return r.node.cast<StructuredClass>(); @@ -42,53 +42,53 @@ static Rooted<StructuredClass> resolveDescriptor(Handle<Domain> domain, } /** - * This constructs the "heading" domain given the book domain. + * This constructs the "heading" ontology given the book ontology. */ -static Rooted<Domain> constructHeadingDomain(Manager &mgr, +static Rooted<Ontology> constructHeadingOntology(Manager &mgr, Handle<SystemTypesystem> sys, - Handle<Domain> bookDomain, + Handle<Ontology> bookOntology, Logger &logger) { - // set up domain node. - Rooted<Domain> domain{new Domain(mgr, sys, "headings")}; + // set up ontology node. + Rooted<Ontology> ontology{new Ontology(mgr, sys, "headings")}; // set up cardinality (every section may have at most one heading). Cardinality card; card.merge({0, 1}); // set up heading StructuredClass. Rooted<StructuredClass> heading{ - new StructuredClass(mgr, "heading", domain, card, {nullptr}, true)}; + new StructuredClass(mgr, "heading", ontology, card, {nullptr}, true)}; // as field want to reference the field of paragraph. - Rooted<StructuredClass> p = resolveDescriptor(bookDomain, "paragraph"); + Rooted<StructuredClass> p = resolveDescriptor(bookOntology, "paragraph"); heading->addFieldDescriptor(p->getFieldDescriptor(), logger); // create a new field for headings in each section type. std::vector<std::string> secclasses{"book", "section", "subsection", "paragraph"}; for (auto &s : secclasses) { - Rooted<StructuredClass> desc = resolveDescriptor(bookDomain, s); + Rooted<StructuredClass> desc = resolveDescriptor(bookOntology, s); Rooted<FieldDescriptor> heading_field = desc->createFieldDescriptor(logger, FieldDescriptor::FieldType::SUBTREE, "heading", true).first; heading_field->addChild(heading); } - return domain; + return ontology; } /** - * This constructs the "list" domain given the book domain. + * This constructs the "list" ontology given the book ontology. */ -static Rooted<Domain> constructListDomain(Manager &mgr, +static Rooted<Ontology> constructListOntology(Manager &mgr, Handle<SystemTypesystem> sys, - Handle<Domain> bookDomain, + Handle<Ontology> bookOntology, Logger &logger) { - // set up domain node. - Rooted<Domain> domain{new Domain(mgr, sys, "list")}; + // set up ontology node. + Rooted<Ontology> ontology{new Ontology(mgr, sys, "list")}; // get book.paragraph - Rooted<StructuredClass> p = resolveDescriptor(bookDomain, "paragraph"); + Rooted<StructuredClass> p = resolveDescriptor(bookOntology, "paragraph"); // set up item StructuredClass; Rooted<StructuredClass> item{new StructuredClass( - mgr, "item", domain, Cardinality::any(), {nullptr}, false)}; + mgr, "item", ontology, Cardinality::any(), {nullptr}, false)}; // as field we want to reference the field of paragraph. item->addFieldDescriptor(p->getFieldDescriptor(), logger); @@ -96,28 +96,28 @@ static Rooted<Domain> constructListDomain(Manager &mgr, std::vector<std::string> listTypes{"ol", "ul"}; for (auto &listType : listTypes) { Rooted<StructuredClass> list{new StructuredClass( - mgr, listType, domain, Cardinality::any(), p, false)}; + mgr, listType, ontology, Cardinality::any(), p, false)}; Rooted<FieldDescriptor> list_field{new FieldDescriptor(mgr, list)}; list_field->addChild(item); } - return domain; + return ontology; } /** - * This constructs the "emphasis" domain. + * This constructs the "emphasis" ontology. */ -static Rooted<Domain> constructEmphasisDomain(Manager &mgr, +static Rooted<Ontology> constructEmphasisOntology(Manager &mgr, Handle<SystemTypesystem> sys, Logger &logger) { - // set up domain node. - Rooted<Domain> domain{new Domain(mgr, sys, "emphasis")}; + // set up ontology node. + Rooted<Ontology> ontology{new Ontology(mgr, sys, "emphasis")}; // create AnnotationClasses - Rooted<AnnotationClass> em{new AnnotationClass(mgr, "emphasized", domain)}; + Rooted<AnnotationClass> em{new AnnotationClass(mgr, "emphasized", ontology)}; - Rooted<AnnotationClass> strong{new AnnotationClass(mgr, "strong", domain)}; + Rooted<AnnotationClass> strong{new AnnotationClass(mgr, "strong", ontology)}; - return domain; + return ontology; } static bool addText(Logger &logger, Handle<Document> doc, @@ -173,17 +173,17 @@ static bool addAnnotation(Logger &logger, Handle<Document> doc, /** * This constructs a more advanced book document using not only the book - * domain but also headings, emphasis and lists. + * ontology but also headings, emphasis and lists. */ static Rooted<Document> constructAdvancedDocument(Manager &mgr, Logger &logger, - Handle<Domain> bookDom, - Handle<Domain> headingDom, - Handle<Domain> listDom, - Handle<Domain> emphasisDom) + Handle<Ontology> bookDom, + Handle<Ontology> headingDom, + Handle<Ontology> listDom, + Handle<Ontology> emphasisDom) { // Start with the (empty) document. Rooted<Document> doc{new Document(mgr, "kant_was_ist_aufklaerung.oxd")}; - doc->referenceDomains({bookDom, headingDom, listDom, emphasisDom}); + doc->referenceOntologys({bookDom, headingDom, listDom, emphasisDom}); // Add the root. Rooted<StructuredEntity> book = diff --git a/test/core/model/TestDocument.hpp b/test/core/model/TestDocument.hpp index 7675dab..a4a8f7c 100644 --- a/test/core/model/TestDocument.hpp +++ b/test/core/model/TestDocument.hpp @@ -20,7 +20,7 @@ #define _MODEL_TEST_DOCUMENT_HPP_ #include <core/model/Document.hpp> -#include <core/model/Domain.hpp> +#include <core/model/Ontology.hpp> #include <core/model/Typesystem.hpp> #include "TestDocumentBuilder.hpp" @@ -28,15 +28,15 @@ namespace ousia { /** - * This constructs a fairly simple test document for the "book" domain. The + * This constructs a fairly simple test document for the "book" ontology. The * structure of the document can be seen in the Code below. */ static Rooted<Document> constructBookDocument(Manager &mgr, Logger &logger, - Rooted<Domain> bookDomain) + Rooted<Ontology> bookOntology) { // Start with the (empty) document. Rooted<Document> doc{new Document(mgr, "myDoc.oxd")}; - doc->referenceDomain(bookDomain); + doc->referenceOntology(bookOntology); // Add the root. Rooted<StructuredEntity> root = diff --git a/test/core/model/TestDocumentBuilder.hpp b/test/core/model/TestDocumentBuilder.hpp index fc76b07..745f1ab 100644 --- a/test/core/model/TestDocumentBuilder.hpp +++ b/test/core/model/TestDocumentBuilder.hpp @@ -23,7 +23,7 @@ #include <core/common/Logger.hpp> #include <core/model/Document.hpp> -#include <core/model/Domain.hpp> +#include <core/model/Ontology.hpp> #include <core/model/Typesystem.hpp> namespace ousia { @@ -81,7 +81,7 @@ static Rooted<Descriptor> resolveDescriptor(Handle<Document> doc, * @param name is the name of this StructuredEntity (empty per * default). * @return the newly created StructuredEntity or a nullptr if some - * input handle was empty or the given domains did not + * input handle was empty or the given ontologies did not * contain a StructuredClass with the given name. */ Rooted<StructuredEntity> buildRootStructuredEntity( @@ -112,7 +112,7 @@ Rooted<StructuredEntity> buildRootStructuredEntity( * This builds a StructuredEntity as child of the given DocumentEntity. It * automatically appends the newly build entity to its parent. * - * @param document is the document this entity shall be build for. The domains + * @param document is the document this entity shall be build for. The ontologies * referenced here are the basis to resolve the given path. * @param logger is the current logger. * @param parent is the parent DocumentEntity. The newly constructed @@ -126,7 +126,7 @@ Rooted<StructuredEntity> buildRootStructuredEntity( * @param name is the name of this StructuredEntity (empty per * default). * @return the newly created StructuredEntity or a nullptr if some - * input handle was empty or the given domains did not + * input handle was empty or the given ontologies did not * contain a StructuredClass with the given name. */ Rooted<StructuredEntity> buildStructuredEntity( @@ -167,7 +167,7 @@ Rooted<StructuredEntity> buildStructuredEntity( * This builds an AnnotationEntity as child of the given Document. It * automatically appends the newly build entity to its parent. * - * @param document is the document this entity shall be build for. The domains + * @param document is the document this entity shall be build for. The ontologies * referenced here are the basis to resolve the given path. * @param logger is the current logger. * @param path is the name of the AnnotationClass or a path specifying it @@ -179,7 +179,7 @@ Rooted<StructuredEntity> buildStructuredEntity( * @param name is the name of this AnnotationEntity (empty per * default). * @return the newly created AnnotationEntity or a nullptr if some - * input handle was empty or the given domains did not + * input handle was empty or the given ontologies did not * contain a AnnotationClass with the given name. */ Rooted<AnnotationEntity> buildAnnotationEntity( diff --git a/test/core/model/TestDomain.hpp b/test/core/model/TestOntology.hpp index 779ef03..c65d6f4 100644 --- a/test/core/model/TestDomain.hpp +++ b/test/core/model/TestOntology.hpp @@ -19,27 +19,27 @@ #ifndef _MODEL_TEST_DOMAIN_HPP_ #define _MODEL_TEST_DOMAIN_HPP_ -#include <core/model/Domain.hpp> +#include <core/model/Ontology.hpp> #include <core/model/Typesystem.hpp> namespace ousia { /** - * This constructs the "book" domain for test purposes. The structure of the - * domain is fairly simple and can be seen from the construction itself. + * This constructs the "book" ontology for test purposes. The structure of the + * ontology is fairly simple and can be seen from the construction itself. */ -static Rooted<Domain> constructBookDomain(Manager &mgr, +static Rooted<Ontology> constructBookOntology(Manager &mgr, Handle<SystemTypesystem> sys, Logger &logger) { - // Start with the Domain itself. - Rooted<Domain> domain{new Domain(mgr, sys, "book")}; + // Start with the Ontology itself. + Rooted<Ontology> ontology{new Ontology(mgr, sys, "book")}; // Set up the cardinalities we'll need. Cardinality single; single.merge({1}); // Set up the "book" node. Rooted<StructuredClass> book{new StructuredClass( - mgr, "book", domain, single, {nullptr}, false, true)}; + mgr, "book", ontology, single, {nullptr}, false, true)}; // The structure field of it. Rooted<FieldDescriptor> book_field = @@ -47,7 +47,7 @@ static Rooted<Domain> constructBookDomain(Manager &mgr, // From there on the "section". Rooted<StructuredClass> section{ - new StructuredClass(mgr, "section", domain, Cardinality::any())}; + new StructuredClass(mgr, "section", ontology, Cardinality::any())}; book_field->addChild(section); // And the field of it. @@ -56,7 +56,7 @@ static Rooted<Domain> constructBookDomain(Manager &mgr, // We also add the "paragraph", which is transparent. Rooted<StructuredClass> paragraph{new StructuredClass( - mgr, "paragraph", domain, Cardinality::any(), {nullptr}, true)}; + mgr, "paragraph", ontology, Cardinality::any(), {nullptr}, true)}; section_field->addChild(paragraph); book_field->addChild(paragraph); @@ -66,7 +66,7 @@ static Rooted<Domain> constructBookDomain(Manager &mgr, // We append "subsection" to section. Rooted<StructuredClass> subsection{ - new StructuredClass(mgr, "subsection", domain, Cardinality::any())}; + new StructuredClass(mgr, "subsection", ontology, Cardinality::any())}; section_field->addChild(subsection); // And the field of it. @@ -78,7 +78,7 @@ static Rooted<Domain> constructBookDomain(Manager &mgr, // Finally we add the "text" node, which is transparent as well. Rooted<StructuredClass> text{new StructuredClass( - mgr, "text", domain, Cardinality::any(), {nullptr}, true)}; + mgr, "text", ontology, Cardinality::any(), {nullptr}, true)}; paragraph_field->addChild(text); // ... and has a primitive field. @@ -86,7 +86,7 @@ static Rooted<Domain> constructBookDomain(Manager &mgr, text->createPrimitiveFieldDescriptor(sys->getStringType(), logger) .first; - return domain; + return ontology; } } diff --git a/test/core/resource/ResourceRequestTest.cpp b/test/core/resource/ResourceRequestTest.cpp index dac7a28..3112cc4 100644 --- a/test/core/resource/ResourceRequestTest.cpp +++ b/test/core/resource/ResourceRequestTest.cpp @@ -31,7 +31,7 @@ namespace ousia { namespace RttiTypes { extern const Rtti Document; -extern const Rtti Domain; +extern const Rtti Ontology; extern const Rtti Typesystem; } @@ -62,12 +62,12 @@ struct TestSetup { TestSetup() { - registry.registerExtension("domain", "application/domain"); + registry.registerExtension("ontology", "application/ontology"); registry.registerExtension("typesystem", "application/typesystem"); registry.registerExtension("document", "application/document"); registry.registerParser( - {"application/domain", "application/typesystem"}, - {&RttiTypes::Domain, &RttiTypes::Typesystem}, &pModule); + {"application/ontology", "application/typesystem"}, + {&RttiTypes::Ontology, &RttiTypes::Typesystem}, &pModule); registry.registerParser({"application/document"}, {&RttiTypes::Document}, &pDocument); } @@ -78,16 +78,16 @@ TEST(ResourceRequest, deduction) { TestSetup t; - ResourceRequest req("test.domain", "", "", {&RttiTypes::Domain}); + ResourceRequest req("test.ontology", "", "", {&RttiTypes::Ontology}); ASSERT_TRUE(req.deduce(t.registry, logger)); - ASSERT_EQ("test.domain", req.getPath()); - ASSERT_EQ("application/domain", req.getMimetype()); - ASSERT_EQ(RttiSet({&RttiTypes::Domain}), req.getSupportedTypes()); - ASSERT_EQ(ResourceType::DOMAIN_DESC, req.getResourceType()); + ASSERT_EQ("test.ontology", req.getPath()); + ASSERT_EQ("application/ontology", req.getMimetype()); + ASSERT_EQ(RttiSet({&RttiTypes::Ontology}), req.getSupportedTypes()); + ASSERT_EQ(ResourceType::ONTOLOGY, req.getResourceType()); ASSERT_EQ(&t.pModule, req.getParser()); - ASSERT_EQ(RttiSet({&RttiTypes::Domain, &RttiTypes::Typesystem}), + ASSERT_EQ(RttiSet({&RttiTypes::Ontology, &RttiTypes::Typesystem}), req.getParserTypes()); } @@ -95,17 +95,17 @@ TEST(ResourceRequest, deductionWithMimetype) { TestSetup t; - ResourceRequest req("test.domain", "application/typesystem", "", + ResourceRequest req("test.ontology", "application/typesystem", "", {&RttiTypes::Typesystem}); ASSERT_TRUE(req.deduce(t.registry, logger)); - ASSERT_EQ("test.domain", req.getPath()); + ASSERT_EQ("test.ontology", req.getPath()); ASSERT_EQ("application/typesystem", req.getMimetype()); ASSERT_EQ(RttiSet({&RttiTypes::Typesystem}), req.getSupportedTypes()); ASSERT_EQ(ResourceType::TYPESYSTEM, req.getResourceType()); ASSERT_EQ(&t.pModule, req.getParser()); - ASSERT_EQ(RttiSet({&RttiTypes::Domain, &RttiTypes::Typesystem}), + ASSERT_EQ(RttiSet({&RttiTypes::Ontology, &RttiTypes::Typesystem}), req.getParserTypes()); } @@ -113,18 +113,18 @@ TEST(ResourceRequest, deductionWithUnknownResourceType) { TestSetup t; - ResourceRequest req("test.domain", "", "", - {&RttiTypes::Domain, &RttiTypes::Typesystem}); + ResourceRequest req("test.ontology", "", "", + {&RttiTypes::Ontology, &RttiTypes::Typesystem}); ASSERT_TRUE(req.deduce(t.registry, logger)); - ASSERT_EQ("test.domain", req.getPath()); - ASSERT_EQ("application/domain", req.getMimetype()); - ASSERT_EQ(RttiSet({&RttiTypes::Domain, &RttiTypes::Typesystem}), + ASSERT_EQ("test.ontology", req.getPath()); + ASSERT_EQ("application/ontology", req.getMimetype()); + ASSERT_EQ(RttiSet({&RttiTypes::Ontology, &RttiTypes::Typesystem}), req.getSupportedTypes()); ASSERT_EQ(ResourceType::UNKNOWN, req.getResourceType()); ASSERT_EQ(&t.pModule, req.getParser()); - ASSERT_EQ(RttiSet({&RttiTypes::Domain, &RttiTypes::Typesystem}), + ASSERT_EQ(RttiSet({&RttiTypes::Ontology, &RttiTypes::Typesystem}), req.getParserTypes()); } @@ -132,17 +132,17 @@ TEST(ResourceRequest, deductionWithRel) { TestSetup t; - ResourceRequest req("test.domain", "", "domain", - {&RttiTypes::Domain, &RttiTypes::Typesystem}); + ResourceRequest req("test.ontology", "", "ontology", + {&RttiTypes::Ontology, &RttiTypes::Typesystem}); ASSERT_TRUE(req.deduce(t.registry, logger)); - ASSERT_EQ("test.domain", req.getPath()); - ASSERT_EQ("application/domain", req.getMimetype()); - ASSERT_EQ(RttiSet({&RttiTypes::Domain}), req.getSupportedTypes()); - ASSERT_EQ(ResourceType::DOMAIN_DESC, req.getResourceType()); + ASSERT_EQ("test.ontology", req.getPath()); + ASSERT_EQ("application/ontology", req.getMimetype()); + ASSERT_EQ(RttiSet({&RttiTypes::Ontology}), req.getSupportedTypes()); + ASSERT_EQ(ResourceType::ONTOLOGY, req.getResourceType()); ASSERT_EQ(&t.pModule, req.getParser()); - ASSERT_EQ(RttiSet({&RttiTypes::Domain, &RttiTypes::Typesystem}), + ASSERT_EQ(RttiSet({&RttiTypes::Ontology, &RttiTypes::Typesystem}), req.getParserTypes()); } } |