summaryrefslogtreecommitdiff
path: root/test/core
diff options
context:
space:
mode:
Diffstat (limited to 'test/core')
-rw-r--r--test/core/StandaloneEnvironment.hpp2
-rw-r--r--test/core/model/DocumentTest.cpp24
-rw-r--r--test/core/model/DomainTest.cpp32
-rw-r--r--test/core/model/TestAdvanced.hpp6
-rw-r--r--test/core/model/TestDocumentBuilder.hpp20
-rw-r--r--test/core/model/TestDomain.hpp6
6 files changed, 41 insertions, 49 deletions
diff --git a/test/core/StandaloneEnvironment.hpp b/test/core/StandaloneEnvironment.hpp
index c381abe..a9dcdce 100644
--- a/test/core/StandaloneEnvironment.hpp
+++ b/test/core/StandaloneEnvironment.hpp
@@ -41,7 +41,7 @@ struct StandaloneEnvironment {
ParserContext context;
StandaloneEnvironment(ConcreteLogger &logger)
- : logger(logger), project(new Project(manager)),
+ : logger(logger), manager(1), project(new Project(manager)),
context(registry, resourceManager, scope, project, logger)
{
logger.reset();
diff --git a/test/core/model/DocumentTest.cpp b/test/core/model/DocumentTest.cpp
index 5a2bcec..177f69b 100644
--- a/test/core/model/DocumentTest.cpp
+++ b/test/core/model/DocumentTest.cpp
@@ -123,7 +123,7 @@ TEST(Document, validate)
single.merge({1});
// Set up the "root" StructuredClass.
Rooted<StructuredClass> rootClass{new StructuredClass(
- mgr, "root", domain, single, {nullptr}, {nullptr}, false, true)};
+ mgr, "root", domain, single, {nullptr}, false, true)};
// set up a document for it.
{
@@ -177,8 +177,8 @@ TEST(Document, validate)
/*
* Add a further extension to the domain: We add a subclass to child.
*/
- Rooted<StructuredClass> childSubClass{new StructuredClass(
- mgr, "childSub", domain, single, {nullptr}, childClass)};
+ Rooted<StructuredClass> childSubClass{
+ new StructuredClass(mgr, "childSub", domain, single, childClass)};
{
/*
* A document with one instance of the Child subclass should be valid.
@@ -284,23 +284,19 @@ TEST(Document, validate)
ASSERT_EQ(ValidationState::UNKNOWN, doc->getValidationState());
ASSERT_TRUE(doc->validate(logger));
// add an attribute to the root, which should make it invalid.
- root->setAttributes({2});
+ root->setAttributes(Variant::mapType{{"bla", 2}});
ASSERT_EQ(ValidationState::UNKNOWN, doc->getValidationState());
ASSERT_FALSE(doc->validate(logger));
- // if we reset it to null it should be valid again
- root->setAttributes({});
+ // if we reset it to an empty map it should be valid again
+ root->setAttributes(Variant::mapType{});
ASSERT_EQ(ValidationState::UNKNOWN, doc->getValidationState());
ASSERT_TRUE(doc->validate(logger));
// let's set an attribute descriptor.
- Rooted<StructType> structType{StructType::createValidated(
- mgr, "attributes", nullptr, nullptr,
- NodeVector<Attribute>{
- new Attribute{mgr, "myAttr", sys->getStringType(), "default"}},
- logger)};
- childSubClass->setAttributesDescriptor(structType);
+ childSubClass->getAttributesDescriptor()->addAttribute(
+ new Attribute{mgr, "myAttr", sys->getStringType(), "default"},
+ logger);
// the right map content should be valid now.
- child->setAttributes(
- std::map<std::string, Variant>{{"myAttr", "content"}});
+ child->setAttributes(Variant::mapType{{"myAttr", "content"}});
ASSERT_EQ(ValidationState::UNKNOWN, doc->getValidationState());
ASSERT_TRUE(doc->validate(logger));
// but an empty map as well
diff --git a/test/core/model/DomainTest.cpp b/test/core/model/DomainTest.cpp
index 69c6694..8fcd21d 100644
--- a/test/core/model/DomainTest.cpp
+++ b/test/core/model/DomainTest.cpp
@@ -154,22 +154,22 @@ TEST(Descriptor, pathToAdvanced)
// Let's create the classes that we need first
Rooted<StructuredClass> A{new StructuredClass(
- mgr, "A", domain, AnyCardinality, {nullptr}, {nullptr}, false, true)};
+ mgr, "A", domain, AnyCardinality, {nullptr}, false, true)};
Rooted<StructuredClass> start{new StructuredClass(
- mgr, "start", domain, AnyCardinality, {nullptr}, A, false, false)};
+ mgr, "start", domain, AnyCardinality, A, false, false)};
Rooted<StructuredClass> B{new StructuredClass(
- mgr, "B", domain, AnyCardinality, {nullptr}, {nullptr}, true, false)};
+ mgr, "B", domain, AnyCardinality, {nullptr}, true, false)};
- Rooted<StructuredClass> C{new StructuredClass(
- mgr, "C", domain, AnyCardinality, {nullptr}, B, true, false)};
+ Rooted<StructuredClass> C{
+ new StructuredClass(mgr, "C", domain, AnyCardinality, B, true, false)};
Rooted<StructuredClass> D{new StructuredClass(
- mgr, "D", domain, AnyCardinality, {nullptr}, {nullptr}, true, false)};
+ mgr, "D", domain, AnyCardinality, {nullptr}, true, false)};
Rooted<StructuredClass> E{new StructuredClass(
- mgr, "E", domain, AnyCardinality, {nullptr}, {nullptr}, true, false)};
+ mgr, "E", domain, AnyCardinality, {nullptr}, true, false)};
Rooted<StructuredClass> target{
new StructuredClass(mgr, "target", domain, AnyCardinality)};
@@ -223,19 +223,19 @@ TEST(StructuredClass, isSubclassOf)
Rooted<SystemTypesystem> sys{new SystemTypesystem(mgr)};
Rooted<Domain> domain{new Domain(mgr, sys, "inheritance")};
Rooted<StructuredClass> A{new StructuredClass(
- mgr, "A", domain, AnyCardinality, {nullptr}, {nullptr}, false, true)};
+ mgr, "A", domain, AnyCardinality, {nullptr}, false, true)};
// first branch
Rooted<StructuredClass> B{
- new StructuredClass(mgr, "B", domain, AnyCardinality, {nullptr}, A)};
+ new StructuredClass(mgr, "B", domain, AnyCardinality, A)};
Rooted<StructuredClass> C{
- new StructuredClass(mgr, "C", domain, AnyCardinality, {nullptr}, B)};
+ new StructuredClass(mgr, "C", domain, AnyCardinality, B)};
// second branch
Rooted<StructuredClass> D{
- new StructuredClass(mgr, "D", domain, AnyCardinality, {nullptr}, A)};
+ new StructuredClass(mgr, "D", domain, AnyCardinality, A)};
Rooted<StructuredClass> E{
- new StructuredClass(mgr, "E", domain, AnyCardinality, {nullptr}, D)};
+ new StructuredClass(mgr, "E", domain, AnyCardinality, D)};
Rooted<StructuredClass> F{
- new StructuredClass(mgr, "F", domain, AnyCardinality, {nullptr}, D)};
+ new StructuredClass(mgr, "F", domain, AnyCardinality, D)};
// check function results
ASSERT_FALSE(A->isSubclassOf(A));
@@ -335,16 +335,16 @@ TEST(Domain, validate)
ASSERT_EQ(ValidationState::UNKNOWN, domain->getValidationState());
ASSERT_TRUE(domain->validate(logger));
// and still if we add a superclass.
- sub->setSuperclass(base);
+ sub->setSuperclass(base, logger);
ASSERT_EQ(ValidationState::UNKNOWN, domain->getValidationState());
ASSERT_TRUE(domain->validate(logger));
// and still we we remove the subclass from the base class.
- base->removeSubclass(sub);
+ base->removeSubclass(sub, logger);
ASSERT_EQ(ValidationState::UNKNOWN, domain->getValidationState());
ASSERT_TRUE(domain->validate(logger));
ASSERT_EQ(nullptr, sub->getSuperclass());
// and still if we re-add it.
- base->addSubclass(sub);
+ base->addSubclass(sub, logger);
ASSERT_EQ(ValidationState::UNKNOWN, domain->getValidationState());
ASSERT_TRUE(domain->validate(logger));
ASSERT_EQ(base, sub->getSuperclass());
diff --git a/test/core/model/TestAdvanced.hpp b/test/core/model/TestAdvanced.hpp
index 3845676..2e4a541 100644
--- a/test/core/model/TestAdvanced.hpp
+++ b/test/core/model/TestAdvanced.hpp
@@ -56,7 +56,7 @@ static Rooted<Domain> constructHeadingDomain(Manager &mgr,
card.merge({0, 1});
// set up heading StructuredClass.
Rooted<StructuredClass> heading{new StructuredClass(
- mgr, "heading", domain, card, {nullptr}, {nullptr}, true)};
+ mgr, "heading", domain, card, {nullptr}, true)};
// as field want to copy the field of paragraph.
Rooted<StructuredClass> p = resolveDescriptor(bookDomain, "paragraph");
heading->copyFieldDescriptor(p->getFieldDescriptors()[0]);
@@ -86,7 +86,7 @@ static Rooted<Domain> constructListDomain(Manager &mgr,
Rooted<StructuredClass> p = resolveDescriptor(bookDomain, "paragraph");
// set up item StructuredClass;
Rooted<StructuredClass> item{new StructuredClass(
- mgr, "item", domain, AnyCardinality, {nullptr}, {nullptr}, false)};
+ mgr, "item", domain, AnyCardinality, {nullptr}, false)};
// as field we want to copy the field of paragraph.
item->copyFieldDescriptor(p->getFieldDescriptors()[0]);
@@ -94,7 +94,7 @@ 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, AnyCardinality, {nullptr}, p, false)};
+ mgr, listType, domain, AnyCardinality, p, false)};
Rooted<FieldDescriptor> list_field{new FieldDescriptor(mgr, list)};
list_field->addChild(item);
}
diff --git a/test/core/model/TestDocumentBuilder.hpp b/test/core/model/TestDocumentBuilder.hpp
index 05b27b7..3d24839 100644
--- a/test/core/model/TestDocumentBuilder.hpp
+++ b/test/core/model/TestDocumentBuilder.hpp
@@ -84,11 +84,9 @@ static Rooted<Descriptor> resolveDescriptor(Handle<Document> doc,
* input handle was empty or the given domains did not
* contain a StructuredClass with the given name.
*/
-Rooted<StructuredEntity> buildRootStructuredEntity(Handle<Document> document,
- Logger &logger,
- const Path &path,
- Variant attributes = {},
- std::string name = "")
+Rooted<StructuredEntity> buildRootStructuredEntity(
+ Handle<Document> document, Logger &logger, const Path &path,
+ Variant attributes = Variant::mapType{}, std::string name = "")
{
// If the parent is not set, we can not build the entity.
if (document == nullptr) {
@@ -134,7 +132,7 @@ Rooted<StructuredEntity> buildRootStructuredEntity(Handle<Document> document,
Rooted<StructuredEntity> buildStructuredEntity(
Handle<Document> document, Logger &logger, Handle<StructuredEntity> parent,
Path path, const std::string &fieldName = DEFAULT_FIELD_NAME,
- Variant attributes = {}, std::string name = "")
+ Variant attributes = Variant::mapType{}, std::string name = "")
{
// If the input handles are not set, we can not build the entity.
if (parent == nullptr) {
@@ -184,12 +182,10 @@ Rooted<StructuredEntity> buildStructuredEntity(
* input handle was empty or the given domains did not
* contain a AnnotationClass with the given name.
*/
-Rooted<AnnotationEntity> buildAnnotationEntity(Handle<Document> document,
- Logger &logger, const Path &path,
- Handle<Anchor> start,
- Handle<Anchor> end,
- Variant attributes = {},
- std::string name = "")
+Rooted<AnnotationEntity> buildAnnotationEntity(
+ Handle<Document> document, Logger &logger, const Path &path,
+ Handle<Anchor> start, Handle<Anchor> end,
+ Variant attributes = Variant::mapType{}, std::string name = "")
{
// If the input handles are not set, we can not build the entity.
if (document == nullptr) {
diff --git a/test/core/model/TestDomain.hpp b/test/core/model/TestDomain.hpp
index 88ab715..18c42bd 100644
--- a/test/core/model/TestDomain.hpp
+++ b/test/core/model/TestDomain.hpp
@@ -39,7 +39,7 @@ static Rooted<Domain> constructBookDomain(Manager &mgr,
// Set up the "book" node.
Rooted<StructuredClass> book{new StructuredClass(
- mgr, "book", domain, single, {nullptr}, {nullptr}, false, true)};
+ mgr, "book", domain, single, {nullptr}, false, true)};
// The structure field of it.
Rooted<FieldDescriptor> book_field{new FieldDescriptor(mgr, book)};
@@ -54,7 +54,7 @@ static Rooted<Domain> constructBookDomain(Manager &mgr,
// We also add the "paragraph", which is transparent.
Rooted<StructuredClass> paragraph{new StructuredClass(
- mgr, "paragraph", domain, AnyCardinality, {nullptr}, {nullptr}, true)};
+ mgr, "paragraph", domain, AnyCardinality, {nullptr}, true)};
section_field->addChild(paragraph);
book_field->addChild(paragraph);
@@ -76,7 +76,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, AnyCardinality, {nullptr}, {nullptr}, true)};
+ mgr, "text", domain, AnyCardinality, {nullptr}, true)};
paragraph_field->addChild(text);
// ... and has a primitive field.