diff --git a/test/test-BlueprintParser.cc b/test/test-BlueprintParser.cc index a0199c49..a4577c0c 100644 --- a/test/test-BlueprintParser.cc +++ b/test/test-BlueprintParser.cc @@ -413,7 +413,7 @@ TEST_CASE("Parsing unexpected blocks", "[blueprint]") "# GET /\n"; ParseResult blueprint; - SectionParserHelper::parse(source, BlueprintSectionType, blueprint, ExportSourcemapOption, Models(), &blueprint); + SectionParserHelper::parse(source, BlueprintSectionType, blueprint, ExportSourcemapOption); REQUIRE(blueprint.report.error.code == Error::OK); REQUIRE(blueprint.report.warnings.size() == 1); // no response @@ -607,7 +607,7 @@ TEST_CASE("Parser blueprint correctly when having a big chain of inheritance in "Clone\n"; ParseResult blueprint; - SectionParserHelper::parse(source, BlueprintSectionType, blueprint, ExportSourcemapOption, Models(), &blueprint); + SectionParserHelper::parse(source, BlueprintSectionType, blueprint, ExportSourcemapOption); REQUIRE(blueprint.report.error.code == Error::OK); REQUIRE(blueprint.report.warnings.empty()); @@ -644,7 +644,7 @@ TEST_CASE("Report error when coming across a super type reference to non existen "+ id: 25OFF (string)\n"; ParseResult blueprint; - SectionParserHelper::parse(source, BlueprintSectionType, blueprint, ExportSourcemapOption, Models(), &blueprint); + SectionParserHelper::parse(source, BlueprintSectionType, blueprint, ExportSourcemapOption); REQUIRE(blueprint.report.error.code == MSONError); SourceMapHelper::check(blueprint.report.error.location, 62, 27); @@ -659,7 +659,7 @@ TEST_CASE("Report error when a Data Structure inherits from itself", "[blueprint "+ id (string)\n"; ParseResult blueprint; - SectionParserHelper::parse(source, BlueprintSectionType, blueprint, ExportSourcemapOption, Models(), &blueprint); + SectionParserHelper::parse(source, BlueprintSectionType, blueprint, ExportSourcemapOption); REQUIRE(blueprint.report.error.code == MSONError); SourceMapHelper::check(blueprint.report.error.location, 19, 9); @@ -674,7 +674,7 @@ TEST_CASE("Report error when named type inherits a sub type in array", "[bluepri "## B (A)\n"; ParseResult blueprint; - SectionParserHelper::parse(source, BlueprintSectionType, blueprint, ExportSourcemapOption, Models(), &blueprint); + SectionParserHelper::parse(source, BlueprintSectionType, blueprint, ExportSourcemapOption); REQUIRE(blueprint.report.error.code == MSONError); SourceMapHelper::check(blueprint.report.error.location, 35, 9); @@ -690,7 +690,7 @@ TEST_CASE("Report error when data Structure inheritance graph contains a cycle", "## C (A)\n"; ParseResult blueprint; - SectionParserHelper::parse(source, BlueprintSectionType, blueprint, ExportSourcemapOption, Models(), &blueprint); + SectionParserHelper::parse(source, BlueprintSectionType, blueprint, ExportSourcemapOption); REQUIRE(blueprint.report.error.code == MSONError); SourceMapHelper::check(blueprint.report.error.location, 19, 9); @@ -708,7 +708,7 @@ TEST_CASE("Report error when data Structure inheritance graph with only a few of "## E (C)\n"; ParseResult blueprint; - SectionParserHelper::parse(source, BlueprintSectionType, blueprint, ExportSourcemapOption, Models(), &blueprint); + SectionParserHelper::parse(source, BlueprintSectionType, blueprint, ExportSourcemapOption); REQUIRE(blueprint.report.error.code == MSONError); SourceMapHelper::check(blueprint.report.error.location, 37, 9); @@ -724,7 +724,7 @@ TEST_CASE("Do not report error when named sub type is referenced in nested membe "+ person (A)\n"; ParseResult blueprint; - SectionParserHelper::parse(source, BlueprintSectionType, blueprint, ExportSourcemapOption, Models(), &blueprint); + SectionParserHelper::parse(source, BlueprintSectionType, blueprint, ExportSourcemapOption); REQUIRE(blueprint.report.error.code == Error::OK); REQUIRE(blueprint.report.warnings.empty()); @@ -767,7 +767,7 @@ TEST_CASE("Do not report error when there are circular references in nested memb "+ id (B)\n"; ParseResult blueprint; - SectionParserHelper::parse(source, BlueprintSectionType, blueprint, ExportSourcemapOption, Models(), &blueprint); + SectionParserHelper::parse(source, BlueprintSectionType, blueprint, ExportSourcemapOption); REQUIRE(blueprint.report.error.code == Error::OK); REQUIRE(blueprint.report.warnings.empty()); @@ -823,7 +823,7 @@ TEST_CASE("Do not report error when named sub type is referenced in nested membe "## A (B)\n"; ParseResult blueprint; - SectionParserHelper::parse(source, BlueprintSectionType, blueprint, ExportSourcemapOption, Models(), &blueprint); + SectionParserHelper::parse(source, BlueprintSectionType, blueprint, ExportSourcemapOption); REQUIRE(blueprint.report.error.code == Error::OK); REQUIRE(blueprint.report.warnings.empty()); @@ -867,7 +867,7 @@ TEST_CASE("Do not report error when a resource attributes type is circularly ref "+ posts (Post)\n"; ParseResult blueprint; - SectionParserHelper::parse(source, BlueprintSectionType, blueprint, ExportSourcemapOption, Models(), &blueprint); + SectionParserHelper::parse(source, BlueprintSectionType, blueprint, ExportSourcemapOption); REQUIRE(blueprint.report.error.code == Error::OK); REQUIRE(blueprint.report.warnings.empty()); @@ -918,7 +918,7 @@ TEST_CASE("Report error when named sub type is referenced as mixin", "[blueprint "+ Include A\n"; ParseResult blueprint; - SectionParserHelper::parse(source, BlueprintSectionType, blueprint, ExportSourcemapOption, Models(), &blueprint); + SectionParserHelper::parse(source, BlueprintSectionType, blueprint, ExportSourcemapOption); REQUIRE(blueprint.report.error.code == MSONError); SourceMapHelper::check(blueprint.report.error.location, 35, 10); @@ -935,7 +935,7 @@ TEST_CASE("Report error when named sub type is referenced as mixin when referenc "## A (B)\n"; ParseResult blueprint; - SectionParserHelper::parse(source, BlueprintSectionType, blueprint, ExportSourcemapOption, Models(), &blueprint); + SectionParserHelper::parse(source, BlueprintSectionType, blueprint, ExportSourcemapOption); REQUIRE(blueprint.report.error.code == MSONError); SourceMapHelper::check(blueprint.report.error.location, 26, 10); @@ -953,7 +953,7 @@ TEST_CASE("Report error when circular reference in mixins", "[blueprint]") "+ Include A\n"; ParseResult blueprint; - SectionParserHelper::parse(source, BlueprintSectionType, blueprint, ExportSourcemapOption, Models(), &blueprint); + SectionParserHelper::parse(source, BlueprintSectionType, blueprint, ExportSourcemapOption); REQUIRE(blueprint.report.error.code == MSONError); SourceMapHelper::check(blueprint.report.error.location, 45, 10); @@ -969,7 +969,7 @@ TEST_CASE("Do not report error when named type references itself in array", "[bl "+ children (array[Comment])\n"; ParseResult blueprint; - SectionParserHelper::parse(source, BlueprintSectionType, blueprint, ExportSourcemapOption, Models(), &blueprint); + SectionParserHelper::parse(source, BlueprintSectionType, blueprint, ExportSourcemapOption); REQUIRE(blueprint.report.error.code == Error::OK); REQUIRE(blueprint.report.warnings.empty()); @@ -1009,7 +1009,7 @@ TEST_CASE("Report error when a named type is defined twice with inheritance", "[ "## C (object)\n"; ParseResult blueprint; - SectionParserHelper::parse(source, BlueprintSectionType, blueprint, ExportSourcemapOption, Models(), &blueprint); + SectionParserHelper::parse(source, BlueprintSectionType, blueprint, ExportSourcemapOption); REQUIRE(blueprint.report.error.code == MSONError); SourceMapHelper::check(blueprint.report.error.location, 19, 9); @@ -1024,7 +1024,7 @@ TEST_CASE("Report error when a named type is defined twice with base type", "[bl "## A (object)\n"; ParseResult blueprint; - SectionParserHelper::parse(source, BlueprintSectionType, blueprint, ExportSourcemapOption, Models(), &blueprint); + SectionParserHelper::parse(source, BlueprintSectionType, blueprint, ExportSourcemapOption); REQUIRE(blueprint.report.error.code == MSONError); SourceMapHelper::check(blueprint.report.error.location, 33, 14); @@ -1040,7 +1040,7 @@ TEST_CASE("Report error when a named type is defined twice, once with base type "## B (object)\n"; ParseResult blueprint; - SectionParserHelper::parse(source, BlueprintSectionType, blueprint, ExportSourcemapOption, Models(), &blueprint); + SectionParserHelper::parse(source, BlueprintSectionType, blueprint, ExportSourcemapOption); REQUIRE(blueprint.report.error.code == MSONError); SourceMapHelper::check(blueprint.report.error.location, 28, 14); @@ -1053,7 +1053,7 @@ TEST_CASE("Parse mson signature attributes with mismatched square brackets", "[b "+ Attributes (array[Note)"; ParseResult blueprint; - SectionParserHelper::parse(source, BlueprintSectionType, blueprint, ExportSourcemapOption, Models(), &blueprint); + SectionParserHelper::parse(source, BlueprintSectionType, blueprint, ExportSourcemapOption); REQUIRE(blueprint.report.error.code == Error::OK); } @@ -1065,7 +1065,7 @@ TEST_CASE("Parse named type mson signature attributes with no closing bracket", "## B (A("; ParseResult blueprint; - SectionParserHelper::parse(source, BlueprintSectionType, blueprint, ExportSourcemapOption, Models(), &blueprint); + SectionParserHelper::parse(source, BlueprintSectionType, blueprint, ExportSourcemapOption); REQUIRE(blueprint.report.error.code == MSONError); REQUIRE(blueprint.report.error.message == "base type 'A(' is not defined in the document"); @@ -1084,7 +1084,7 @@ TEST_CASE("Parse correctly when a resource named type is non-circularly referenc " + bla (Question)\n"; ParseResult blueprint; - SectionParserHelper::parse(source, BlueprintSectionType, blueprint, ExportSourcemapOption, Models(), &blueprint); + SectionParserHelper::parse(source, BlueprintSectionType, blueprint, ExportSourcemapOption); REQUIRE(blueprint.report.error.code == Error::OK); } @@ -1097,7 +1097,7 @@ TEST_CASE("Report error when not finding a super type of the nested member", "[b "+ choice (B)\n"; ParseResult blueprint; - SectionParserHelper::parse(source, BlueprintSectionType, blueprint, ExportSourcemapOption, Models(), &blueprint); + SectionParserHelper::parse(source, BlueprintSectionType, blueprint, ExportSourcemapOption); REQUIRE(blueprint.report.error.code == MSONError); REQUIRE(blueprint.report.error.message == "base type 'B' is not defined in the document"); @@ -1111,7 +1111,7 @@ TEST_CASE("Report error when not finding a nested super type of the nested membe "+ choice (array[B])\n"; ParseResult blueprint; - SectionParserHelper::parse(source, BlueprintSectionType, blueprint, ExportSourcemapOption, Models(), &blueprint); + SectionParserHelper::parse(source, BlueprintSectionType, blueprint, ExportSourcemapOption); REQUIRE(blueprint.report.error.code == MSONError); REQUIRE(blueprint.report.error.message == "base type 'B' is not defined in the document"); @@ -1125,7 +1125,7 @@ TEST_CASE("Report error when not finding a mixin type", "[blueprint]") "+ Include B\n"; ParseResult blueprint; - SectionParserHelper::parse(source, BlueprintSectionType, blueprint, ExportSourcemapOption, Models(), &blueprint); + SectionParserHelper::parse(source, BlueprintSectionType, blueprint, ExportSourcemapOption); REQUIRE(blueprint.report.error.code == MSONError); REQUIRE(blueprint.report.error.message == "base type 'B' is not defined in the document"); @@ -1241,7 +1241,7 @@ TEST_CASE("Any named type data structure should be able to be overridden when re " + relation: family\n"; ParseResult blueprint; - SectionParserHelper::parse(source, BlueprintSectionType, blueprint, ExportSourcemapOption, Models(), &blueprint); + SectionParserHelper::parse(source, BlueprintSectionType, blueprint, ExportSourcemapOption); REQUIRE(blueprint.report.error.code == Error::OK); REQUIRE(blueprint.report.warnings.empty()); @@ -1301,3 +1301,45 @@ TEST_CASE("Any named type data structure should be able to be overridden when re REQUIRE(property3.valueDefinition.values[0].literal == "family"); REQUIRE(property3.valueDefinition.typeDefinition.empty()); } + +TEST_CASE("Parse attributes with mixin and no base type mentioned for attributes", "[blueprint][#362]") +{ + mdp::ByteBuffer source = \ + "# GET /\n"\ + "+ Response 200\n"\ + " + Attributes\n"\ + " + Include A\n"\ + "\n"\ + "# Data Structures\n"\ + "\n"\ + "## A (object)\n"\ + "+ a: a\n"; + + ParseResult blueprint; + SectionParserHelper::parse(source, BlueprintSectionType, blueprint, ExportSourcemapOption); + + REQUIRE(blueprint.report.error.code == Error::OK); + REQUIRE(blueprint.report.warnings.empty()); + REQUIRE(blueprint.node.content.elements().size() == 2); +} + +TEST_CASE("Parse attributes with mixin and no base type mentioned for mixin", "[blueprint][#138]") +{ + mdp::ByteBuffer source = \ + "# GET /\n"\ + "+ Response 200\n"\ + " + Attributes (object)\n"\ + " + Include A\n"\ + "\n"\ + "# Data Structures\n"\ + "\n"\ + "## A\n"\ + "+ a: a\n"; + + ParseResult blueprint; + SectionParserHelper::parse(source, BlueprintSectionType, blueprint, ExportSourcemapOption); + + REQUIRE(blueprint.report.error.code == Error::OK); + REQUIRE(blueprint.report.warnings.empty()); + REQUIRE(blueprint.node.content.elements().size() == 2); +}