From 7cdcc566139dcace4b1d71494098e0e6798c63ac Mon Sep 17 00:00:00 2001 From: Jonathan Casey Date: Fri, 13 Oct 2023 15:24:36 +0100 Subject: [PATCH 01/20] feat(map): extend xmlschemavisitor Signed-off-by: Jonathan Casey --- .../fromcto/xmlschema/xmlschemavisitor.js | 41 ++++++++++++++++++- 1 file changed, 39 insertions(+), 2 deletions(-) diff --git a/lib/codegen/fromcto/xmlschema/xmlschemavisitor.js b/lib/codegen/fromcto/xmlschema/xmlschemavisitor.js index 9500e552..29c7e2d9 100644 --- a/lib/codegen/fromcto/xmlschema/xmlschemavisitor.js +++ b/lib/codegen/fromcto/xmlschema/xmlschemavisitor.js @@ -44,7 +44,7 @@ class XmlSchemaVisitor { } else if (thing.isClassDeclaration?.()) { return this.visitClassDeclaration(thing, parameters); } else if (thing.isMapDeclaration?.()) { - return; + return this.visitMapDeclaration(thing, parameters); } else if (thing.isTypeScalar?.()) { return this.visitField(thing.getScalarField(), parameters); } else if (thing.isField?.()) { @@ -153,6 +153,33 @@ class XmlSchemaVisitor { return null; } + /** + * Visitor design pattern + * @param {MapDeclaration} mapDeclaration - the object being visited + * @param {Object} parameters - the parameter + * @return {Object} the result of visiting or null + * @private + */ + visitMapDeclaration(mapDeclaration, parameters) { + + const key = this.toXsType(mapDeclaration.getKey().getType(), mapDeclaration.getKey(), mapDeclaration); + const value = this.toXsType(mapDeclaration.getValue().getType(), mapDeclaration.getValue(), mapDeclaration); + + parameters.fileWriter.writeLine(0, `` ); + parameters.fileWriter.writeLine(1, ''); + parameters.fileWriter.writeLine(2, ''); + parameters.fileWriter.writeLine(3, ''); + parameters.fileWriter.writeLine(4, ``); + parameters.fileWriter.writeLine(4, ``); + parameters.fileWriter.writeLine(3, ''); + parameters.fileWriter.writeLine(2, ''); + parameters.fileWriter.writeLine(1, ''); + parameters.fileWriter.writeLine(0, ''); + + return null; + } + + /** * Visitor design pattern * @param {ClassDeclaration} classDeclaration - the object being visited @@ -256,10 +283,12 @@ class XmlSchemaVisitor { * Converts a Concerto type to a XML Schema type. Primitive types are converted * everything else is passed through unchanged. * @param {string} type - the fully qualified concerto type name + * @param {Object} mapElement - the mapElement representing either the Key or Value of a MapDeclaration + * @param {MapDeclaration} mapDeclaration - the object representing a MapDeclaration * @return {string} the corresponding type in XML Schema * @private */ - toXsType(type) { + toXsType(type, mapElement, mapDeclaration) { switch(type) { case 'DateTime': return 'xs:dateTime'; @@ -274,6 +303,14 @@ class XmlSchemaVisitor { case 'Integer': return 'xs:integer'; default: + if(!ModelUtil.getNamespace(type)) { + const typeDeclaration = mapDeclaration.getModelFile().getAllDeclarations().find(d => d.name === type); + if (typeDeclaration?.isClassDeclaration?.() || typeDeclaration?.isScalarDeclaration?.()) { + return `${ModelUtil.parseNamespace(mapDeclaration.getModelFile().getNamespace()).name}:${mapElement.getType()}`; + } else { + return `concerto:${mapElement.getType()}`; + } + } return `${ModelUtil.parseNamespace(ModelUtil.getNamespace(type)).name}:${ModelUtil.getShortName(type)}`; } } From 2c5e4a7bf1af4c09b25eee2c8e49c7083671d8dd Mon Sep 17 00:00:00 2001 From: Jonathan Casey Date: Fri, 13 Oct 2023 15:27:14 +0100 Subject: [PATCH 02/20] test(map): adds test coverage Signed-off-by: Jonathan Casey --- .../fromcto/xmlschema/xmlschemavisitor.js | 175 ++++++++++++++++++ 1 file changed, 175 insertions(+) diff --git a/test/codegen/fromcto/xmlschema/xmlschemavisitor.js b/test/codegen/fromcto/xmlschema/xmlschemavisitor.js index a8ceebad..0d7ba97d 100644 --- a/test/codegen/fromcto/xmlschema/xmlschemavisitor.js +++ b/test/codegen/fromcto/xmlschema/xmlschemavisitor.js @@ -22,6 +22,7 @@ const XmlSchemaVisitor = require('../../../../lib/codegen/fromcto/xmlschema/xmls const ClassDeclaration = require('@accordproject/concerto-core').ClassDeclaration; const EnumDeclaration = require('@accordproject/concerto-core').EnumDeclaration; +const MapDeclaration = require('@accordproject/concerto-core').MapDeclaration; const EnumValueDeclaration = require('@accordproject/concerto-core').EnumValueDeclaration; const Field = require('@accordproject/concerto-core').Field; const ModelFile = require('@accordproject/concerto-core').ModelFile; @@ -377,6 +378,180 @@ describe('XmlSchemaVisitor', function () { }); }); + + describe('visitMapDeclaration', () => { + it.skip('should write the map declaration for a map ', () => { + let acceptSpy = sinon.spy(); + + let param = { + fileWriter: mockFileWriter + }; + + const mockField = sinon.createStubInstance(Field); + const getAllDeclarations = sinon.stub(); + + mockField.dummy = 'Dummy Value'; + mockField.getModelFile.returns({ getAllDeclarations: getAllDeclarations }); + + const mockMapDeclaration = sinon.createStubInstance(MapDeclaration); + const findStub = sinon.stub(); + const getKeyType = sinon.stub(); + const getValueType = sinon.stub(); + + getAllDeclarations.returns({ find: findStub }); + findStub.returns(mockMapDeclaration); + getKeyType.returns('String'); + getValueType.returns('String'); + mockField.getName.returns('Map1'); + mockMapDeclaration.getName.returns('Map1'); + mockMapDeclaration.getKey.returns({ getType: getKeyType }); + mockMapDeclaration.getValue.returns({ getType: getValueType }); + + + xmlSchemaVisitor.visitMapDeclaration(mockMapDeclaration, param); + + param.fileWriter.writeLine.callCount.should.deep.equal(10); + param.fileWriter.writeLine.getCall(0).args.should.deep.equal([0, '']); + param.fileWriter.writeLine.getCall(1).args.should.deep.equal([1, '']); + param.fileWriter.writeLine.getCall(2).args.should.deep.equal([2, '']); + param.fileWriter.writeLine.getCall(3).args.should.deep.equal([3, '']); + param.fileWriter.writeLine.getCall(4).args.should.deep.equal([4, '']); + param.fileWriter.writeLine.getCall(5).args.should.deep.equal([4, '']); + param.fileWriter.writeLine.getCall(6).args.should.deep.equal([3, '']); + param.fileWriter.writeLine.getCall(7).args.should.deep.equal([2, '']); + param.fileWriter.writeLine.getCall(8).args.should.deep.equal([1, '']); + param.fileWriter.writeLine.getCall(9).args.should.deep.equal([0, '']); + }); + + + it.only('should write the map declaration for a map ', () => { + + let param = { + fileWriter: mockFileWriter + }; + + const mockField = sinon.createStubInstance(Field); + const getAllDeclarations = sinon.stub(); + + mockField.dummy = 'Dummy Value'; + mockField.getModelFile.returns({ getAllDeclarations: getAllDeclarations }); + + const mockMapDeclaration = sinon.createStubInstance(MapDeclaration); + const findStub = sinon.stub(); + const getKeyType = sinon.stub(); + const getValueType = sinon.stub(); + + getAllDeclarations.returns({ find: findStub }); + findStub.returns(mockMapDeclaration); + getKeyType.returns('String'); + getValueType.returns('SSN'); + mockField.getName.returns('Map1'); + mockMapDeclaration.getName.returns('Map1'); + mockMapDeclaration.getKey.returns({ getType: getKeyType }); + mockMapDeclaration.getValue.returns({ getType: getValueType }); + + + xmlSchemaVisitor.visitMapDeclaration(mockMapDeclaration, param); + + param.fileWriter.writeLine.callCount.should.deep.equal(10); + param.fileWriter.writeLine.getCall(0).args.should.deep.equal([0, '']); + param.fileWriter.writeLine.getCall(1).args.should.deep.equal([1, '']); + param.fileWriter.writeLine.getCall(2).args.should.deep.equal([2, '']); + param.fileWriter.writeLine.getCall(3).args.should.deep.equal([3, '']); + param.fileWriter.writeLine.getCall(4).args.should.deep.equal([4, '']); + param.fileWriter.writeLine.getCall(5).args.should.deep.equal([4, '']); + param.fileWriter.writeLine.getCall(6).args.should.deep.equal([3, '']); + param.fileWriter.writeLine.getCall(7).args.should.deep.equal([2, '']); + param.fileWriter.writeLine.getCall(8).args.should.deep.equal([1, '']); + param.fileWriter.writeLine.getCall(9).args.should.deep.equal([0, '']); + }); + + it.skip('should write the map declaration for a map ', () => { + + let param = { + fileWriter: mockFileWriter + }; + + const mockMapDeclaration = sinon.createStubInstance(MapDeclaration); + // const getModelFile = sinon.stub(); + const findStub = sinon.stub(); + const getKeyType = sinon.stub(); + const getValueType = sinon.stub(); + const getAllDeclarations = sinon.stub(); + + + mockMapDeclaration.getModelFile.returns({ getAllDeclarations: getAllDeclarations }); + + getAllDeclarations.returns({ find: findStub }); + findStub.returns(mockMapDeclaration); + getKeyType.returns('String'); + getValueType.returns('String'); + // mockField.getName.returns('Map1'); + mockMapDeclaration.getName.returns('Map1'); + mockMapDeclaration.getKey.returns({ getType: getKeyType }); + mockMapDeclaration.getValue.returns({ getType: getValueType }); + + + xmlSchemaVisitor.visitMapDeclaration(mockMapDeclaration, param); + + param.fileWriter.writeLine.callCount.should.deep.equal(10); + param.fileWriter.writeLine.getCall(0).args.should.deep.equal([0, '']); + param.fileWriter.writeLine.getCall(1).args.should.deep.equal([1, '']); + param.fileWriter.writeLine.getCall(2).args.should.deep.equal([2, '']); + param.fileWriter.writeLine.getCall(3).args.should.deep.equal([3, '']); + param.fileWriter.writeLine.getCall(4).args.should.deep.equal([4, '']); + param.fileWriter.writeLine.getCall(5).args.should.deep.equal([4, '']); + param.fileWriter.writeLine.getCall(6).args.should.deep.equal([3, '']); + param.fileWriter.writeLine.getCall(7).args.should.deep.equal([2, '']); + param.fileWriter.writeLine.getCall(8).args.should.deep.equal([1, '']); + param.fileWriter.writeLine.getCall(9).args.should.deep.equal([0, '']); + }); + + it.only('should write the map declaration for a map ', () => { + let acceptSpy = sinon.spy(); + + let param = { + fileWriter: mockFileWriter + }; + + const mockField = sinon.createStubInstance(Field); + const getAllDeclarations = sinon.stub(); + + mockField.dummy = 'Dummy Value'; + mockField.getModelFile.returns({ getAllDeclarations: getAllDeclarations }); + + const mockMapDeclaration = sinon.createStubInstance(MapDeclaration); + const findStub = sinon.stub(); + const getKeyType = sinon.stub(); + const getValueType = sinon.stub(); + + getAllDeclarations.returns({ find: findStub }); + findStub.returns(mockMapDeclaration); + getKeyType.returns('String'); + getValueType.returns('String'); + mockField.getName.returns('Map1'); + mockMapDeclaration.getName.returns('Map1'); + mockMapDeclaration.getKey.returns({ getType: getKeyType }); + mockMapDeclaration.getValue.returns({ getType: getValueType }); + + + xmlSchemaVisitor.visitMapDeclaration(mockMapDeclaration, param); + + param.fileWriter.writeLine.callCount.should.deep.equal(10); + param.fileWriter.writeLine.getCall(0).args.should.deep.equal([0, '']); + param.fileWriter.writeLine.getCall(1).args.should.deep.equal([1, '']); + param.fileWriter.writeLine.getCall(2).args.should.deep.equal([2, '']); + param.fileWriter.writeLine.getCall(3).args.should.deep.equal([3, '']); + param.fileWriter.writeLine.getCall(4).args.should.deep.equal([4, '']); + param.fileWriter.writeLine.getCall(5).args.should.deep.equal([4, '']); + param.fileWriter.writeLine.getCall(6).args.should.deep.equal([3, '']); + param.fileWriter.writeLine.getCall(7).args.should.deep.equal([2, '']); + param.fileWriter.writeLine.getCall(8).args.should.deep.equal([1, '']); + param.fileWriter.writeLine.getCall(9).args.should.deep.equal([0, '']); + }); + + }); + describe('visitField', () => { it('should write a line for a String field', () => { let param = { From 98d5f33f846f5157b6122c3c47ae1ca5f0bf00d8 Mon Sep 17 00:00:00 2001 From: Jonathan Casey Date: Fri, 13 Oct 2023 15:27:53 +0100 Subject: [PATCH 03/20] test(map): updates snapshots Signed-off-by: Jonathan Casey --- test/codegen/__snapshots__/codegen.js.snap | 5186 +------------------- 1 file changed, 60 insertions(+), 5126 deletions(-) diff --git a/test/codegen/__snapshots__/codegen.js.snap b/test/codegen/__snapshots__/codegen.js.snap index b031ca12..ba16a857 100644 --- a/test/codegen/__snapshots__/codegen.js.snap +++ b/test/codegen/__snapshots__/codegen.js.snap @@ -1,5131 +1,5 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'avro' 1`] = ` -{ - "key": "concerto@1.0.0.avdl", - "value": "@namespace("concerto@1.0.0") -protocol MyProtocol { - - - record Concept { - } - - record Asset { - string _identifier; - } - - record Participant { - string _identifier; - } - - record Transaction { - @logicalType("timestamp-micros") - long _timestamp; - } - - record Event { - @logicalType("timestamp-micros") - long _timestamp; - } - -} -", -} -`; - -exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'avro' 2`] = ` -{ - "key": "concerto.avdl", - "value": "@namespace("concerto") -protocol MyProtocol { - - - record Concept { - } - - record Asset { - string _identifier; - } - - record Participant { - string _identifier; - } - - record Transaction { - } - - record Event { - } - -} -", -} -`; - -exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'avro' 3`] = ` -{ - "key": "org.acme.hr.avdl", - "value": "@namespace("org.acme.hr") -protocol MyProtocol { - - import idl "concerto@1.0.0.avdl"; - - enum State { - MA, - NY, - CO, - WA, - IL, - CA - } - - record Address { - string street; - string city; - union { null, State } state; - string zipCode; - string country; - Map1 dictionary1; - Map2 dictionary2; - Map3 dictionary3; - Map4 dictionary4; - Map5 dictionary5; - Map6 dictionary6; - } - - record Company { - string name; - Address headquarters; - } - - enum Department { - Sales, - Marketing, - Finance, - HR, - Engineering, - Design - } - - record Equipment { - string serialNumber; - } - - enum LaptopMake { - Apple, - Microsoft - } - - record Laptop { - LaptopMake make; - string serialNumber; - } - - record Person { - string email; - string firstName; - string lastName; - union { null, string } middleNames; - Address homeAddress; - string ssn; - double height; - @logicalType("timestamp-micros") - long dob; - } - - record Employee { - string employeeId; - long salary; - int numDependents; - boolean retired; - Department department; - Address officeAddress; - array companyAssets; - union { null, string } manager; - string email; - string firstName; - string lastName; - union { null, string } middleNames; - Address homeAddress; - string ssn; - double height; - @logicalType("timestamp-micros") - long dob; - } - - record Contractor { - Company company; - union { null, string } manager; - string email; - string firstName; - string lastName; - union { null, string } middleNames; - Address homeAddress; - string ssn; - double height; - @logicalType("timestamp-micros") - long dob; - } - - record Manager { - union { null, array } reports; - string employeeId; - long salary; - int numDependents; - boolean retired; - Department department; - Address officeAddress; - array companyAssets; - union { null, string } manager; - string email; - string firstName; - string lastName; - union { null, string } middleNames; - Address homeAddress; - string ssn; - double height; - @logicalType("timestamp-micros") - long dob; - } - - record CompanyEvent { - @logicalType("timestamp-micros") - long _timestamp; - } - - record Onboarded { - string employee; - @logicalType("timestamp-micros") - long _timestamp; - } - - record ChangeOfAddress { - string Person; - Address newAddress; - @logicalType("timestamp-micros") - long _timestamp; - } - -} -", -} -`; - -exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'csharp' 1`] = ` -{ - "key": "concerto@1.0.0.cs", - "value": "namespace AccordProject.Concerto; -[AccordProject.Concerto.Type(Namespace = "concerto", Version = "1.0.0", Name = "Concept")] -[System.Text.Json.Serialization.JsonConverter(typeof(AccordProject.Concerto.ConcertoConverterFactorySystem))] -public abstract class Concept { - [System.Text.Json.Serialization.JsonPropertyName("$class")] - public virtual string _class { get; } = "concerto@1.0.0.Concept"; -} -[AccordProject.Concerto.Type(Namespace = "concerto", Version = "1.0.0", Name = "Asset")] -[System.Text.Json.Serialization.JsonConverter(typeof(AccordProject.Concerto.ConcertoConverterFactorySystem))] -public abstract class Asset : Concept { - [System.Text.Json.Serialization.JsonPropertyName("$class")] - public override string _class { get; } = "concerto@1.0.0.Asset"; - [AccordProject.Concerto.Identifier()] - [System.Text.Json.Serialization.JsonPropertyName("$identifier")] - public string _identifier { get; set; } -} -[AccordProject.Concerto.Type(Namespace = "concerto", Version = "1.0.0", Name = "Participant")] -[System.Text.Json.Serialization.JsonConverter(typeof(AccordProject.Concerto.ConcertoConverterFactorySystem))] -public abstract class Participant : Concept { - [System.Text.Json.Serialization.JsonPropertyName("$class")] - public override string _class { get; } = "concerto@1.0.0.Participant"; - [AccordProject.Concerto.Identifier()] - [System.Text.Json.Serialization.JsonPropertyName("$identifier")] - public string _identifier { get; set; } -} -[AccordProject.Concerto.Type(Namespace = "concerto", Version = "1.0.0", Name = "Transaction")] -[System.Text.Json.Serialization.JsonConverter(typeof(AccordProject.Concerto.ConcertoConverterFactorySystem))] -public abstract class Transaction : Concept { - [System.Text.Json.Serialization.JsonPropertyName("$class")] - public override string _class { get; } = "concerto@1.0.0.Transaction"; - [System.Text.Json.Serialization.JsonPropertyName("$timestamp")] - public System.DateTime _timestamp { get; set; } -} -[AccordProject.Concerto.Type(Namespace = "concerto", Version = "1.0.0", Name = "Event")] -[System.Text.Json.Serialization.JsonConverter(typeof(AccordProject.Concerto.ConcertoConverterFactorySystem))] -public abstract class Event : Concept { - [System.Text.Json.Serialization.JsonPropertyName("$class")] - public override string _class { get; } = "concerto@1.0.0.Event"; - [System.Text.Json.Serialization.JsonPropertyName("$timestamp")] - public System.DateTime _timestamp { get; set; } -} -", -} -`; - -exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'csharp' 2`] = ` -{ - "key": "concerto.cs", - "value": "namespace AccordProject.Concerto; -[AccordProject.Concerto.Type(Namespace = "concerto", Version = null, Name = "Concept")] -[System.Text.Json.Serialization.JsonConverter(typeof(AccordProject.Concerto.ConcertoConverterFactorySystem))] -public abstract class Concept { - [System.Text.Json.Serialization.JsonPropertyName("$class")] - public virtual string _class { get; } = "concerto.Concept"; -} -[AccordProject.Concerto.Type(Namespace = "concerto", Version = null, Name = "Asset")] -[System.Text.Json.Serialization.JsonConverter(typeof(AccordProject.Concerto.ConcertoConverterFactorySystem))] -public abstract class Asset : Concept { - [System.Text.Json.Serialization.JsonPropertyName("$class")] - public override string _class { get; } = "concerto.Asset"; - [AccordProject.Concerto.Identifier()] - [System.Text.Json.Serialization.JsonPropertyName("$identifier")] - public string _identifier { get; set; } -} -[AccordProject.Concerto.Type(Namespace = "concerto", Version = null, Name = "Participant")] -[System.Text.Json.Serialization.JsonConverter(typeof(AccordProject.Concerto.ConcertoConverterFactorySystem))] -public abstract class Participant : Concept { - [System.Text.Json.Serialization.JsonPropertyName("$class")] - public override string _class { get; } = "concerto.Participant"; - [AccordProject.Concerto.Identifier()] - [System.Text.Json.Serialization.JsonPropertyName("$identifier")] - public string _identifier { get; set; } -} -[AccordProject.Concerto.Type(Namespace = "concerto", Version = null, Name = "Transaction")] -[System.Text.Json.Serialization.JsonConverter(typeof(AccordProject.Concerto.ConcertoConverterFactorySystem))] -public abstract class Transaction : Concept { - [System.Text.Json.Serialization.JsonPropertyName("$class")] - public override string _class { get; } = "concerto.Transaction"; -} -[AccordProject.Concerto.Type(Namespace = "concerto", Version = null, Name = "Event")] -[System.Text.Json.Serialization.JsonConverter(typeof(AccordProject.Concerto.ConcertoConverterFactorySystem))] -public abstract class Event : Concept { - [System.Text.Json.Serialization.JsonPropertyName("$class")] - public override string _class { get; } = "concerto.Event"; -} -", -} -`; - -exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'csharp' 3`] = ` -{ - "key": "org.acme.hr.cs", - "value": "namespace org.acme.hr; -using AccordProject.Concerto; -[System.Text.Json.Serialization.JsonConverter(typeof(System.Text.Json.Serialization.JsonStringEnumConverter))] -public enum State { - MA, - NY, - CO, - WA, - IL, - CA, -} -[AccordProject.Concerto.Type(Namespace = "org.acme.hr", Version = null, Name = "Address")] -[System.Text.Json.Serialization.JsonConverter(typeof(AccordProject.Concerto.ConcertoConverterFactorySystem))] -public class Address : Concept { - [System.Text.Json.Serialization.JsonPropertyName("$class")] - public override string _class { get; } = "org.acme.hr.Address"; - public string street { get; set; } - public string city { get; set; } - public State? state { get; set; } - public string zipCode { get; set; } - public string country { get; set; } - public Dictionary dictionary1 { get; set; } - public Dictionary dictionary2 { get; set; } - public Dictionary dictionary3 { get; set; } - public Dictionary dictionary4 { get; set; } - public Dictionary dictionary5 { get; set; } - public Dictionary dictionary6 { get; set; } -} -//Dummy implementation of the scalar declaration to avoid compilation errors. -class Time_Dummy {} -[AccordProject.Concerto.Type(Namespace = "org.acme.hr", Version = null, Name = "Company")] -[System.Text.Json.Serialization.JsonConverter(typeof(AccordProject.Concerto.ConcertoConverterFactorySystem))] -public class Company : Concept { - [System.Text.Json.Serialization.JsonPropertyName("$class")] - public override string _class { get; } = "org.acme.hr.Company"; - public string name { get; set; } - public Address headquarters { get; set; } -} -[System.Text.Json.Serialization.JsonConverter(typeof(System.Text.Json.Serialization.JsonStringEnumConverter))] -public enum Department { - Sales, - Marketing, - Finance, - HR, - Engineering, - Design, -} -[AccordProject.Concerto.Type(Namespace = "org.acme.hr", Version = null, Name = "Equipment")] -[System.Text.Json.Serialization.JsonConverter(typeof(AccordProject.Concerto.ConcertoConverterFactorySystem))] -public abstract class Equipment : Asset { - [System.Text.Json.Serialization.JsonPropertyName("$class")] - public override string _class { get; } = "org.acme.hr.Equipment"; - [AccordProject.Concerto.Identifier()] - public string serialNumber { get; set; } -} -[System.Text.Json.Serialization.JsonConverter(typeof(System.Text.Json.Serialization.JsonStringEnumConverter))] -public enum LaptopMake { - Apple, - Microsoft, -} -[AccordProject.Concerto.Type(Namespace = "org.acme.hr", Version = null, Name = "Laptop")] -[System.Text.Json.Serialization.JsonConverter(typeof(AccordProject.Concerto.ConcertoConverterFactorySystem))] -public class Laptop : Equipment { - [System.Text.Json.Serialization.JsonPropertyName("$class")] - public override string _class { get; } = "org.acme.hr.Laptop"; - public LaptopMake make { get; set; } -} -//Dummy implementation of the scalar declaration to avoid compilation errors. -class SSN_Dummy {} -[AccordProject.Concerto.Type(Namespace = "org.acme.hr", Version = null, Name = "Person")] -[System.Text.Json.Serialization.JsonConverter(typeof(AccordProject.Concerto.ConcertoConverterFactorySystem))] -public abstract class Person : Participant { - [System.Text.Json.Serialization.JsonPropertyName("$class")] - public override string _class { get; } = "org.acme.hr.Person"; - [AccordProject.Concerto.Identifier()] - public string email { get; set; } - public string firstName { get; set; } - public string lastName { get; set; } - public string? middleNames { get; set; } - public Address homeAddress { get; set; } - [System.ComponentModel.DataAnnotations.RegularExpression(@"\\d{3}-\\d{2}-\\{4}+", ErrorMessage = "Invalid characters")] - public string ssn { get; set; } - public float height { get; set; } - public System.DateTime dob { get; set; } -} -[AccordProject.Concerto.Type(Namespace = "org.acme.hr", Version = null, Name = "Employee")] -[System.Text.Json.Serialization.JsonConverter(typeof(AccordProject.Concerto.ConcertoConverterFactorySystem))] -public class Employee : Person { - [System.Text.Json.Serialization.JsonPropertyName("$class")] - public override string _class { get; } = "org.acme.hr.Employee"; - public string employeeId { get; set; } - public long salary { get; set; } - public int numDependents { get; set; } - public bool retired { get; set; } - public Department department { get; set; } - public Address officeAddress { get; set; } - public Equipment[] companyAssets { get; set; } - public Manager manager { get; set; } -} -[AccordProject.Concerto.Type(Namespace = "org.acme.hr", Version = null, Name = "Contractor")] -[System.Text.Json.Serialization.JsonConverter(typeof(AccordProject.Concerto.ConcertoConverterFactorySystem))] -public class Contractor : Person { - [System.Text.Json.Serialization.JsonPropertyName("$class")] - public override string _class { get; } = "org.acme.hr.Contractor"; - public Company company { get; set; } - public Manager manager { get; set; } -} -[AccordProject.Concerto.Type(Namespace = "org.acme.hr", Version = null, Name = "Manager")] -[System.Text.Json.Serialization.JsonConverter(typeof(AccordProject.Concerto.ConcertoConverterFactorySystem))] -public class Manager : Employee { - [System.Text.Json.Serialization.JsonPropertyName("$class")] - public override string _class { get; } = "org.acme.hr.Manager"; - public Person[] reports { get; set; } -} -[AccordProject.Concerto.Type(Namespace = "org.acme.hr", Version = null, Name = "CompanyEvent")] -[System.Text.Json.Serialization.JsonConverter(typeof(AccordProject.Concerto.ConcertoConverterFactorySystem))] -public class CompanyEvent : Event { - [System.Text.Json.Serialization.JsonPropertyName("$class")] - public override string _class { get; } = "org.acme.hr.CompanyEvent"; -} -[AccordProject.Concerto.Type(Namespace = "org.acme.hr", Version = null, Name = "Onboarded")] -[System.Text.Json.Serialization.JsonConverter(typeof(AccordProject.Concerto.ConcertoConverterFactorySystem))] -public class Onboarded : CompanyEvent { - [System.Text.Json.Serialization.JsonPropertyName("$class")] - public override string _class { get; } = "org.acme.hr.Onboarded"; - public Employee employee { get; set; } -} -[AccordProject.Concerto.Type(Namespace = "org.acme.hr", Version = null, Name = "ChangeOfAddress")] -[System.Text.Json.Serialization.JsonConverter(typeof(AccordProject.Concerto.ConcertoConverterFactorySystem))] -public class ChangeOfAddress : Transaction { - [System.Text.Json.Serialization.JsonPropertyName("$class")] - public override string _class { get; } = "org.acme.hr.ChangeOfAddress"; - public Person Person { get; set; } - public Address newAddress { get; set; } -} -", -} -`; - -exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'golang' 1`] = ` -{ - "key": "concerto@1.0.0.go", - "value": "// Package concerto_1_0_0 contains domain objects and was generated from Concerto namespace concerto@1.0.0. -package concerto_1_0_0 -import "time" - -type Concept struct { -} -type Asset struct { - Concept - Identifier string \`json:"$identifier"\` -} -type Participant struct { - Concept - Identifier string \`json:"$identifier"\` -} -type Transaction struct { - Concept - Timestamp time.Time \`json:"$timestamp"\` -} -type Event struct { - Concept - Timestamp time.Time \`json:"$timestamp"\` -} -", -} -`; - -exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'golang' 2`] = ` -{ - "key": "concerto.go", - "value": "// Package concerto contains domain objects and was generated from Concerto namespace concerto. -package concerto - -type Concept struct { -} -type Asset struct { - Concept - Identifier string \`json:"$identifier"\` -} -type Participant struct { - Concept - Identifier string \`json:"$identifier"\` -} -type Transaction struct { - Concept -} -type Event struct { - Concept -} -", -} -`; - -exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'golang' 3`] = ` -{ - "key": "org.acme.hr.go", - "value": "// Package org_acme_hr contains domain objects and was generated from Concerto namespace org.acme.hr. -package org_acme_hr -import "time" -import "concerto_1_0_0"; - -type State int -const ( - MA State = 1 + iota - NY - CO - WA - IL - CA -) -type Address struct { - concerto_1_0_0.Concept - Street string \`json:"street"\` - City string \`json:"city"\` - State State \`json:"state"\` - ZipCode string \`json:"zipCode"\` - Country string \`json:"country"\` - Dictionary1 Map1 \`json:"dictionary1"\` - Dictionary2 Map2 \`json:"dictionary2"\` - Dictionary3 Map3 \`json:"dictionary3"\` - Dictionary4 Map4 \`json:"dictionary4"\` - Dictionary5 Map5 \`json:"dictionary5"\` - Dictionary6 Map6 \`json:"dictionary6"\` -} -type Company struct { - concerto_1_0_0.Concept - Name string \`json:"name"\` - Headquarters Address \`json:"headquarters"\` -} -type Department int -const ( - Sales Department = 1 + iota - Marketing - Finance - HR - Engineering - Design -) -type Equipment struct { - concerto_1_0_0.Asset - SerialNumber string \`json:"serialNumber"\` -} -type LaptopMake int -const ( - Apple LaptopMake = 1 + iota - Microsoft -) -type Laptop struct { - Equipment - Make LaptopMake \`json:"make"\` -} -type Person struct { - concerto_1_0_0.Participant - Email string \`json:"email"\` - FirstName string \`json:"firstName"\` - LastName string \`json:"lastName"\` - MiddleNames string \`json:"middleNames"\` - HomeAddress Address \`json:"homeAddress"\` - Ssn string \`json:"ssn"\` - Height float64 \`json:"height"\` - Dob time.Time \`json:"dob"\` -} -type Employee struct { - Person - EmployeeId string \`json:"employeeId"\` - Salary int64 \`json:"salary"\` - NumDependents int32 \`json:"numDependents"\` - Retired bool \`json:"retired"\` - Department Department \`json:"department"\` - OfficeAddress Address \`json:"officeAddress"\` - CompanyAssets []Equipment \`json:"companyAssets"\` - Manager *Manager \`json:"manager"\` -} -type Contractor struct { - Person - Company Company \`json:"company"\` - Manager *Manager \`json:"manager"\` -} -type Manager struct { - Employee - Reports []*Person \`json:"reports"\` -} -type CompanyEvent struct { - concerto_1_0_0.Event -} -type Onboarded struct { - CompanyEvent - Employee *Employee \`json:"employee"\` -} -type ChangeOfAddress struct { - concerto_1_0_0.Transaction - Person *Person \`json:"Person"\` - NewAddress Address \`json:"newAddress"\` -} -", -} -`; - -exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'graphql' 1`] = ` -{ - "key": "model.gql", - "value": "directive @resource on OBJECT | FIELD_DEFINITION -scalar DateTime -# namespace org.acme.hr -enum State { - MA - NY - CO - WA - IL - CA -} -type Address { - street: String! - city: String! - state: State - zipCode: String! - country: String! - dictionary1: Map1! - dictionary2: Map2! - dictionary3: Map3! - dictionary4: Map4! - dictionary5: Map5! - dictionary6: Map6! -} -type Company { - name: String! - headquarters: Address! -} -enum Department { - Sales - Marketing - Finance - HR - Engineering - Design -} -type Equipment @resource { - serialNumber: String! - _identifier: String! -} -enum LaptopMake { - Apple - Microsoft -} -type Laptop { - make: LaptopMake! - serialNumber: String! - _identifier: String! -} -type Person @resource { - email: String! - firstName: String! - lastName: String! - middleNames: String - homeAddress: Address! - ssn: String! - height: Float! - dob: DateTime! - _identifier: String! -} -type Employee { - employeeId: String! - salary: Int! - numDependents: Int! - retired: Boolean! - department: Department! - officeAddress: Address! - companyAssets: [Equipment]! - manager: ID # Manager - email: String! - firstName: String! - lastName: String! - middleNames: String - homeAddress: Address! - ssn: String! - height: Float! - dob: DateTime! - _identifier: String! -} -type Contractor { - company: Company! - manager: ID # Manager - email: String! - firstName: String! - lastName: String! - middleNames: String - homeAddress: Address! - ssn: String! - height: Float! - dob: DateTime! - _identifier: String! -} -type Manager { - reports: [ID] # Person - employeeId: String! - salary: Int! - numDependents: Int! - retired: Boolean! - department: Department! - officeAddress: Address! - companyAssets: [Equipment]! - manager: ID # Manager - email: String! - firstName: String! - lastName: String! - middleNames: String - homeAddress: Address! - ssn: String! - height: Float! - dob: DateTime! - _identifier: String! -} -type CompanyEvent { - _timestamp: DateTime! -} -type Onboarded { - employee: ID! # Employee - _timestamp: DateTime! -} -type ChangeOfAddress { - Person: ID! # Person - newAddress: Address! - _timestamp: DateTime! -} -", -} -`; - -exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'java' 1`] = ` -{ - "key": "concerto/Concept.java", - "value": "// this code is generated and should not be modified -package concerto; - -import com.fasterxml.jackson.annotation.*; - -@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, property = "$class") -public abstract class Concept { -} -", -} -`; - -exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'java' 2`] = ` -{ - "key": "concerto/Asset.java", - "value": "// this code is generated and should not be modified -package concerto; - -import com.fasterxml.jackson.annotation.*; - -@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, property = "$class") -@JsonIgnoreProperties({"id"}) -@JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "$identifier") -public abstract class Asset extends Concept { - private String $id; - @JsonProperty("$id") - public String get$id() { - return $id; - } - @JsonProperty("$id") - public void set$id(String i) { - $id = i; - } - - // the accessor for the identifying field - public String getID() { - return this.get$identifier(); - } - - private String $identifier; - public String get$identifier() { - return this.$identifier; - } - public void set$identifier(String $identifier) { - this.$identifier = $identifier; - } -} -", -} -`; - -exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'java' 3`] = ` -{ - "key": "concerto/Participant.java", - "value": "// this code is generated and should not be modified -package concerto; - -import com.fasterxml.jackson.annotation.*; - -@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, property = "$class") -@JsonIgnoreProperties({"id"}) -@JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "$identifier") -public abstract class Participant extends Concept { - private String $id; - @JsonProperty("$id") - public String get$id() { - return $id; - } - @JsonProperty("$id") - public void set$id(String i) { - $id = i; - } - - // the accessor for the identifying field - public String getID() { - return this.get$identifier(); - } - - private String $identifier; - public String get$identifier() { - return this.$identifier; - } - public void set$identifier(String $identifier) { - this.$identifier = $identifier; - } -} -", -} -`; - -exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'java' 4`] = ` -{ - "key": "concerto/Transaction.java", - "value": "// this code is generated and should not be modified -package concerto; - -import com.fasterxml.jackson.annotation.*; - -@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, property = "$class") -public abstract class Transaction extends Concept { -} -", -} -`; - -exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'java' 5`] = ` -{ - "key": "concerto/Event.java", - "value": "// this code is generated and should not be modified -package concerto; - -import com.fasterxml.jackson.annotation.*; - -@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, property = "$class") -public abstract class Event extends Concept { -} -", -} -`; - -exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'java' 6`] = ` -{ - "key": "org/acme/hr/State.java", - "value": "// this code is generated and should not be modified -package org.acme.hr; - -import com.fasterxml.jackson.annotation.*; -@JsonIgnoreProperties({"$class"}) -public enum State { - MA, - NY, - CO, - WA, - IL, - CA, -} -", -} -`; - -exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'java' 7`] = ` -{ - "key": "org/acme/hr/Address.java", - "value": "// this code is generated and should not be modified -package org.acme.hr; - -import concerto.Concept; -import concerto.Asset; -import concerto.Transaction; -import concerto.Participant; -import concerto.Event; -import com.fasterxml.jackson.annotation.*; - -@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, property = "$class") -public class Address extends Concept { - private String street; - private String city; - private State state; - private String zipCode; - private String country; - private Map1 dictionary1; - private Map2 dictionary2; - private Map3 dictionary3; - private Map4 dictionary4; - private Map5 dictionary5; - private Map6 dictionary6; - public String getStreet() { - return this.street; - } - public String getCity() { - return this.city; - } - public State getState() { - return this.state; - } - public String getZipCode() { - return this.zipCode; - } - public String getCountry() { - return this.country; - } - public Map1 getDictionary1() { - return this.dictionary1; - } - public Map2 getDictionary2() { - return this.dictionary2; - } - public Map3 getDictionary3() { - return this.dictionary3; - } - public Map4 getDictionary4() { - return this.dictionary4; - } - public Map5 getDictionary5() { - return this.dictionary5; - } - public Map6 getDictionary6() { - return this.dictionary6; - } - public void setStreet(String street) { - this.street = street; - } - public void setCity(String city) { - this.city = city; - } - public void setState(State state) { - this.state = state; - } - public void setZipCode(String zipCode) { - this.zipCode = zipCode; - } - public void setCountry(String country) { - this.country = country; - } - public void setDictionary1(Map1 dictionary1) { - this.dictionary1 = dictionary1; - } - public void setDictionary2(Map2 dictionary2) { - this.dictionary2 = dictionary2; - } - public void setDictionary3(Map3 dictionary3) { - this.dictionary3 = dictionary3; - } - public void setDictionary4(Map4 dictionary4) { - this.dictionary4 = dictionary4; - } - public void setDictionary5(Map5 dictionary5) { - this.dictionary5 = dictionary5; - } - public void setDictionary6(Map6 dictionary6) { - this.dictionary6 = dictionary6; - } -} -", -} -`; - -exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'java' 8`] = ` -{ - "key": "org/acme/hr/Company.java", - "value": "// this code is generated and should not be modified -package org.acme.hr; - -import concerto.Concept; -import concerto.Asset; -import concerto.Transaction; -import concerto.Participant; -import concerto.Event; -import com.fasterxml.jackson.annotation.*; - -@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, property = "$class") -public class Company extends Concept { - private String name; - private Address headquarters; - public String getName() { - return this.name; - } - public Address getHeadquarters() { - return this.headquarters; - } - public void setName(String name) { - this.name = name; - } - public void setHeadquarters(Address headquarters) { - this.headquarters = headquarters; - } -} -", -} -`; - -exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'java' 9`] = ` -{ - "key": "org/acme/hr/Department.java", - "value": "// this code is generated and should not be modified -package org.acme.hr; - -import com.fasterxml.jackson.annotation.*; -@JsonIgnoreProperties({"$class"}) -public enum Department { - Sales, - Marketing, - Finance, - HR, - Engineering, - Design, -} -", -} -`; - -exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'java' 10`] = ` -{ - "key": "org/acme/hr/Equipment.java", - "value": "// this code is generated and should not be modified -package org.acme.hr; - -import concerto.Concept; -import concerto.Asset; -import concerto.Transaction; -import concerto.Participant; -import concerto.Event; -import com.fasterxml.jackson.annotation.*; - -@JsonIgnoreProperties({"id"}) -@JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "serialNumber") -public abstract class Equipment extends Asset { - - // the accessor for the identifying field - public String getID() { - return this.getSerialNumber(); - } - - private String serialNumber; - public String getSerialNumber() { - return this.serialNumber; - } - public void setSerialNumber(String serialNumber) { - this.serialNumber = serialNumber; - } -} -", -} -`; - -exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'java' 11`] = ` -{ - "key": "org/acme/hr/LaptopMake.java", - "value": "// this code is generated and should not be modified -package org.acme.hr; - -import com.fasterxml.jackson.annotation.*; -@JsonIgnoreProperties({"$class"}) -public enum LaptopMake { - Apple, - Microsoft, -} -", -} -`; - -exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'java' 12`] = ` -{ - "key": "org/acme/hr/Laptop.java", - "value": "// this code is generated and should not be modified -package org.acme.hr; - -import concerto.Concept; -import concerto.Asset; -import concerto.Transaction; -import concerto.Participant; -import concerto.Event; -import com.fasterxml.jackson.annotation.*; - -@JsonIgnoreProperties({"id"}) -@JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "serialNumber") -public class Laptop extends Equipment { - - // the accessor for the identifying field - public String getID() { - return this.getSerialNumber(); - } - - private LaptopMake make; - public LaptopMake getMake() { - return this.make; - } - public void setMake(LaptopMake make) { - this.make = make; - } -} -", -} -`; - -exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'java' 13`] = ` -{ - "key": "org/acme/hr/Person.java", - "value": "// this code is generated and should not be modified -package org.acme.hr; - -import concerto.Concept; -import concerto.Asset; -import concerto.Transaction; -import concerto.Participant; -import concerto.Event; -import com.fasterxml.jackson.annotation.*; - -@JsonIgnoreProperties({"id"}) -@JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "email") -public abstract class Person extends Participant { - - // the accessor for the identifying field - public String getID() { - return this.getEmail(); - } - - private String email; - private String firstName; - private String lastName; - private String middleNames; - private Address homeAddress; - private String ssn; - private double height; - private java.util.Date dob; - public String getEmail() { - return this.email; - } - public String getFirstName() { - return this.firstName; - } - public String getLastName() { - return this.lastName; - } - public String getMiddleNames() { - return this.middleNames; - } - public Address getHomeAddress() { - return this.homeAddress; - } - public String getSsn() { - return this.ssn; - } - public double getHeight() { - return this.height; - } - public java.util.Date getDob() { - return this.dob; - } - public void setEmail(String email) { - this.email = email; - } - public void setFirstName(String firstName) { - this.firstName = firstName; - } - public void setLastName(String lastName) { - this.lastName = lastName; - } - public void setMiddleNames(String middleNames) { - this.middleNames = middleNames; - } - public void setHomeAddress(Address homeAddress) { - this.homeAddress = homeAddress; - } - public void setSsn(String ssn) { - this.ssn = ssn; - } - public void setHeight(double height) { - this.height = height; - } - public void setDob(java.util.Date dob) { - this.dob = dob; - } -} -", -} -`; - -exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'java' 14`] = ` -{ - "key": "org/acme/hr/Employee.java", - "value": "// this code is generated and should not be modified -package org.acme.hr; - -import concerto.Concept; -import concerto.Asset; -import concerto.Transaction; -import concerto.Participant; -import concerto.Event; -import com.fasterxml.jackson.annotation.*; - -@JsonIgnoreProperties({"id"}) -@JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "email") -public class Employee extends Person { - - // the accessor for the identifying field - public String getID() { - return this.getEmail(); - } - - private String employeeId; - private long salary; - private int numDependents; - private boolean retired; - private Department department; - private Address officeAddress; - private Equipment[] companyAssets; - private Manager manager; - public String getEmployeeId() { - return this.employeeId; - } - public long getSalary() { - return this.salary; - } - public int getNumDependents() { - return this.numDependents; - } - public boolean getRetired() { - return this.retired; - } - public Department getDepartment() { - return this.department; - } - public Address getOfficeAddress() { - return this.officeAddress; - } - public Equipment[] getCompanyAssets() { - return this.companyAssets; - } - public Manager getManager() { - return this.manager; - } - public void setEmployeeId(String employeeId) { - this.employeeId = employeeId; - } - public void setSalary(long salary) { - this.salary = salary; - } - public void setNumDependents(int numDependents) { - this.numDependents = numDependents; - } - public void setRetired(boolean retired) { - this.retired = retired; - } - public void setDepartment(Department department) { - this.department = department; - } - public void setOfficeAddress(Address officeAddress) { - this.officeAddress = officeAddress; - } - public void setCompanyAssets(Equipment[] companyAssets) { - this.companyAssets = companyAssets; - } - public void setManager(Manager manager) { - this.manager = manager; - } -} -", -} -`; - -exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'java' 15`] = ` -{ - "key": "org/acme/hr/Contractor.java", - "value": "// this code is generated and should not be modified -package org.acme.hr; - -import concerto.Concept; -import concerto.Asset; -import concerto.Transaction; -import concerto.Participant; -import concerto.Event; -import com.fasterxml.jackson.annotation.*; - -@JsonIgnoreProperties({"id"}) -@JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "email") -public class Contractor extends Person { - - // the accessor for the identifying field - public String getID() { - return this.getEmail(); - } - - private Company company; - private Manager manager; - public Company getCompany() { - return this.company; - } - public Manager getManager() { - return this.manager; - } - public void setCompany(Company company) { - this.company = company; - } - public void setManager(Manager manager) { - this.manager = manager; - } -} -", -} -`; - -exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'java' 16`] = ` -{ - "key": "org/acme/hr/Manager.java", - "value": "// this code is generated and should not be modified -package org.acme.hr; - -import concerto.Concept; -import concerto.Asset; -import concerto.Transaction; -import concerto.Participant; -import concerto.Event; -import com.fasterxml.jackson.annotation.*; - -@JsonIgnoreProperties({"id"}) -@JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "email") -public class Manager extends Employee { - - // the accessor for the identifying field - public String getID() { - return this.getEmail(); - } - - private Person[] reports; - public Person[] getReports() { - return this.reports; - } - public void setReports(Person[] reports) { - this.reports = reports; - } -} -", -} -`; - -exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'java' 17`] = ` -{ - "key": "org/acme/hr/CompanyEvent.java", - "value": "// this code is generated and should not be modified -package org.acme.hr; - -import concerto.Concept; -import concerto.Asset; -import concerto.Transaction; -import concerto.Participant; -import concerto.Event; -import com.fasterxml.jackson.annotation.*; - -public class CompanyEvent extends Event { -} -", -} -`; - -exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'java' 18`] = ` -{ - "key": "org/acme/hr/Onboarded.java", - "value": "// this code is generated and should not be modified -package org.acme.hr; - -import concerto.Concept; -import concerto.Asset; -import concerto.Transaction; -import concerto.Participant; -import concerto.Event; -import com.fasterxml.jackson.annotation.*; - -public class Onboarded extends CompanyEvent { - private Employee employee; - public Employee getEmployee() { - return this.employee; - } - public void setEmployee(Employee employee) { - this.employee = employee; - } -} -", -} -`; - -exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'java' 19`] = ` -{ - "key": "org/acme/hr/ChangeOfAddress.java", - "value": "// this code is generated and should not be modified -package org.acme.hr; - -import concerto.Concept; -import concerto.Asset; -import concerto.Transaction; -import concerto.Participant; -import concerto.Event; -import com.fasterxml.jackson.annotation.*; - -public class ChangeOfAddress extends Transaction { - private Person Person; - private Address newAddress; - public Person getPerson() { - return this.Person; - } - public Address getNewAddress() { - return this.newAddress; - } - public void setPerson(Person Person) { - this.Person = Person; - } - public void setNewAddress(Address newAddress) { - this.newAddress = newAddress; - } -} -", -} -`; - -exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'jsonschema' 1`] = ` -{ - "key": "schema.json", - "value": "{ - "$schema": "http://json-schema.org/draft-07/schema#", - "definitions": { - "org.acme.hr.State": { - "title": "State", - "description": "An instance of org.acme.hr.State", - "enum": [ - "MA", - "NY", - "CO", - "WA", - "IL", - "CA" - ] - }, - "org.acme.hr.Address": { - "title": "Address", - "description": "An instance of org.acme.hr.Address", - "type": "object", - "properties": { - "$class": { - "type": "string", - "default": "org.acme.hr.Address", - "pattern": "^org\\\\.acme\\\\.hr\\\\.Address$", - "description": "The class identifier for org.acme.hr.Address" - }, - "street": { - "type": "string" - }, - "city": { - "type": "string" - }, - "state": { - "$ref": "#/definitions/org.acme.hr.State" - }, - "zipCode": { - "type": "string" - }, - "country": { - "type": "string" - } - }, - "required": [ - "$class", - "street", - "city", - "zipCode", - "country", - "dictionary1", - "dictionary2", - "dictionary3", - "dictionary4", - "dictionary5", - "dictionary6" - ] - }, - "org.acme.hr.Time": { - "format": "date-time", - "type": "string" - }, - "org.acme.hr.Company": { - "title": "Company", - "description": "An instance of org.acme.hr.Company", - "type": "object", - "properties": { - "$class": { - "type": "string", - "default": "org.acme.hr.Company", - "pattern": "^org\\\\.acme\\\\.hr\\\\.Company$", - "description": "The class identifier for org.acme.hr.Company" - }, - "name": { - "type": "string" - }, - "headquarters": { - "$ref": "#/definitions/org.acme.hr.Address" - } - }, - "required": [ - "$class", - "name", - "headquarters" - ] - }, - "org.acme.hr.Department": { - "title": "Department", - "description": "An instance of org.acme.hr.Department", - "enum": [ - "Sales", - "Marketing", - "Finance", - "HR", - "Engineering", - "Design" - ] - }, - "org.acme.hr.Equipment": { - "title": "Equipment", - "description": "An instance of org.acme.hr.Equipment", - "type": "object", - "properties": { - "$class": { - "type": "string", - "default": "org.acme.hr.Equipment", - "pattern": "^org\\\\.acme\\\\.hr\\\\.Equipment$", - "description": "The class identifier for org.acme.hr.Equipment" - }, - "serialNumber": { - "type": "string", - "description": "The instance identifier for this type" - } - }, - "required": [ - "$class", - "serialNumber" - ], - "$decorators": { - "resource": [] - } - }, - "org.acme.hr.LaptopMake": { - "title": "LaptopMake", - "description": "An instance of org.acme.hr.LaptopMake", - "enum": [ - "Apple", - "Microsoft" - ] - }, - "org.acme.hr.Laptop": { - "title": "Laptop", - "description": "An instance of org.acme.hr.Laptop", - "type": "object", - "properties": { - "$class": { - "type": "string", - "default": "org.acme.hr.Laptop", - "pattern": "^org\\\\.acme\\\\.hr\\\\.Laptop$", - "description": "The class identifier for org.acme.hr.Laptop" - }, - "make": { - "$ref": "#/definitions/org.acme.hr.LaptopMake" - }, - "serialNumber": { - "type": "string", - "description": "The instance identifier for this type" - } - }, - "required": [ - "$class", - "make", - "serialNumber" - ] - }, - "org.acme.hr.SSN": { - "type": "string", - "pattern": "\\\\d{3}-\\\\d{2}-\\\\{4}+" - }, - "org.acme.hr.Person": { - "title": "Person", - "description": "An instance of org.acme.hr.Person", - "type": "object", - "properties": { - "$class": { - "type": "string", - "default": "org.acme.hr.Person", - "pattern": "^org\\\\.acme\\\\.hr\\\\.Person$", - "description": "The class identifier for org.acme.hr.Person" - }, - "email": { - "type": "string", - "description": "The instance identifier for this type" - }, - "firstName": { - "type": "string" - }, - "lastName": { - "type": "string" - }, - "middleNames": { - "type": "string" - }, - "homeAddress": { - "$ref": "#/definitions/org.acme.hr.Address" - }, - "ssn": { - "default": "000-00-0000", - "type": "string", - "pattern": "\\\\d{3}-\\\\d{2}-\\\\{4}+" - }, - "height": { - "type": "number" - }, - "dob": { - "format": "date-time", - "type": "string" - } - }, - "required": [ - "$class", - "email", - "firstName", - "lastName", - "homeAddress", - "ssn", - "height", - "dob" - ], - "$decorators": { - "resource": [] - } - }, - "org.acme.hr.Employee": { - "title": "Employee", - "description": "An instance of org.acme.hr.Employee", - "type": "object", - "properties": { - "$class": { - "type": "string", - "default": "org.acme.hr.Employee", - "pattern": "^org\\\\.acme\\\\.hr\\\\.Employee$", - "description": "The class identifier for org.acme.hr.Employee" - }, - "employeeId": { - "type": "string" - }, - "salary": { - "type": "integer" - }, - "numDependents": { - "type": "integer" - }, - "retired": { - "type": "boolean" - }, - "department": { - "$ref": "#/definitions/org.acme.hr.Department" - }, - "officeAddress": { - "$ref": "#/definitions/org.acme.hr.Address" - }, - "companyAssets": { - "type": "array", - "items": { - "anyOf": [ - { - "$ref": "#/definitions/org.acme.hr.Equipment" - }, - { - "$ref": "#/definitions/org.acme.hr.Laptop" - } - ] - } - }, - "manager": { - "type": "string", - "description": "The identifier of an instance of org.acme.hr.Manager" - }, - "email": { - "type": "string", - "description": "The instance identifier for this type" - }, - "firstName": { - "type": "string" - }, - "lastName": { - "type": "string" - }, - "middleNames": { - "type": "string" - }, - "homeAddress": { - "$ref": "#/definitions/org.acme.hr.Address" - }, - "ssn": { - "default": "000-00-0000", - "type": "string", - "pattern": "\\\\d{3}-\\\\d{2}-\\\\{4}+" - }, - "height": { - "type": "number" - }, - "dob": { - "format": "date-time", - "type": "string" - } - }, - "required": [ - "$class", - "employeeId", - "salary", - "numDependents", - "retired", - "department", - "officeAddress", - "companyAssets", - "email", - "firstName", - "lastName", - "homeAddress", - "ssn", - "height", - "dob" - ] - }, - "org.acme.hr.Contractor": { - "title": "Contractor", - "description": "An instance of org.acme.hr.Contractor", - "type": "object", - "properties": { - "$class": { - "type": "string", - "default": "org.acme.hr.Contractor", - "pattern": "^org\\\\.acme\\\\.hr\\\\.Contractor$", - "description": "The class identifier for org.acme.hr.Contractor" - }, - "company": { - "$ref": "#/definitions/org.acme.hr.Company" - }, - "manager": { - "type": "string", - "description": "The identifier of an instance of org.acme.hr.Manager" - }, - "email": { - "type": "string", - "description": "The instance identifier for this type" - }, - "firstName": { - "type": "string" - }, - "lastName": { - "type": "string" - }, - "middleNames": { - "type": "string" - }, - "homeAddress": { - "$ref": "#/definitions/org.acme.hr.Address" - }, - "ssn": { - "default": "000-00-0000", - "type": "string", - "pattern": "\\\\d{3}-\\\\d{2}-\\\\{4}+" - }, - "height": { - "type": "number" - }, - "dob": { - "format": "date-time", - "type": "string" - } - }, - "required": [ - "$class", - "company", - "email", - "firstName", - "lastName", - "homeAddress", - "ssn", - "height", - "dob" - ] - }, - "org.acme.hr.Manager": { - "title": "Manager", - "description": "An instance of org.acme.hr.Manager", - "type": "object", - "properties": { - "$class": { - "type": "string", - "default": "org.acme.hr.Manager", - "pattern": "^org\\\\.acme\\\\.hr\\\\.Manager$", - "description": "The class identifier for org.acme.hr.Manager" - }, - "reports": { - "type": "array", - "items": { - "type": "string", - "description": "The identifier of an instance of org.acme.hr.Person" - } - }, - "employeeId": { - "type": "string" - }, - "salary": { - "type": "integer" - }, - "numDependents": { - "type": "integer" - }, - "retired": { - "type": "boolean" - }, - "department": { - "$ref": "#/definitions/org.acme.hr.Department" - }, - "officeAddress": { - "$ref": "#/definitions/org.acme.hr.Address" - }, - "companyAssets": { - "type": "array", - "items": { - "anyOf": [ - { - "$ref": "#/definitions/org.acme.hr.Equipment" - }, - { - "$ref": "#/definitions/org.acme.hr.Laptop" - } - ] - } - }, - "manager": { - "type": "string", - "description": "The identifier of an instance of org.acme.hr.Manager" - }, - "email": { - "type": "string", - "description": "The instance identifier for this type" - }, - "firstName": { - "type": "string" - }, - "lastName": { - "type": "string" - }, - "middleNames": { - "type": "string" - }, - "homeAddress": { - "$ref": "#/definitions/org.acme.hr.Address" - }, - "ssn": { - "default": "000-00-0000", - "type": "string", - "pattern": "\\\\d{3}-\\\\d{2}-\\\\{4}+" - }, - "height": { - "type": "number" - }, - "dob": { - "format": "date-time", - "type": "string" - } - }, - "required": [ - "$class", - "employeeId", - "salary", - "numDependents", - "retired", - "department", - "officeAddress", - "companyAssets", - "email", - "firstName", - "lastName", - "homeAddress", - "ssn", - "height", - "dob" - ] - }, - "org.acme.hr.CompanyEvent": { - "title": "CompanyEvent", - "description": "An instance of org.acme.hr.CompanyEvent", - "type": "object", - "properties": { - "$class": { - "type": "string", - "default": "org.acme.hr.CompanyEvent", - "pattern": "^org\\\\.acme\\\\.hr\\\\.CompanyEvent$", - "description": "The class identifier for org.acme.hr.CompanyEvent" - } - }, - "required": [ - "$class" - ] - }, - "org.acme.hr.Onboarded": { - "title": "Onboarded", - "description": "An instance of org.acme.hr.Onboarded", - "type": "object", - "properties": { - "$class": { - "type": "string", - "default": "org.acme.hr.Onboarded", - "pattern": "^org\\\\.acme\\\\.hr\\\\.Onboarded$", - "description": "The class identifier for org.acme.hr.Onboarded" - }, - "employee": { - "type": "string", - "description": "The identifier of an instance of org.acme.hr.Employee" - } - }, - "required": [ - "$class", - "employee" - ] - }, - "org.acme.hr.ChangeOfAddress": { - "title": "ChangeOfAddress", - "description": "An instance of org.acme.hr.ChangeOfAddress", - "type": "object", - "properties": { - "$class": { - "type": "string", - "default": "org.acme.hr.ChangeOfAddress", - "pattern": "^org\\\\.acme\\\\.hr\\\\.ChangeOfAddress$", - "description": "The class identifier for org.acme.hr.ChangeOfAddress" - }, - "Person": { - "type": "string", - "description": "The identifier of an instance of org.acme.hr.Person" - }, - "newAddress": { - "$ref": "#/definitions/org.acme.hr.Address" - } - }, - "required": [ - "$class", - "Person", - "newAddress" - ] - } - } -} -", -} -`; - -exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'markdown' 1`] = ` -{ - "key": "models.md", - "value": "# Namespace org.acme.hr - -## Overview -- 2 concepts -- 3 enumerations -- 2 assets -- 4 participants -- 1 transactions -- 2 events -- 22 total declarations - -## Imports -- concerto@1.0.0.Concept -- concerto@1.0.0.Asset -- concerto@1.0.0.Transaction -- concerto@1.0.0.Participant -- concerto@1.0.0.Event - -## Diagram -\`\`\`mermaid -classDiagram -class \`org.acme.hr.State\` { -<< enumeration>> - + \`MA\` - + \`NY\` - + \`CO\` - + \`WA\` - + \`IL\` - + \`CA\` -} - -class \`org.acme.hr.Address\` { -<< concept>> - + \`String\` \`street\` - + \`String\` \`city\` - + \`State\` \`state\` - + \`String\` \`zipCode\` - + \`String\` \`country\` - + \`Map1\` \`dictionary1\` - + \`Map2\` \`dictionary2\` - + \`Map3\` \`dictionary3\` - + \`Map4\` \`dictionary4\` - + \`Map5\` \`dictionary5\` - + \`Map6\` \`dictionary6\` -} - -\`org.acme.hr.Address\` "1" *-- "1" \`org.acme.hr.State\` -\`org.acme.hr.Address\` "1" *-- "1" \`org.acme.hr.Map1\` -\`org.acme.hr.Address\` "1" *-- "1" \`org.acme.hr.Map2\` -\`org.acme.hr.Address\` "1" *-- "1" \`org.acme.hr.Map3\` -\`org.acme.hr.Address\` "1" *-- "1" \`org.acme.hr.Map4\` -\`org.acme.hr.Address\` "1" *-- "1" \`org.acme.hr.Map5\` -\`org.acme.hr.Address\` "1" *-- "1" \`org.acme.hr.Map6\` -class \`org.acme.hr.Company\` { -<< concept>> - + \`String\` \`name\` - + \`Address\` \`headquarters\` -} - -\`org.acme.hr.Company\` "1" *-- "1" \`org.acme.hr.Address\` -class \`org.acme.hr.Department\` { -<< enumeration>> - + \`Sales\` - + \`Marketing\` - + \`Finance\` - + \`HR\` - + \`Engineering\` - + \`Design\` -} - -class \`org.acme.hr.Equipment\` { -<< asset>> - + \`String\` \`serialNumber\` -} - -class \`org.acme.hr.LaptopMake\` { -<< enumeration>> - + \`Apple\` - + \`Microsoft\` -} - -class \`org.acme.hr.Laptop\` { -<< asset>> - + \`LaptopMake\` \`make\` -} - -\`org.acme.hr.Laptop\` "1" *-- "1" \`org.acme.hr.LaptopMake\` -\`org.acme.hr.Laptop\` --|> \`org.acme.hr.Equipment\` -class \`org.acme.hr.Person\` { -<< participant>> - + \`String\` \`email\` - + \`String\` \`firstName\` - + \`String\` \`lastName\` - + \`String\` \`middleNames\` - + \`Address\` \`homeAddress\` - + \`String\` \`ssn\` - + \`Double\` \`height\` - + \`DateTime\` \`dob\` -} - -\`org.acme.hr.Person\` "1" *-- "1" \`org.acme.hr.Address\` -\`org.acme.hr.Person\` "1" *-- "1" \`org.acme.hr.SSN\` -class \`org.acme.hr.Employee\` { -<< participant>> - + \`String\` \`employeeId\` - + \`Long\` \`salary\` - + \`Integer\` \`numDependents\` - + \`Boolean\` \`retired\` - + \`Department\` \`department\` - + \`Address\` \`officeAddress\` - + \`Equipment[]\` \`companyAssets\` - + \`Manager\` \`manager\` -} - -\`org.acme.hr.Employee\` "1" *-- "1" \`org.acme.hr.Department\` -\`org.acme.hr.Employee\` "1" *-- "1" \`org.acme.hr.Address\` -\`org.acme.hr.Employee\` "1" *-- "*" \`org.acme.hr.Equipment\` -\`org.acme.hr.Employee\` "1" o-- "1" \`org.acme.hr.Manager\` : manager -\`org.acme.hr.Employee\` --|> \`org.acme.hr.Person\` -class \`org.acme.hr.Contractor\` { -<< participant>> - + \`Company\` \`company\` - + \`Manager\` \`manager\` -} - -\`org.acme.hr.Contractor\` "1" *-- "1" \`org.acme.hr.Company\` -\`org.acme.hr.Contractor\` "1" o-- "1" \`org.acme.hr.Manager\` : manager -\`org.acme.hr.Contractor\` --|> \`org.acme.hr.Person\` -class \`org.acme.hr.Manager\` { -<< participant>> - + \`Person[]\` \`reports\` -} - -\`org.acme.hr.Manager\` "1" o-- "*" \`org.acme.hr.Person\` : reports -\`org.acme.hr.Manager\` --|> \`org.acme.hr.Employee\` -class \`org.acme.hr.CompanyEvent\` -<< event>> \`org.acme.hr.CompanyEvent\` - -class \`org.acme.hr.Onboarded\` { -<< event>> - + \`Employee\` \`employee\` -} - -\`org.acme.hr.Onboarded\` "1" o-- "1" \`org.acme.hr.Employee\` : employee -\`org.acme.hr.Onboarded\` --|> \`org.acme.hr.CompanyEvent\` -class \`org.acme.hr.ChangeOfAddress\` { -<< transaction>> - + \`Person\` \`Person\` - + \`Address\` \`newAddress\` -} - -\`org.acme.hr.ChangeOfAddress\` "1" o-- "1" \`org.acme.hr.Person\` : Person -\`org.acme.hr.ChangeOfAddress\` "1" *-- "1" \`org.acme.hr.Address\` -\`\`\` - -", -} -`; - -exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'mermaid' 1`] = ` -{ - "key": "model.mmd", - "value": "classDiagram -class \`org.acme.hr.State\` { -<< enumeration>> - + \`MA\` - + \`NY\` - + \`CO\` - + \`WA\` - + \`IL\` - + \`CA\` -} - -\`org.acme.hr.State\` --|> \`concerto@1.0.0.Concept\` -class \`org.acme.hr.Address\` { -<< concept>> - + \`String\` \`street\` - + \`String\` \`city\` - + \`State\` \`state\` - + \`String\` \`zipCode\` - + \`String\` \`country\` - + \`Map1\` \`dictionary1\` - + \`Map2\` \`dictionary2\` - + \`Map3\` \`dictionary3\` - + \`Map4\` \`dictionary4\` - + \`Map5\` \`dictionary5\` - + \`Map6\` \`dictionary6\` -} - -\`org.acme.hr.Address\` --|> \`concerto@1.0.0.Concept\` -class \`org.acme.hr.Company\` { -<< concept>> - + \`String\` \`name\` - + \`Address\` \`headquarters\` -} - -\`org.acme.hr.Company\` --|> \`concerto@1.0.0.Concept\` -class \`org.acme.hr.Department\` { -<< enumeration>> - + \`Sales\` - + \`Marketing\` - + \`Finance\` - + \`HR\` - + \`Engineering\` - + \`Design\` -} - -\`org.acme.hr.Department\` --|> \`concerto@1.0.0.Concept\` -class \`org.acme.hr.Equipment\` { -<< asset>> - + \`String\` \`serialNumber\` -} - -\`org.acme.hr.Equipment\` --|> \`concerto@1.0.0.Asset\` -class \`org.acme.hr.LaptopMake\` { -<< enumeration>> - + \`Apple\` - + \`Microsoft\` -} - -\`org.acme.hr.LaptopMake\` --|> \`concerto@1.0.0.Concept\` -class \`org.acme.hr.Laptop\` { -<< asset>> - + \`LaptopMake\` \`make\` -} - -\`org.acme.hr.Laptop\` --|> \`org.acme.hr.Equipment\` -class \`org.acme.hr.Person\` { -<< participant>> - + \`String\` \`email\` - + \`String\` \`firstName\` - + \`String\` \`lastName\` - + \`String\` \`middleNames\` - + \`Address\` \`homeAddress\` - + \`String\` \`ssn\` - + \`Double\` \`height\` - + \`DateTime\` \`dob\` -} - -\`org.acme.hr.Person\` --|> \`concerto@1.0.0.Participant\` -class \`org.acme.hr.Employee\` { -<< participant>> - + \`String\` \`employeeId\` - + \`Long\` \`salary\` - + \`Integer\` \`numDependents\` - + \`Boolean\` \`retired\` - + \`Department\` \`department\` - + \`Address\` \`officeAddress\` - + \`Equipment[]\` \`companyAssets\` - + \`Manager\` \`manager\` -} - -\`org.acme.hr.Employee\` "1" o-- "1" \`org.acme.hr.Manager\` : manager -\`org.acme.hr.Employee\` --|> \`org.acme.hr.Person\` -class \`org.acme.hr.Contractor\` { -<< participant>> - + \`Company\` \`company\` - + \`Manager\` \`manager\` -} - -\`org.acme.hr.Contractor\` "1" o-- "1" \`org.acme.hr.Manager\` : manager -\`org.acme.hr.Contractor\` --|> \`org.acme.hr.Person\` -class \`org.acme.hr.Manager\` { -<< participant>> - + \`Person[]\` \`reports\` -} - -\`org.acme.hr.Manager\` "1" o-- "*" \`org.acme.hr.Person\` : reports -\`org.acme.hr.Manager\` --|> \`org.acme.hr.Employee\` -class \`org.acme.hr.CompanyEvent\` -<< event>> \`org.acme.hr.CompanyEvent\` - -\`org.acme.hr.CompanyEvent\` --|> \`concerto@1.0.0.Event\` -class \`org.acme.hr.Onboarded\` { -<< event>> - + \`Employee\` \`employee\` -} - -\`org.acme.hr.Onboarded\` "1" o-- "1" \`org.acme.hr.Employee\` : employee -\`org.acme.hr.Onboarded\` --|> \`org.acme.hr.CompanyEvent\` -class \`org.acme.hr.ChangeOfAddress\` { -<< transaction>> - + \`Person\` \`Person\` - + \`Address\` \`newAddress\` -} - -\`org.acme.hr.ChangeOfAddress\` "1" o-- "1" \`org.acme.hr.Person\` : Person -\`org.acme.hr.ChangeOfAddress\` --|> \`concerto@1.0.0.Transaction\` -", -} -`; - -exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'odata' 1`] = ` -{ - "key": "concerto.csdl", - "value": " - - - - - - - - - - - - - - - - - - - - - - - - - -", -} -`; - -exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'odata' 2`] = ` -{ - "key": "org.acme.hr.csdl", - "value": " - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -", -} -`; - -exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'openapi' 1`] = ` -{ - "key": "openapi.json", - "value": "{ - "openapi": "3.0.2", - "servers": [], - "info": { - "title": "Generated Open API from Concerto Models", - "version": "1.0.0", - "description": "Create, read, update and delete entities" - }, - "components": { - "schemas": { - "org.acme.hr.State": { - "title": "State", - "description": "An instance of org.acme.hr.State", - "enum": [ - "MA", - "NY", - "CO", - "WA", - "IL", - "CA" - ] - }, - "org.acme.hr.Address": { - "title": "Address", - "description": "An instance of org.acme.hr.Address", - "type": "object", - "properties": { - "$class": { - "type": "string", - "default": "org.acme.hr.Address", - "pattern": "^org\\\\.acme\\\\.hr\\\\.Address$", - "description": "The class identifier for org.acme.hr.Address" - }, - "street": { - "type": "string" - }, - "city": { - "type": "string" - }, - "state": { - "$ref": "#/components/schemas/org.acme.hr.State" - }, - "zipCode": { - "type": "string" - }, - "country": { - "type": "string" - } - }, - "required": [ - "$class", - "street", - "city", - "zipCode", - "country", - "dictionary1", - "dictionary2", - "dictionary3", - "dictionary4", - "dictionary5", - "dictionary6" - ] - }, - "org.acme.hr.Time": { - "format": "date-time", - "type": "string" - }, - "org.acme.hr.Company": { - "title": "Company", - "description": "An instance of org.acme.hr.Company", - "type": "object", - "properties": { - "$class": { - "type": "string", - "default": "org.acme.hr.Company", - "pattern": "^org\\\\.acme\\\\.hr\\\\.Company$", - "description": "The class identifier for org.acme.hr.Company" - }, - "name": { - "type": "string" - }, - "headquarters": { - "$ref": "#/components/schemas/org.acme.hr.Address" - } - }, - "required": [ - "$class", - "name", - "headquarters" - ] - }, - "org.acme.hr.Department": { - "title": "Department", - "description": "An instance of org.acme.hr.Department", - "enum": [ - "Sales", - "Marketing", - "Finance", - "HR", - "Engineering", - "Design" - ] - }, - "org.acme.hr.Equipment": { - "title": "Equipment", - "description": "An instance of org.acme.hr.Equipment", - "type": "object", - "properties": { - "$class": { - "type": "string", - "default": "org.acme.hr.Equipment", - "pattern": "^org\\\\.acme\\\\.hr\\\\.Equipment$", - "description": "The class identifier for org.acme.hr.Equipment" - }, - "serialNumber": { - "type": "string", - "description": "The instance identifier for this type" - } - }, - "required": [ - "$class", - "serialNumber" - ], - "$decorators": { - "resource": [] - } - }, - "org.acme.hr.LaptopMake": { - "title": "LaptopMake", - "description": "An instance of org.acme.hr.LaptopMake", - "enum": [ - "Apple", - "Microsoft" - ] - }, - "org.acme.hr.Laptop": { - "title": "Laptop", - "description": "An instance of org.acme.hr.Laptop", - "type": "object", - "properties": { - "$class": { - "type": "string", - "default": "org.acme.hr.Laptop", - "pattern": "^org\\\\.acme\\\\.hr\\\\.Laptop$", - "description": "The class identifier for org.acme.hr.Laptop" - }, - "make": { - "$ref": "#/components/schemas/org.acme.hr.LaptopMake" - }, - "serialNumber": { - "type": "string", - "description": "The instance identifier for this type" - } - }, - "required": [ - "$class", - "make", - "serialNumber" - ] - }, - "org.acme.hr.SSN": { - "type": "string", - "pattern": "\\\\d{3}-\\\\d{2}-\\\\{4}+" - }, - "org.acme.hr.Person": { - "title": "Person", - "description": "An instance of org.acme.hr.Person", - "type": "object", - "properties": { - "$class": { - "type": "string", - "default": "org.acme.hr.Person", - "pattern": "^org\\\\.acme\\\\.hr\\\\.Person$", - "description": "The class identifier for org.acme.hr.Person" - }, - "email": { - "type": "string", - "description": "The instance identifier for this type" - }, - "firstName": { - "type": "string" - }, - "lastName": { - "type": "string" - }, - "middleNames": { - "type": "string" - }, - "homeAddress": { - "$ref": "#/components/schemas/org.acme.hr.Address" - }, - "ssn": { - "default": "000-00-0000", - "type": "string", - "pattern": "\\\\d{3}-\\\\d{2}-\\\\{4}+" - }, - "height": { - "type": "number" - }, - "dob": { - "format": "date-time", - "type": "string" - } - }, - "required": [ - "$class", - "email", - "firstName", - "lastName", - "homeAddress", - "ssn", - "height", - "dob" - ], - "$decorators": { - "resource": [] - } - }, - "org.acme.hr.Employee": { - "title": "Employee", - "description": "An instance of org.acme.hr.Employee", - "type": "object", - "properties": { - "$class": { - "type": "string", - "default": "org.acme.hr.Employee", - "pattern": "^org\\\\.acme\\\\.hr\\\\.Employee$", - "description": "The class identifier for org.acme.hr.Employee" - }, - "employeeId": { - "type": "string" - }, - "salary": { - "type": "integer" - }, - "numDependents": { - "type": "integer" - }, - "retired": { - "type": "boolean" - }, - "department": { - "$ref": "#/components/schemas/org.acme.hr.Department" - }, - "officeAddress": { - "$ref": "#/components/schemas/org.acme.hr.Address" - }, - "companyAssets": { - "type": "array", - "items": { - "anyOf": [ - { - "$ref": "#/components/schemas/org.acme.hr.Equipment" - }, - { - "$ref": "#/components/schemas/org.acme.hr.Laptop" - } - ] - } - }, - "manager": { - "type": "string", - "description": "The identifier of an instance of org.acme.hr.Manager" - }, - "email": { - "type": "string", - "description": "The instance identifier for this type" - }, - "firstName": { - "type": "string" - }, - "lastName": { - "type": "string" - }, - "middleNames": { - "type": "string" - }, - "homeAddress": { - "$ref": "#/components/schemas/org.acme.hr.Address" - }, - "ssn": { - "default": "000-00-0000", - "type": "string", - "pattern": "\\\\d{3}-\\\\d{2}-\\\\{4}+" - }, - "height": { - "type": "number" - }, - "dob": { - "format": "date-time", - "type": "string" - } - }, - "required": [ - "$class", - "employeeId", - "salary", - "numDependents", - "retired", - "department", - "officeAddress", - "companyAssets", - "email", - "firstName", - "lastName", - "homeAddress", - "ssn", - "height", - "dob" - ] - }, - "org.acme.hr.Contractor": { - "title": "Contractor", - "description": "An instance of org.acme.hr.Contractor", - "type": "object", - "properties": { - "$class": { - "type": "string", - "default": "org.acme.hr.Contractor", - "pattern": "^org\\\\.acme\\\\.hr\\\\.Contractor$", - "description": "The class identifier for org.acme.hr.Contractor" - }, - "company": { - "$ref": "#/components/schemas/org.acme.hr.Company" - }, - "manager": { - "type": "string", - "description": "The identifier of an instance of org.acme.hr.Manager" - }, - "email": { - "type": "string", - "description": "The instance identifier for this type" - }, - "firstName": { - "type": "string" - }, - "lastName": { - "type": "string" - }, - "middleNames": { - "type": "string" - }, - "homeAddress": { - "$ref": "#/components/schemas/org.acme.hr.Address" - }, - "ssn": { - "default": "000-00-0000", - "type": "string", - "pattern": "\\\\d{3}-\\\\d{2}-\\\\{4}+" - }, - "height": { - "type": "number" - }, - "dob": { - "format": "date-time", - "type": "string" - } - }, - "required": [ - "$class", - "company", - "email", - "firstName", - "lastName", - "homeAddress", - "ssn", - "height", - "dob" - ] - }, - "org.acme.hr.Manager": { - "title": "Manager", - "description": "An instance of org.acme.hr.Manager", - "type": "object", - "properties": { - "$class": { - "type": "string", - "default": "org.acme.hr.Manager", - "pattern": "^org\\\\.acme\\\\.hr\\\\.Manager$", - "description": "The class identifier for org.acme.hr.Manager" - }, - "reports": { - "type": "array", - "items": { - "type": "string", - "description": "The identifier of an instance of org.acme.hr.Person" - } - }, - "employeeId": { - "type": "string" - }, - "salary": { - "type": "integer" - }, - "numDependents": { - "type": "integer" - }, - "retired": { - "type": "boolean" - }, - "department": { - "$ref": "#/components/schemas/org.acme.hr.Department" - }, - "officeAddress": { - "$ref": "#/components/schemas/org.acme.hr.Address" - }, - "companyAssets": { - "type": "array", - "items": { - "anyOf": [ - { - "$ref": "#/components/schemas/org.acme.hr.Equipment" - }, - { - "$ref": "#/components/schemas/org.acme.hr.Laptop" - } - ] - } - }, - "manager": { - "type": "string", - "description": "The identifier of an instance of org.acme.hr.Manager" - }, - "email": { - "type": "string", - "description": "The instance identifier for this type" - }, - "firstName": { - "type": "string" - }, - "lastName": { - "type": "string" - }, - "middleNames": { - "type": "string" - }, - "homeAddress": { - "$ref": "#/components/schemas/org.acme.hr.Address" - }, - "ssn": { - "default": "000-00-0000", - "type": "string", - "pattern": "\\\\d{3}-\\\\d{2}-\\\\{4}+" - }, - "height": { - "type": "number" - }, - "dob": { - "format": "date-time", - "type": "string" - } - }, - "required": [ - "$class", - "employeeId", - "salary", - "numDependents", - "retired", - "department", - "officeAddress", - "companyAssets", - "email", - "firstName", - "lastName", - "homeAddress", - "ssn", - "height", - "dob" - ] - }, - "org.acme.hr.CompanyEvent": { - "title": "CompanyEvent", - "description": "An instance of org.acme.hr.CompanyEvent", - "type": "object", - "properties": { - "$class": { - "type": "string", - "default": "org.acme.hr.CompanyEvent", - "pattern": "^org\\\\.acme\\\\.hr\\\\.CompanyEvent$", - "description": "The class identifier for org.acme.hr.CompanyEvent" - } - }, - "required": [ - "$class" - ] - }, - "org.acme.hr.Onboarded": { - "title": "Onboarded", - "description": "An instance of org.acme.hr.Onboarded", - "type": "object", - "properties": { - "$class": { - "type": "string", - "default": "org.acme.hr.Onboarded", - "pattern": "^org\\\\.acme\\\\.hr\\\\.Onboarded$", - "description": "The class identifier for org.acme.hr.Onboarded" - }, - "employee": { - "type": "string", - "description": "The identifier of an instance of org.acme.hr.Employee" - } - }, - "required": [ - "$class", - "employee" - ] - }, - "org.acme.hr.ChangeOfAddress": { - "title": "ChangeOfAddress", - "description": "An instance of org.acme.hr.ChangeOfAddress", - "type": "object", - "properties": { - "$class": { - "type": "string", - "default": "org.acme.hr.ChangeOfAddress", - "pattern": "^org\\\\.acme\\\\.hr\\\\.ChangeOfAddress$", - "description": "The class identifier for org.acme.hr.ChangeOfAddress" - }, - "Person": { - "type": "string", - "description": "The identifier of an instance of org.acme.hr.Person" - }, - "newAddress": { - "$ref": "#/components/schemas/org.acme.hr.Address" - } - }, - "required": [ - "$class", - "Person", - "newAddress" - ] - } - } - }, - "paths": { - "/equipment": { - "summary": "Path used to manage the list of equipment.", - "description": "The REST endpoint/path used to list and create zero or more \`equipment\` entities. This path contains a \`GET\` and \`POST\` operation to perform the list and create tasks, respectively.", - "get": { - "responses": { - "200": { - "content": { - "application/json": { - "schema": { - "type": "array", - "items": { - "$ref": "#/components/schemas/org.acme.hr.Equipment" - } - } - } - }, - "description": "Successful response - returns an array of \`equipment\` entities." - } - }, - "operationId": "listEquipment", - "summary": "List All Equipment", - "description": "Gets a list of all \`equipment\` entities.", - "tags": [ - "equipment" - ] - }, - "post": { - "requestBody": { - "description": "A new \`equipment\` to be created.", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/org.acme.hr.Equipment" - } - } - }, - "required": true - }, - "responses": { - "201": { - "description": "Successful response." - } - }, - "operationId": "createEquipment", - "summary": "Create a Equipment", - "description": "Creates a new instance of a \`equipment\`.", - "tags": [ - "equipment" - ] - } - }, - "/equipment/{serialNumber}": { - "summary": "Path used to manage a single equipment.", - "description": "The REST endpoint/path used to get, update, and delete single instances of a \`equipment\`. This path contains \`GET\`, \`PUT\`, and \`DELETE\` operations used to perform the get, update, and delete tasks, respectively.", - "get": { - "responses": { - "200": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/org.acme.hr.Equipment" - } - } - }, - "description": "Successful response - returns a single \`equipment\`." - } - }, - "operationId": "getEquipment", - "summary": "Get a equipment", - "description": "Gets the details of a single instance of a \`equipment\`.", - "tags": [ - "equipment" - ] - }, - "put": { - "requestBody": { - "description": "Updated \`equipment\` information.", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/org.acme.hr.Equipment" - } - } - }, - "required": true - }, - "responses": { - "202": { - "description": "Successful response." - } - }, - "operationId": "replaceEquipment", - "summary": "Update a equipment", - "description": "Updates an existing \`equipment\`.", - "tags": [ - "equipment" - ] - }, - "delete": { - "responses": { - "204": { - "description": "Successful response." - } - }, - "operationId": "deleteEquipment", - "summary": "Delete a equipment", - "description": "Deletes an existing \`equipment\`.", - "tags": [ - "equipment" - ] - }, - "parameters": [ - { - "name": "serialNumber", - "description": "A unique identifier for a \`Equipment\`.", - "schema": { - "type": "string" - }, - "in": "path", - "required": true - } - ] - }, - "/people": { - "summary": "Path used to manage the list of people.", - "description": "The REST endpoint/path used to list and create zero or more \`person\` entities. This path contains a \`GET\` and \`POST\` operation to perform the list and create tasks, respectively.", - "get": { - "responses": { - "200": { - "content": { - "application/json": { - "schema": { - "type": "array", - "items": { - "$ref": "#/components/schemas/org.acme.hr.Person" - } - } - } - }, - "description": "Successful response - returns an array of \`person\` entities." - } - }, - "operationId": "listPeople", - "summary": "List All People", - "description": "Gets a list of all \`person\` entities.", - "tags": [ - "people" - ] - }, - "post": { - "requestBody": { - "description": "A new \`person\` to be created.", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/org.acme.hr.Person" - } - } - }, - "required": true - }, - "responses": { - "201": { - "description": "Successful response." - } - }, - "operationId": "createPerson", - "summary": "Create a Person", - "description": "Creates a new instance of a \`person\`.", - "tags": [ - "people" - ] - } - }, - "/people/{email}": { - "summary": "Path used to manage a single person.", - "description": "The REST endpoint/path used to get, update, and delete single instances of a \`person\`. This path contains \`GET\`, \`PUT\`, and \`DELETE\` operations used to perform the get, update, and delete tasks, respectively.", - "get": { - "responses": { - "200": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/org.acme.hr.Person" - } - } - }, - "description": "Successful response - returns a single \`person\`." - } - }, - "operationId": "getPerson", - "summary": "Get a person", - "description": "Gets the details of a single instance of a \`person\`.", - "tags": [ - "people" - ] - }, - "put": { - "requestBody": { - "description": "Updated \`person\` information.", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/org.acme.hr.Person" - } - } - }, - "required": true - }, - "responses": { - "202": { - "description": "Successful response." - } - }, - "operationId": "replacePerson", - "summary": "Update a person", - "description": "Updates an existing \`person\`.", - "tags": [ - "people" - ] - }, - "delete": { - "responses": { - "204": { - "description": "Successful response." - } - }, - "operationId": "deletePerson", - "summary": "Delete a person", - "description": "Deletes an existing \`person\`.", - "tags": [ - "people" - ] - }, - "parameters": [ - { - "name": "email", - "description": "A unique identifier for a \`Person\`.", - "schema": { - "type": "string" - }, - "in": "path", - "required": true - } - ] - } - } -} -", -} -`; - -exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'plantuml' 1`] = ` -{ - "key": "model.puml", - "value": "@startuml -title -Model -endtitle -class org.acme.hr.State << (E,grey) >> { - + MA - + NY - + CO - + WA - + IL - + CA -} -org.acme.hr.State --|> concerto_1_0_0.Concept -class org.acme.hr.Address { - + String street - + String city - + State state - + String zipCode - + String country - + Map1 dictionary1 - + Map2 dictionary2 - + Map3 dictionary3 - + Map4 dictionary4 - + Map5 dictionary5 - + Map6 dictionary6 -} -org.acme.hr.Address --|> concerto_1_0_0.Concept -class org.acme.hr.Company { - + String name - + Address headquarters -} -org.acme.hr.Company --|> concerto_1_0_0.Concept -class org.acme.hr.Department << (E,grey) >> { - + Sales - + Marketing - + Finance - + HR - + Engineering - + Design -} -org.acme.hr.Department --|> concerto_1_0_0.Concept -class org.acme.hr.Equipment << (A,green) >> { - + String serialNumber -} -org.acme.hr.Equipment --|> concerto_1_0_0.Asset -class org.acme.hr.LaptopMake << (E,grey) >> { - + Apple - + Microsoft -} -org.acme.hr.LaptopMake --|> concerto_1_0_0.Concept -class org.acme.hr.Laptop << (A,green) >> { - + LaptopMake make -} -org.acme.hr.Laptop --|> org.acme.hr.Equipment -class org.acme.hr.Person << (P,lightblue) >> { - + String email - + String firstName - + String lastName - + String middleNames - + Address homeAddress - + String ssn - + Double height - + DateTime dob -} -org.acme.hr.Person --|> concerto_1_0_0.Participant -class org.acme.hr.Employee << (P,lightblue) >> { - + String employeeId - + Long salary - + Integer numDependents - + Boolean retired - + Department department - + Address officeAddress - + Equipment[] companyAssets - + Manager manager -} -org.acme.hr.Employee "1" o-- "1" org.acme.hr.Manager : manager -org.acme.hr.Employee --|> org.acme.hr.Person -class org.acme.hr.Contractor << (P,lightblue) >> { - + Company company - + Manager manager -} -org.acme.hr.Contractor "1" o-- "1" org.acme.hr.Manager : manager -org.acme.hr.Contractor --|> org.acme.hr.Person -class org.acme.hr.Manager << (P,lightblue) >> { - + Person[] reports -} -org.acme.hr.Manager "1" o-- "*" org.acme.hr.Person : reports -org.acme.hr.Manager --|> org.acme.hr.Employee -class org.acme.hr.CompanyEvent { -} -org.acme.hr.CompanyEvent --|> concerto_1_0_0.Event -class org.acme.hr.Onboarded { - + Employee employee -} -org.acme.hr.Onboarded "1" o-- "1" org.acme.hr.Employee : employee -org.acme.hr.Onboarded --|> org.acme.hr.CompanyEvent -class org.acme.hr.ChangeOfAddress << (T,yellow) >> { - + Person Person - + Address newAddress -} -org.acme.hr.ChangeOfAddress "1" o-- "1" org.acme.hr.Person : Person -org.acme.hr.ChangeOfAddress --|> concerto_1_0_0.Transaction -@enduml -", -} -`; - -exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'protobuf' 1`] = ` -{ - "key": "org.acme.hr.v.proto", - "value": "syntax = "proto3"; - -package org.acme.hr.v; - -import "google/protobuf/timestamp.proto"; - -enum State { - State_CA = 0; - State_CO = 1; - State_IL = 2; - State_MA = 3; - State_NY = 4; - State_WA = 5; -} - -message Address { - string city = 1; - string country = 2; - Map1 dictionary1 = 3; - Map2 dictionary2 = 4; - Map3 dictionary3 = 5; - Map4 dictionary4 = 6; - Map5 dictionary5 = 7; - Map6 dictionary6 = 8; - optional State state = 9; - string street = 10; - string zipCode = 11; -} - -message Company { - Address headquarters = 1; - string name = 2; -} - -enum Department { - Department_Design = 0; - Department_Engineering = 1; - Department_Finance = 2; - Department_HR = 3; - Department_Marketing = 4; - Department_Sales = 5; -} - -message _Subclasses_of_class_Equipment { - oneof _class_oneof_Equipment { - Laptop _subclass_of_class_Equipment_Laptop = 1; - } -} - -enum LaptopMake { - LaptopMake_Apple = 0; - LaptopMake_Microsoft = 1; -} - -message Laptop { - LaptopMake make = 1; - string serialNumber = 2; -} - -message _Subclasses_of_class_Person { - oneof _class_oneof_Person { - Contractor _subclass_of_class_Person_Contractor = 1; - Employee _subclass_of_class_Person_Employee = 2; - Manager _subclass_of_class_Person_Manager = 3; - } -} - -message Employee { - repeated _Subclasses_of_class_Equipment companyAssets = 1; - Department department = 2; - google.protobuf.Timestamp dob = 3; - string email = 4; - string employeeId = 5; - string firstName = 6; - double height = 7; - Address homeAddress = 8; - string lastName = 9; - optional string manager = 10; - optional string middleNames = 11; - sint64 numDependents = 12; - Address officeAddress = 13; - bool retired = 14; - sint64 salary = 15; - string ssn = 16; -} - -message _Subclasses_of_class_Employee { - oneof _class_oneof_Employee { - Employee _subclass_of_class_Employee_Employee = 1; - Manager _subclass_of_class_Employee_Manager = 2; - } -} - -message Contractor { - Company company = 1; - google.protobuf.Timestamp dob = 2; - string email = 3; - string firstName = 4; - double height = 5; - Address homeAddress = 6; - string lastName = 7; - optional string manager = 8; - optional string middleNames = 9; - string ssn = 10; -} - -message Manager { - repeated _Subclasses_of_class_Equipment companyAssets = 1; - Department department = 2; - google.protobuf.Timestamp dob = 3; - string email = 4; - string employeeId = 5; - string firstName = 6; - double height = 7; - Address homeAddress = 8; - string lastName = 9; - optional string manager = 10; - optional string middleNames = 11; - sint64 numDependents = 12; - Address officeAddress = 13; - repeated string reports = 14; - bool retired = 15; - sint64 salary = 16; - string ssn = 17; -} - -message CompanyEvent { -} - -message _Subclasses_of_class_CompanyEvent { - oneof _class_oneof_CompanyEvent { - CompanyEvent _subclass_of_class_CompanyEvent_CompanyEvent = 1; - Onboarded _subclass_of_class_CompanyEvent_Onboarded = 2; - } -} - -message Onboarded { - string employee = 1; -} - -message ChangeOfAddress { - Address newAddress = 1; - string Person = 2; -} - -", -} -`; - -exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'rust' 1`] = ` -{ - "key": "mod.rs", - "value": "#[allow(unused_imports)] -pub mod concerto_1_0_0; -#[allow(unused_imports)] -pub mod concerto; -#[allow(unused_imports)] -pub mod org_acme_hr; -#[allow(unused_imports)] -pub mod utils; -", -} -`; - -exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'rust' 2`] = ` -{ - "key": "utils.rs", - "value": "use chrono::{ DateTime, TimeZone, Utc }; -use serde::{ Deserialize, Serialize, Deserializer, Serializer }; - -pub fn serialize_datetime_option(datetime: &Option>, serializer: S) -> Result -where - S: Serializer, -{ - match datetime { - Some(dt) => { - serialize_datetime(&dt, serializer) - }, - _ => unreachable!(), - } -} - -pub fn deserialize_datetime_option<'de, D>(deserializer: D) -> Result>, D::Error> -where - D: Deserializer<'de>, -{ - match deserialize_datetime(deserializer) { - Ok(result)=>Ok(Some(result)), - Err(error) => Err(error), - } -} - -pub fn deserialize_datetime<'de, D>(deserializer: D) -> Result, D::Error> -where - D: Deserializer<'de>, -{ - let datetime_str = String::deserialize(deserializer)?; - Utc.datetime_from_str(&datetime_str, "%Y-%m-%dT%H:%M:%S%.3f%Z").map_err(serde::de::Error::custom) -} - -pub fn serialize_datetime(datetime: &chrono::DateTime, serializer: S) -> Result -where - S: Serializer, -{ - let datetime_str = datetime.format("%+").to_string(); - serializer.serialize_str(&datetime_str) -} -", -} -`; - -exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'rust' 3`] = ` -{ - "key": "concerto_1_0_0.rs", - "value": "use serde::{ Deserialize, Serialize }; -use chrono::{ DateTime, TimeZone, Utc }; - -use crate::utils::*; - -#[derive(Debug, Serialize, Deserialize)] -pub struct Concept { - #[serde( - rename = "$class", - )] - pub _class: String, -} - -#[derive(Debug, Serialize, Deserialize)] -pub struct Asset { - #[serde( - rename = "$class", - )] - pub _class: String, - - #[serde( - rename = "$identifier", - )] - pub _identifier: String, -} - -#[derive(Debug, Serialize, Deserialize)] -pub struct Participant { - #[serde( - rename = "$class", - )] - pub _class: String, - - #[serde( - rename = "$identifier", - )] - pub _identifier: String, -} - -#[derive(Debug, Serialize, Deserialize)] -pub struct Transaction { - #[serde( - rename = "$class", - )] - pub _class: String, - - #[serde( - rename = "$timestamp", - serialize_with = "serialize_datetime", - deserialize_with = "deserialize_datetime", - )] - pub _timestamp: DateTime, -} - -#[derive(Debug, Serialize, Deserialize)] -pub struct Event { - #[serde( - rename = "$class", - )] - pub _class: String, - - #[serde( - rename = "$timestamp", - serialize_with = "serialize_datetime", - deserialize_with = "deserialize_datetime", - )] - pub _timestamp: DateTime, -} - -", -} -`; - -exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'rust' 4`] = ` -{ - "key": "concerto.rs", - "value": "use serde::{ Deserialize, Serialize }; -use chrono::{ DateTime, TimeZone, Utc }; - -use crate::utils::*; - -#[derive(Debug, Serialize, Deserialize)] -pub struct Concept { - #[serde( - rename = "$class", - )] - pub _class: String, -} - -#[derive(Debug, Serialize, Deserialize)] -pub struct Asset { - #[serde( - rename = "$class", - )] - pub _class: String, - - #[serde( - rename = "$identifier", - )] - pub _identifier: String, -} - -#[derive(Debug, Serialize, Deserialize)] -pub struct Participant { - #[serde( - rename = "$class", - )] - pub _class: String, - - #[serde( - rename = "$identifier", - )] - pub _identifier: String, -} - -#[derive(Debug, Serialize, Deserialize)] -pub struct Transaction { - #[serde( - rename = "$class", - )] - pub _class: String, -} - -#[derive(Debug, Serialize, Deserialize)] -pub struct Event { - #[serde( - rename = "$class", - )] - pub _class: String, -} - -", -} -`; - -exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'rust' 5`] = ` -{ - "key": "org_acme_hr.rs", - "value": "use serde::{ Deserialize, Serialize }; -use chrono::{ DateTime, TimeZone, Utc }; - -use crate::concerto_1_0_0::*; -use crate::utils::*; - -#[derive(Debug, Serialize, Deserialize)] -pub enum State { - #[allow(non_camel_case_types)] - MA, - #[allow(non_camel_case_types)] - NY, - #[allow(non_camel_case_types)] - CO, - #[allow(non_camel_case_types)] - WA, - #[allow(non_camel_case_types)] - IL, - #[allow(non_camel_case_types)] - CA, -} - -#[derive(Debug, Serialize, Deserialize)] -pub struct Address { - #[serde( - rename = "$class", - )] - pub _class: String, - - #[serde( - rename = "street", - )] - pub street: String, - - #[serde( - rename = "city", - )] - pub city: String, - - #[serde( - rename = "state", - skip_serializing_if = "Option::is_none", - )] - pub state: Option, - - #[serde( - rename = "zipCode", - )] - pub zip_code: String, - - #[serde( - rename = "country", - )] - pub country: String, - - #[serde( - rename = "dictionary1", - )] - pub dictionary1: Map1, - - #[serde( - rename = "dictionary2", - )] - pub dictionary2: Map2, - - #[serde( - rename = "dictionary3", - )] - pub dictionary3: Map3, - - #[serde( - rename = "dictionary4", - )] - pub dictionary4: Map4, - - #[serde( - rename = "dictionary5", - )] - pub dictionary5: Map5, - - #[serde( - rename = "dictionary6", - )] - pub dictionary6: Map6, -} - -#[derive(Debug, Serialize, Deserialize)] -pub struct Company { - #[serde( - rename = "$class", - )] - pub _class: String, - - #[serde( - rename = "name", - )] - pub name: String, - - #[serde( - rename = "headquarters", - )] - pub headquarters: Address, -} - -#[derive(Debug, Serialize, Deserialize)] -pub enum Department { - #[allow(non_camel_case_types)] - Sales, - #[allow(non_camel_case_types)] - Marketing, - #[allow(non_camel_case_types)] - Finance, - #[allow(non_camel_case_types)] - HR, - #[allow(non_camel_case_types)] - Engineering, - #[allow(non_camel_case_types)] - Design, -} - -#[derive(Debug, Serialize, Deserialize)] -pub struct Equipment { - #[serde( - rename = "$class", - )] - pub _class: String, - - #[serde( - rename = "serialNumber", - )] - pub serial_number: String, - - #[serde( - rename = "$identifier", - )] - pub _identifier: String, -} - -#[derive(Debug, Serialize, Deserialize)] -pub enum LaptopMake { - #[allow(non_camel_case_types)] - Apple, - #[allow(non_camel_case_types)] - Microsoft, -} - -#[derive(Debug, Serialize, Deserialize)] -pub struct Laptop { - #[serde( - rename = "$class", - )] - pub _class: String, - - #[serde( - rename = "make", - )] - pub make: LaptopMake, - - #[serde( - rename = "serialNumber", - )] - pub serial_number: String, - - #[serde( - rename = "$identifier", - )] - pub _identifier: String, -} - -#[derive(Debug, Serialize, Deserialize)] -pub struct Person { - #[serde( - rename = "$class", - )] - pub _class: String, - - #[serde( - rename = "email", - )] - pub email: String, - - #[serde( - rename = "firstName", - )] - pub first_name: String, - - #[serde( - rename = "lastName", - )] - pub last_name: String, - - #[serde( - rename = "middleNames", - skip_serializing_if = "Option::is_none", - )] - pub middle_names: Option, - - #[serde( - rename = "homeAddress", - )] - pub home_address: Address, - - #[serde( - rename = "ssn", - )] - pub ssn: String, - - #[serde( - rename = "height", - )] - pub height: f64, - - #[serde( - rename = "dob", - serialize_with = "serialize_datetime", - deserialize_with = "deserialize_datetime", - )] - pub dob: DateTime, - - #[serde( - rename = "$identifier", - )] - pub _identifier: String, -} - -#[derive(Debug, Serialize, Deserialize)] -pub struct Employee { - #[serde( - rename = "$class", - )] - pub _class: String, - - #[serde( - rename = "employeeId", - )] - pub employee_id: String, - - #[serde( - rename = "salary", - )] - pub salary: u64, - - #[serde( - rename = "numDependents", - )] - pub num_dependents: Integer, - - #[serde( - rename = "retired", - )] - pub retired: bool, - - #[serde( - rename = "department", - )] - pub department: Department, - - #[serde( - rename = "officeAddress", - )] - pub office_address: Address, - - #[serde( - rename = "companyAssets", - )] - pub company_assets: Vec, - - #[serde(rename = "manager")] - pub manager: Option, - - #[serde( - rename = "email", - )] - pub email: String, - - #[serde( - rename = "firstName", - )] - pub first_name: String, - - #[serde( - rename = "lastName", - )] - pub last_name: String, - - #[serde( - rename = "middleNames", - skip_serializing_if = "Option::is_none", - )] - pub middle_names: Option, - - #[serde( - rename = "homeAddress", - )] - pub home_address: Address, - - #[serde( - rename = "ssn", - )] - pub ssn: String, - - #[serde( - rename = "height", - )] - pub height: f64, - - #[serde( - rename = "dob", - serialize_with = "serialize_datetime", - deserialize_with = "deserialize_datetime", - )] - pub dob: DateTime, - - #[serde( - rename = "$identifier", - )] - pub _identifier: String, -} - -#[derive(Debug, Serialize, Deserialize)] -pub struct Contractor { - #[serde( - rename = "$class", - )] - pub _class: String, - - #[serde( - rename = "company", - )] - pub company: Company, - - #[serde(rename = "manager")] - pub manager: Option, - - #[serde( - rename = "email", - )] - pub email: String, - - #[serde( - rename = "firstName", - )] - pub first_name: String, - - #[serde( - rename = "lastName", - )] - pub last_name: String, - - #[serde( - rename = "middleNames", - skip_serializing_if = "Option::is_none", - )] - pub middle_names: Option, - - #[serde( - rename = "homeAddress", - )] - pub home_address: Address, - - #[serde( - rename = "ssn", - )] - pub ssn: String, - - #[serde( - rename = "height", - )] - pub height: f64, - - #[serde( - rename = "dob", - serialize_with = "serialize_datetime", - deserialize_with = "deserialize_datetime", - )] - pub dob: DateTime, - - #[serde( - rename = "$identifier", - )] - pub _identifier: String, -} - -#[derive(Debug, Serialize, Deserialize)] -pub struct Manager { - #[serde( - rename = "$class", - )] - pub _class: String, - - #[serde(rename = "reports")] - pub reports: Option>, - - #[serde( - rename = "employeeId", - )] - pub employee_id: String, - - #[serde( - rename = "salary", - )] - pub salary: u64, - - #[serde( - rename = "numDependents", - )] - pub num_dependents: Integer, - - #[serde( - rename = "retired", - )] - pub retired: bool, - - #[serde( - rename = "department", - )] - pub department: Department, - - #[serde( - rename = "officeAddress", - )] - pub office_address: Address, - - #[serde( - rename = "companyAssets", - )] - pub company_assets: Vec, - - #[serde(rename = "manager")] - pub manager: Option, - - #[serde( - rename = "email", - )] - pub email: String, - - #[serde( - rename = "firstName", - )] - pub first_name: String, - - #[serde( - rename = "lastName", - )] - pub last_name: String, - - #[serde( - rename = "middleNames", - skip_serializing_if = "Option::is_none", - )] - pub middle_names: Option, - - #[serde( - rename = "homeAddress", - )] - pub home_address: Address, - - #[serde( - rename = "ssn", - )] - pub ssn: String, - - #[serde( - rename = "height", - )] - pub height: f64, - - #[serde( - rename = "dob", - serialize_with = "serialize_datetime", - deserialize_with = "deserialize_datetime", - )] - pub dob: DateTime, - - #[serde( - rename = "$identifier", - )] - pub _identifier: String, -} - -#[derive(Debug, Serialize, Deserialize)] -pub struct CompanyEvent { - #[serde( - rename = "$class", - )] - pub _class: String, - - #[serde( - rename = "$timestamp", - serialize_with = "serialize_datetime", - deserialize_with = "deserialize_datetime", - )] - pub _timestamp: DateTime, -} - -#[derive(Debug, Serialize, Deserialize)] -pub struct Onboarded { - #[serde( - rename = "$class", - )] - pub _class: String, - - #[serde(rename = "employee")] - pub employee: Employee, - - #[serde( - rename = "$timestamp", - serialize_with = "serialize_datetime", - deserialize_with = "deserialize_datetime", - )] - pub _timestamp: DateTime, -} - -#[derive(Debug, Serialize, Deserialize)] -pub struct ChangeOfAddress { - #[serde( - rename = "$class", - )] - pub _class: String, - - #[serde(rename = "Person")] - pub person: Person, - - #[serde( - rename = "newAddress", - )] - pub new_address: Address, - - #[serde( - rename = "$timestamp", - serialize_with = "serialize_datetime", - deserialize_with = "deserialize_datetime", - )] - pub _timestamp: DateTime, -} - -", -} -`; - -exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'typescript' 1`] = ` -{ - "key": "concerto@1.0.0.ts", - "value": "/* eslint-disable @typescript-eslint/no-empty-interface */ -// Generated code for namespace: concerto@1.0.0 - -// imports - -// Warning: Beware of circular dependencies when modifying these imports -import type { - State, - IAddress, - ICompany, - Department, - LaptopMake -} from './org.acme.hr'; - -// Warning: Beware of circular dependencies when modifying these imports -import type { - IEquipment -} from './org.acme.hr'; - -// Warning: Beware of circular dependencies when modifying these imports -import type { - IPerson -} from './org.acme.hr'; - -// Warning: Beware of circular dependencies when modifying these imports -import type { - IChangeOfAddress -} from './org.acme.hr'; - -// Warning: Beware of circular dependencies when modifying these imports -import type { - ICompanyEvent -} from './org.acme.hr'; - -// interfaces -export interface IConcept { - $class: string; -} - -export type ConceptUnion = IAddress | -ICompany; - -export interface IAsset extends IConcept { - $identifier: string; -} - -export type AssetUnion = IEquipment; - -export interface IParticipant extends IConcept { - $identifier: string; -} - -export type ParticipantUnion = IPerson; - -export interface ITransaction extends IConcept { - $timestamp: Date; -} - -export type TransactionUnion = IChangeOfAddress; - -export interface IEvent extends IConcept { - $timestamp: Date; -} - -export type EventUnion = ICompanyEvent; - -", -} -`; - -exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'typescript' 2`] = ` -{ - "key": "concerto.ts", - "value": "/* eslint-disable @typescript-eslint/no-empty-interface */ -// Generated code for namespace: concerto - -// imports - -// interfaces -export interface IConcept { - $class: string; -} - -export interface IAsset extends IConcept { - $identifier: string; -} - -export interface IParticipant extends IConcept { - $identifier: string; -} - -export interface ITransaction extends IConcept { -} - -export interface IEvent extends IConcept { -} - -", -} -`; - -exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'typescript' 3`] = ` -{ - "key": "org.acme.hr.ts", - "value": "/* eslint-disable @typescript-eslint/no-empty-interface */ -// Generated code for namespace: org.acme.hr - -// imports - -// Warning: Beware of circular dependencies when modifying these imports - -// Warning: Beware of circular dependencies when modifying these imports - -// Warning: Beware of circular dependencies when modifying these imports - -// Warning: Beware of circular dependencies when modifying these imports -import {IConcept,IAsset,IParticipant,IEvent,ITransaction} from './concerto@1.0.0'; - -// interfaces -export enum State { - MA = 'MA', - NY = 'NY', - CO = 'CO', - WA = 'WA', - IL = 'IL', - CA = 'CA', -} - -export interface IAddress extends IConcept { - street: string; - city: string; - state?: State; - zipCode: string; - country: string; - dictionary1: Map1; - dictionary2: Map2; - dictionary3: Map3; - dictionary4: Map4; - dictionary5: Map5; - dictionary6: Map6; -} - -export type Map1 = Map; - -export type Map2 = Map; - -export type Map3 = Map; - -export type Map4 = Map; - -export type Map5 = Map; - -export type Map6 = Map; - -export interface ICompany extends IConcept { - name: string; - headquarters: IAddress; -} - -export enum Department { - Sales = 'Sales', - Marketing = 'Marketing', - Finance = 'Finance', - HR = 'HR', - Engineering = 'Engineering', - Design = 'Design', -} - -export interface IEquipment extends IAsset { - serialNumber: string; -} - -export type EquipmentUnion = ILaptop; - -export enum LaptopMake { - Apple = 'Apple', - Microsoft = 'Microsoft', -} - -export interface ILaptop extends IEquipment { - make: LaptopMake; -} - -export interface IPerson extends IParticipant { - email: string; - firstName: string; - lastName: string; - middleNames?: string; - homeAddress: IAddress; - ssn: string; - height: number; - dob: Date; -} - -export type PersonUnion = IEmployee | -IContractor; - -export interface IEmployee extends IPerson { - employeeId: string; - salary: number; - numDependents: number; - retired: boolean; - department: Department; - officeAddress: IAddress; - companyAssets: IEquipment[]; - manager?: IManager; -} - -export type EmployeeUnion = IManager; - -export interface IContractor extends IPerson { - company: ICompany; - manager?: IManager; -} - -export interface IManager extends IEmployee { - reports?: IPerson[]; -} - -export interface ICompanyEvent extends IEvent { -} - -export type CompanyEventUnion = IOnboarded; - -export interface IOnboarded extends ICompanyEvent { - employee: IEmployee; -} - -export interface IChangeOfAddress extends ITransaction { - Person: IPerson; - newAddress: IAddress; -} - -", -} -`; - -exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'vocabulary' 1`] = ` -{ - "key": "org.acme.hr_en.voc", - "value": "#Generated vocabulary for namespace: org.acme.hr -locale: en -namespace: org.acme.hr -declarations: - - State: State - properties: - - MA: MA of the State - - NY: NY of the State - - CO: CO of the State - - WA: WA of the State - - IL: IL of the State - - CA: CA of the State - - Address: Address - properties: - - street: Street of the Address - - city: City of the Address - - state: State of the Address - - zipCode: Zip Code of the Address - - country: Country of the Address - - dictionary1: Dictionary1 of the Address - - dictionary2: Dictionary2 of the Address - - dictionary3: Dictionary3 of the Address - - dictionary4: Dictionary4 of the Address - - dictionary5: Dictionary5 of the Address - - dictionary6: Dictionary6 of the Address - - Time: Time - - Company: Company - properties: - - name: Name of the Company - - headquarters: Headquarters of the Company - - Department: Department - properties: - - Sales: Sales of the Department - - Marketing: Marketing of the Department - - Finance: Finance of the Department - - HR: HR of the Department - - Engineering: Engineering of the Department - - Design: Design of the Department - - Equipment: Equipment - properties: - - serialNumber: Serial Number of the Equipment - - LaptopMake: Laptop Make - properties: - - Apple: Apple of the Laptop Make - - Microsoft: Microsoft of the Laptop Make - - Laptop: Laptop - properties: - - make: Make of the Laptop - - SSN: SSN - - Person: Person - properties: - - email: Email of the Person - - firstName: First Name of the Person - - lastName: Last Name of the Person - - middleNames: Middle Names of the Person - - homeAddress: Home Address of the Person - - ssn: Ssn of the Person - - height: Height of the Person - - dob: Dob of the Person - - Employee: Employee - properties: - - employeeId: Employee Id of the Employee - - salary: Salary of the Employee - - numDependents: Num Dependents of the Employee - - retired: Retired of the Employee - - department: Department of the Employee - - officeAddress: Office Address of the Employee - - companyAssets: Company Assets of the Employee - - manager: Manager of the Employee - - Contractor: Contractor - properties: - - company: Company of the Contractor - - manager: Manager of the Contractor - - Manager: Manager - properties: - - reports: Reports of the Manager - - CompanyEvent: Company Event - - Onboarded: Onboarded - properties: - - employee: Employee of the Onboarded - - ChangeOfAddress: Change Of Address - properties: - - Person: Person of the Change Of Address - - newAddress: New Address of the Change Of Address -", -} -`; - -exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'xmlschema' 1`] = ` -{ - "key": "concerto@1.0.0.xsd", - "value": " - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -", -} -`; - -exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'xmlschema' 2`] = ` -{ - "key": "concerto.xsd", - "value": " - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -", -} -`; - -exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'xmlschema' 3`] = ` -{ - "key": "org.acme.hr.xsd", - "value": " - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -", -} -`; - -exports[`codegen #formats check we can convert all formats from namespace versioned CTO without the base model, format 'mermaid' 1`] = ` -{ - "key": "model.mmd", - "value": "classDiagram -class \`org.acme.hr@1.0.0.State\` { -<< enumeration>> - + \`MA\` - + \`NY\` - + \`CO\` - + \`WA\` - + \`IL\` - + \`CA\` -} - -class \`org.acme.hr@1.0.0.Address\` { -<< concept>> - + \`String\` \`street\` - + \`String\` \`city\` - + \`State\` \`state\` - + \`String\` \`zipCode\` - + \`String\` \`country\` - + \`Map1\` \`dictionary1\` - + \`Map2\` \`dictionary2\` - + \`Map3\` \`dictionary3\` - + \`Map4\` \`dictionary4\` - + \`Map5\` \`dictionary5\` - + \`Map6\` \`dictionary6\` -} - -\`org.acme.hr@1.0.0.Address\` "1" *-- "1" \`org.acme.hr@1.0.0.State\` -\`org.acme.hr@1.0.0.Address\` "1" *-- "1" \`org.acme.hr@1.0.0.Map1\` -\`org.acme.hr@1.0.0.Address\` "1" *-- "1" \`org.acme.hr@1.0.0.Map2\` -\`org.acme.hr@1.0.0.Address\` "1" *-- "1" \`org.acme.hr@1.0.0.Map3\` -\`org.acme.hr@1.0.0.Address\` "1" *-- "1" \`org.acme.hr@1.0.0.Map4\` -\`org.acme.hr@1.0.0.Address\` "1" *-- "1" \`org.acme.hr@1.0.0.Map5\` -\`org.acme.hr@1.0.0.Address\` "1" *-- "1" \`org.acme.hr@1.0.0.Map6\` -class \`org.acme.hr@1.0.0.Company\` { -<< concept>> - + \`String\` \`name\` - + \`Address\` \`headquarters\` -} - -\`org.acme.hr@1.0.0.Company\` "1" *-- "1" \`org.acme.hr@1.0.0.Address\` -class \`org.acme.hr@1.0.0.Department\` { -<< enumeration>> - + \`Sales\` - + \`Marketing\` - + \`Finance\` - + \`HR\` - + \`Engineering\` - + \`Design\` -} - -class \`org.acme.hr@1.0.0.Equipment\` { -<< asset>> - + \`String\` \`serialNumber\` -} - -class \`org.acme.hr@1.0.0.LaptopMake\` { -<< enumeration>> - + \`Apple\` - + \`Microsoft\` -} - -class \`org.acme.hr@1.0.0.Laptop\` { -<< asset>> - + \`LaptopMake\` \`make\` -} - -\`org.acme.hr@1.0.0.Laptop\` "1" *-- "1" \`org.acme.hr@1.0.0.LaptopMake\` -\`org.acme.hr@1.0.0.Laptop\` --|> \`org.acme.hr@1.0.0.Equipment\` -class \`org.acme.hr@1.0.0.Person\` { -<< participant>> - + \`String\` \`email\` - + \`String\` \`firstName\` - + \`String\` \`lastName\` - + \`String\` \`middleNames\` - + \`Address\` \`homeAddress\` - + \`String\` \`ssn\` - + \`Double\` \`height\` - + \`DateTime\` \`dob\` -} - -\`org.acme.hr@1.0.0.Person\` "1" *-- "1" \`org.acme.hr@1.0.0.Address\` -\`org.acme.hr@1.0.0.Person\` "1" *-- "1" \`org.acme.hr@1.0.0.SSN\` -class \`org.acme.hr@1.0.0.Employee\` { -<< participant>> - + \`String\` \`employeeId\` - + \`Long\` \`salary\` - + \`Integer\` \`numDependents\` - + \`Boolean\` \`retired\` - + \`Department\` \`department\` - + \`Address\` \`officeAddress\` - + \`Equipment[]\` \`companyAssets\` - + \`Manager\` \`manager\` -} - -\`org.acme.hr@1.0.0.Employee\` "1" *-- "1" \`org.acme.hr@1.0.0.Department\` -\`org.acme.hr@1.0.0.Employee\` "1" *-- "1" \`org.acme.hr@1.0.0.Address\` -\`org.acme.hr@1.0.0.Employee\` "1" *-- "*" \`org.acme.hr@1.0.0.Equipment\` -\`org.acme.hr@1.0.0.Employee\` "1" o-- "1" \`org.acme.hr@1.0.0.Manager\` : manager -\`org.acme.hr@1.0.0.Employee\` --|> \`org.acme.hr@1.0.0.Person\` -class \`org.acme.hr@1.0.0.Contractor\` { -<< participant>> - + \`Company\` \`company\` - + \`Manager\` \`manager\` -} - -\`org.acme.hr@1.0.0.Contractor\` "1" *-- "1" \`org.acme.hr@1.0.0.Company\` -\`org.acme.hr@1.0.0.Contractor\` "1" o-- "1" \`org.acme.hr@1.0.0.Manager\` : manager -\`org.acme.hr@1.0.0.Contractor\` --|> \`org.acme.hr@1.0.0.Person\` -class \`org.acme.hr@1.0.0.Manager\` { -<< participant>> - + \`Person[]\` \`reports\` -} - -\`org.acme.hr@1.0.0.Manager\` "1" o-- "*" \`org.acme.hr@1.0.0.Person\` : reports -\`org.acme.hr@1.0.0.Manager\` --|> \`org.acme.hr@1.0.0.Employee\` -class \`org.acme.hr@1.0.0.CompanyEvent\` -<< event>> \`org.acme.hr@1.0.0.CompanyEvent\` - -class \`org.acme.hr@1.0.0.Onboarded\` { -<< event>> - + \`Employee\` \`employee\` -} - -\`org.acme.hr@1.0.0.Onboarded\` "1" o-- "1" \`org.acme.hr@1.0.0.Employee\` : employee -\`org.acme.hr@1.0.0.Onboarded\` --|> \`org.acme.hr@1.0.0.CompanyEvent\` -class \`org.acme.hr@1.0.0.ChangeOfAddress\` { -<< transaction>> - + \`Person\` \`Person\` - + \`Address\` \`newAddress\` -} - -\`org.acme.hr@1.0.0.ChangeOfAddress\` "1" o-- "1" \`org.acme.hr@1.0.0.Person\` : Person -\`org.acme.hr@1.0.0.ChangeOfAddress\` "1" *-- "1" \`org.acme.hr@1.0.0.Address\` -", -} -`; - -exports[`codegen #formats check we can convert all formats from namespace versioned CTO without the base model, format 'plantuml' 1`] = ` -{ - "key": "model.puml", - "value": "@startuml -title -Model -endtitle -class org.acme.hr_1_0_0.State << (E,grey) >> { - + MA - + NY - + CO - + WA - + IL - + CA -} -class org.acme.hr_1_0_0.Address { - + String street - + String city - + State state - + String zipCode - + String country - + Map1 dictionary1 - + Map2 dictionary2 - + Map3 dictionary3 - + Map4 dictionary4 - + Map5 dictionary5 - + Map6 dictionary6 -} -org.acme.hr_1_0_0.Address "1" *-- "1" org.acme.hr_1_0_0.State : state -org.acme.hr_1_0_0.Address "1" *-- "1" org.acme.hr_1_0_0.Map1 : dictionary1 -org.acme.hr_1_0_0.Address "1" *-- "1" org.acme.hr_1_0_0.Map2 : dictionary2 -org.acme.hr_1_0_0.Address "1" *-- "1" org.acme.hr_1_0_0.Map3 : dictionary3 -org.acme.hr_1_0_0.Address "1" *-- "1" org.acme.hr_1_0_0.Map4 : dictionary4 -org.acme.hr_1_0_0.Address "1" *-- "1" org.acme.hr_1_0_0.Map5 : dictionary5 -org.acme.hr_1_0_0.Address "1" *-- "1" org.acme.hr_1_0_0.Map6 : dictionary6 -class org.acme.hr_1_0_0.Company { - + String name - + Address headquarters -} -org.acme.hr_1_0_0.Company "1" *-- "1" org.acme.hr_1_0_0.Address : headquarters -class org.acme.hr_1_0_0.Department << (E,grey) >> { - + Sales - + Marketing - + Finance - + HR - + Engineering - + Design -} -class org.acme.hr_1_0_0.Equipment << (A,green) >> { - + String serialNumber -} -class org.acme.hr_1_0_0.LaptopMake << (E,grey) >> { - + Apple - + Microsoft -} -class org.acme.hr_1_0_0.Laptop << (A,green) >> { - + LaptopMake make -} -org.acme.hr_1_0_0.Laptop "1" *-- "1" org.acme.hr_1_0_0.LaptopMake : make -org.acme.hr_1_0_0.Laptop --|> org.acme.hr_1_0_0.Equipment -class org.acme.hr_1_0_0.Person << (P,lightblue) >> { - + String email - + String firstName - + String lastName - + String middleNames - + Address homeAddress - + String ssn - + Double height - + DateTime dob -} -org.acme.hr_1_0_0.Person "1" *-- "1" org.acme.hr_1_0_0.Address : homeAddress -org.acme.hr_1_0_0.Person "1" *-- "1" org.acme.hr_1_0_0.SSN : ssn -class org.acme.hr_1_0_0.Employee << (P,lightblue) >> { - + String employeeId - + Long salary - + Integer numDependents - + Boolean retired - + Department department - + Address officeAddress - + Equipment[] companyAssets - + Manager manager -} -org.acme.hr_1_0_0.Employee "1" *-- "1" org.acme.hr_1_0_0.Department : department -org.acme.hr_1_0_0.Employee "1" *-- "1" org.acme.hr_1_0_0.Address : officeAddress -org.acme.hr_1_0_0.Employee "1" *-- "*" org.acme.hr_1_0_0.Equipment : companyAssets -org.acme.hr_1_0_0.Employee "1" o-- "1" org.acme.hr_1_0_0.Manager : manager -org.acme.hr_1_0_0.Employee --|> org.acme.hr_1_0_0.Person -class org.acme.hr_1_0_0.Contractor << (P,lightblue) >> { - + Company company - + Manager manager -} -org.acme.hr_1_0_0.Contractor "1" *-- "1" org.acme.hr_1_0_0.Company : company -org.acme.hr_1_0_0.Contractor "1" o-- "1" org.acme.hr_1_0_0.Manager : manager -org.acme.hr_1_0_0.Contractor --|> org.acme.hr_1_0_0.Person -class org.acme.hr_1_0_0.Manager << (P,lightblue) >> { - + Person[] reports -} -org.acme.hr_1_0_0.Manager "1" o-- "*" org.acme.hr_1_0_0.Person : reports -org.acme.hr_1_0_0.Manager --|> org.acme.hr_1_0_0.Employee -class org.acme.hr_1_0_0.CompanyEvent { -} -class org.acme.hr_1_0_0.Onboarded { - + Employee employee -} -org.acme.hr_1_0_0.Onboarded "1" o-- "1" org.acme.hr_1_0_0.Employee : employee -org.acme.hr_1_0_0.Onboarded --|> org.acme.hr_1_0_0.CompanyEvent -class org.acme.hr_1_0_0.ChangeOfAddress << (T,yellow) >> { - + Person Person - + Address newAddress -} -org.acme.hr_1_0_0.ChangeOfAddress "1" o-- "1" org.acme.hr_1_0_0.Person : Person -org.acme.hr_1_0_0.ChangeOfAddress "1" *-- "1" org.acme.hr_1_0_0.Address : newAddress -@enduml -", -} -`; - exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'avro' 1`] = ` { "key": "concerto@1.0.0.avdl", @@ -9888,6 +4762,66 @@ xmlns:concerto="concerto" + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From cd7066c7cbbe165ac4365b4eea6cec503ba404d7 Mon Sep 17 00:00:00 2001 From: Jonathan Casey Date: Mon, 16 Oct 2023 13:47:51 +0100 Subject: [PATCH 04/20] feat(map): write scalars as primitives Signed-off-by: Jonathan Casey --- lib/codegen/fromcto/xmlschema/xmlschemavisitor.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/codegen/fromcto/xmlschema/xmlschemavisitor.js b/lib/codegen/fromcto/xmlschema/xmlschemavisitor.js index 29c7e2d9..1a6e9542 100644 --- a/lib/codegen/fromcto/xmlschema/xmlschemavisitor.js +++ b/lib/codegen/fromcto/xmlschema/xmlschemavisitor.js @@ -305,8 +305,10 @@ class XmlSchemaVisitor { default: if(!ModelUtil.getNamespace(type)) { const typeDeclaration = mapDeclaration.getModelFile().getAllDeclarations().find(d => d.name === type); - if (typeDeclaration?.isClassDeclaration?.() || typeDeclaration?.isScalarDeclaration?.()) { + if (typeDeclaration?.isClassDeclaration?.() ) { return `${ModelUtil.parseNamespace(mapDeclaration.getModelFile().getNamespace()).name}:${mapElement.getType()}`; + } else if (typeDeclaration?.isScalarDeclaration?.()) { + return this.toXsType(typeDeclaration.getType()); } else { return `concerto:${mapElement.getType()}`; } From fc880d03438866da595ba00031817bb88817f6f7 Mon Sep 17 00:00:00 2001 From: Jonathan Casey Date: Mon, 16 Oct 2023 13:49:24 +0100 Subject: [PATCH 05/20] test(map): adds more test cases Signed-off-by: Jonathan Casey --- .../fromcto/xmlschema/xmlschemavisitor.js | 151 +++++++++++++----- 1 file changed, 115 insertions(+), 36 deletions(-) diff --git a/test/codegen/fromcto/xmlschema/xmlschemavisitor.js b/test/codegen/fromcto/xmlschema/xmlschemavisitor.js index 0d7ba97d..b9cf89aa 100644 --- a/test/codegen/fromcto/xmlschema/xmlschemavisitor.js +++ b/test/codegen/fromcto/xmlschema/xmlschemavisitor.js @@ -29,6 +29,7 @@ const ModelFile = require('@accordproject/concerto-core').ModelFile; const ModelManager = require('@accordproject/concerto-core').ModelManager; const RelationshipDeclaration = require('@accordproject/concerto-core').RelationshipDeclaration; const FileWriter = require('@accordproject/concerto-util').FileWriter; +const ModelUtil = require('@accordproject/concerto-core').ModelUtil; describe('XmlSchemaVisitor', function () { let xmlSchemaVisitor; @@ -380,19 +381,20 @@ describe('XmlSchemaVisitor', function () { describe('visitMapDeclaration', () => { - it.skip('should write the map declaration for a map ', () => { - let acceptSpy = sinon.spy(); + + before(() => { + sinon.stub(ModelUtil, 'parseNamespace').callsFake(() => { + return {name:'org.acme'}; + }); + }); + + it('should write the map declaration for a map ', () => { let param = { fileWriter: mockFileWriter }; - const mockField = sinon.createStubInstance(Field); const getAllDeclarations = sinon.stub(); - - mockField.dummy = 'Dummy Value'; - mockField.getModelFile.returns({ getAllDeclarations: getAllDeclarations }); - const mockMapDeclaration = sinon.createStubInstance(MapDeclaration); const findStub = sinon.stub(); const getKeyType = sinon.stub(); @@ -402,11 +404,10 @@ describe('XmlSchemaVisitor', function () { findStub.returns(mockMapDeclaration); getKeyType.returns('String'); getValueType.returns('String'); - mockField.getName.returns('Map1'); mockMapDeclaration.getName.returns('Map1'); mockMapDeclaration.getKey.returns({ getType: getKeyType }); mockMapDeclaration.getValue.returns({ getType: getValueType }); - + mockMapDeclaration.getModelFile.returns({ getAllDeclarations: getAllDeclarations }); xmlSchemaVisitor.visitMapDeclaration(mockMapDeclaration, param); @@ -424,32 +425,33 @@ describe('XmlSchemaVisitor', function () { }); - it.only('should write the map declaration for a map ', () => { + it('should write the map declaration for a map ', () => { let param = { fileWriter: mockFileWriter }; - const mockField = sinon.createStubInstance(Field); - const getAllDeclarations = sinon.stub(); - - mockField.dummy = 'Dummy Value'; - mockField.getModelFile.returns({ getAllDeclarations: getAllDeclarations }); - const mockMapDeclaration = sinon.createStubInstance(MapDeclaration); + const getAllDeclarations = sinon.stub(); + const isScalarDeclaration = sinon.stub(); const findStub = sinon.stub(); const getKeyType = sinon.stub(); const getValueType = sinon.stub(); + const getScalarType = sinon.stub(); getAllDeclarations.returns({ find: findStub }); + mockMapDeclaration.getModelFile.returns({ getAllDeclarations: getAllDeclarations}); + mockMapDeclaration.isScalarDeclaration.returns(true); + findStub.returns(mockMapDeclaration); getKeyType.returns('String'); getValueType.returns('SSN'); - mockField.getName.returns('Map1'); + getScalarType.returns('String'); mockMapDeclaration.getName.returns('Map1'); mockMapDeclaration.getKey.returns({ getType: getKeyType }); + mockMapDeclaration.getType.returns('String'); mockMapDeclaration.getValue.returns({ getType: getValueType }); - + isScalarDeclaration.returns(true); xmlSchemaVisitor.visitMapDeclaration(mockMapDeclaration, param); @@ -466,32 +468,72 @@ describe('XmlSchemaVisitor', function () { param.fileWriter.writeLine.getCall(9).args.should.deep.equal([0, '']); }); - it.skip('should write the map declaration for a map ', () => { + it('should write the map declaration for a map ', () => { let param = { fileWriter: mockFileWriter }; const mockMapDeclaration = sinon.createStubInstance(MapDeclaration); - // const getModelFile = sinon.stub(); const findStub = sinon.stub(); + const getAllDeclarations = sinon.stub(); + const isClassDeclaration = sinon.stub(); + const getNamespaceStub = sinon.stub(); const getKeyType = sinon.stub(); const getValueType = sinon.stub(); - const getAllDeclarations = sinon.stub(); + getAllDeclarations.returns({ find: findStub }); + getNamespaceStub.returns(''); + mockMapDeclaration.getModelFile.returns({ getAllDeclarations: getAllDeclarations, getNamespace: getNamespaceStub}); + mockMapDeclaration.isClassDeclaration.returns(true); + findStub.returns(mockMapDeclaration); + getKeyType.returns('String'); + getValueType.returns('Person'); + isClassDeclaration.returns(true); + mockMapDeclaration.getName.returns('Map1'); + mockMapDeclaration.getKey.returns({ getType: getKeyType }); + mockMapDeclaration.getValue.returns({ getType: getValueType }); - mockMapDeclaration.getModelFile.returns({ getAllDeclarations: getAllDeclarations }); + xmlSchemaVisitor.visitMapDeclaration(mockMapDeclaration, param); + + param.fileWriter.writeLine.callCount.should.deep.equal(10); + param.fileWriter.writeLine.getCall(0).args.should.deep.equal([0, '']); + param.fileWriter.writeLine.getCall(1).args.should.deep.equal([1, '']); + param.fileWriter.writeLine.getCall(2).args.should.deep.equal([2, '']); + param.fileWriter.writeLine.getCall(3).args.should.deep.equal([3, '']); + param.fileWriter.writeLine.getCall(4).args.should.deep.equal([4, '']); + param.fileWriter.writeLine.getCall(5).args.should.deep.equal([4, '']); + param.fileWriter.writeLine.getCall(6).args.should.deep.equal([3, '']); + param.fileWriter.writeLine.getCall(7).args.should.deep.equal([2, '']); + param.fileWriter.writeLine.getCall(8).args.should.deep.equal([1, '']); + param.fileWriter.writeLine.getCall(9).args.should.deep.equal([0, '']); + + }); + + it('should write the map declaration for a map ', () => { + + let param = { + fileWriter: mockFileWriter + }; + + const findStub = sinon.stub(); + const getAllDeclarations = sinon.stub(); + const isClassDeclaration = sinon.stub(); + const getKeyType = sinon.stub(); + const getValueType = sinon.stub(); + const mockMapDeclaration = sinon.createStubInstance(MapDeclaration); getAllDeclarations.returns({ find: findStub }); + mockMapDeclaration.getModelFile.returns({ getAllDeclarations: getAllDeclarations}); + mockMapDeclaration.isClassDeclaration.returns(true); findStub.returns(mockMapDeclaration); getKeyType.returns('String'); - getValueType.returns('String'); - // mockField.getName.returns('Map1'); + getValueType.returns('Long'); + isClassDeclaration.returns(true); mockMapDeclaration.getName.returns('Map1'); mockMapDeclaration.getKey.returns({ getType: getKeyType }); mockMapDeclaration.getValue.returns({ getType: getValueType }); - xmlSchemaVisitor.visitMapDeclaration(mockMapDeclaration, param); param.fileWriter.writeLine.callCount.should.deep.equal(10); @@ -500,41 +542,78 @@ describe('XmlSchemaVisitor', function () { param.fileWriter.writeLine.getCall(2).args.should.deep.equal([2, '']); param.fileWriter.writeLine.getCall(3).args.should.deep.equal([3, '']); param.fileWriter.writeLine.getCall(4).args.should.deep.equal([4, '']); - param.fileWriter.writeLine.getCall(5).args.should.deep.equal([4, '']); + param.fileWriter.writeLine.getCall(5).args.should.deep.equal([4, '']); param.fileWriter.writeLine.getCall(6).args.should.deep.equal([3, '']); param.fileWriter.writeLine.getCall(7).args.should.deep.equal([2, '']); param.fileWriter.writeLine.getCall(8).args.should.deep.equal([1, '']); param.fileWriter.writeLine.getCall(9).args.should.deep.equal([0, '']); }); - it.only('should write the map declaration for a map ', () => { - let acceptSpy = sinon.spy(); + it('should write the map declaration for a map ', () => { let param = { fileWriter: mockFileWriter }; - const mockField = sinon.createStubInstance(Field); + const findStub = sinon.stub(); const getAllDeclarations = sinon.stub(); + const isClassDeclaration = sinon.stub(); + const getKeyType = sinon.stub(); + const getValueType = sinon.stub(); + const mockMapDeclaration = sinon.createStubInstance(MapDeclaration); - mockField.dummy = 'Dummy Value'; - mockField.getModelFile.returns({ getAllDeclarations: getAllDeclarations }); + getAllDeclarations.returns({ find: findStub }); + + mockMapDeclaration.getModelFile.returns({ getAllDeclarations: getAllDeclarations}); + mockMapDeclaration.isClassDeclaration.returns(true); + findStub.returns(mockMapDeclaration); + getKeyType.returns('String'); + getValueType.returns('Double'); + isClassDeclaration.returns(true); + mockMapDeclaration.getName.returns('Map1'); + mockMapDeclaration.getKey.returns({ getType: getKeyType }); + mockMapDeclaration.getValue.returns({ getType: getValueType }); + + xmlSchemaVisitor.visitMapDeclaration(mockMapDeclaration, param); + + param.fileWriter.writeLine.callCount.should.deep.equal(10); + param.fileWriter.writeLine.getCall(0).args.should.deep.equal([0, '']); + param.fileWriter.writeLine.getCall(1).args.should.deep.equal([1, '']); + param.fileWriter.writeLine.getCall(2).args.should.deep.equal([2, '']); + param.fileWriter.writeLine.getCall(3).args.should.deep.equal([3, '']); + param.fileWriter.writeLine.getCall(4).args.should.deep.equal([4, '']); + param.fileWriter.writeLine.getCall(5).args.should.deep.equal([4, '']); + param.fileWriter.writeLine.getCall(6).args.should.deep.equal([3, '']); + param.fileWriter.writeLine.getCall(7).args.should.deep.equal([2, '']); + param.fileWriter.writeLine.getCall(8).args.should.deep.equal([1, '']); + param.fileWriter.writeLine.getCall(9).args.should.deep.equal([0, '']); + }); + + it('should write the map declaration for a map ', () => { + + let param = { + fileWriter: mockFileWriter + }; - const mockMapDeclaration = sinon.createStubInstance(MapDeclaration); const findStub = sinon.stub(); + const getAllDeclarations = sinon.stub(); + const isClassDeclaration = sinon.stub(); const getKeyType = sinon.stub(); const getValueType = sinon.stub(); + const mockMapDeclaration = sinon.createStubInstance(MapDeclaration); + getAllDeclarations.returns({ find: findStub }); + mockMapDeclaration.getModelFile.returns({ getAllDeclarations: getAllDeclarations}); + mockMapDeclaration.isClassDeclaration.returns(true); findStub.returns(mockMapDeclaration); getKeyType.returns('String'); - getValueType.returns('String'); - mockField.getName.returns('Map1'); + getValueType.returns('Integer'); + isClassDeclaration.returns(true); mockMapDeclaration.getName.returns('Map1'); mockMapDeclaration.getKey.returns({ getType: getKeyType }); mockMapDeclaration.getValue.returns({ getType: getValueType }); - xmlSchemaVisitor.visitMapDeclaration(mockMapDeclaration, param); param.fileWriter.writeLine.callCount.should.deep.equal(10); @@ -543,7 +622,7 @@ describe('XmlSchemaVisitor', function () { param.fileWriter.writeLine.getCall(2).args.should.deep.equal([2, '']); param.fileWriter.writeLine.getCall(3).args.should.deep.equal([3, '']); param.fileWriter.writeLine.getCall(4).args.should.deep.equal([4, '']); - param.fileWriter.writeLine.getCall(5).args.should.deep.equal([4, '']); + param.fileWriter.writeLine.getCall(5).args.should.deep.equal([4, '']); param.fileWriter.writeLine.getCall(6).args.should.deep.equal([3, '']); param.fileWriter.writeLine.getCall(7).args.should.deep.equal([2, '']); param.fileWriter.writeLine.getCall(8).args.should.deep.equal([1, '']); From 41cfb7772a81c5820b339d31985f9d10322fe9e9 Mon Sep 17 00:00:00 2001 From: Jonathan Casey Date: Mon, 16 Oct 2023 13:49:35 +0100 Subject: [PATCH 06/20] test(map): update snapshot Signed-off-by: Jonathan Casey --- test/codegen/__snapshots__/codegen.js.snap | 5190 +++++++++++++++++++- 1 file changed, 5188 insertions(+), 2 deletions(-) diff --git a/test/codegen/__snapshots__/codegen.js.snap b/test/codegen/__snapshots__/codegen.js.snap index ba16a857..4d366272 100644 --- a/test/codegen/__snapshots__/codegen.js.snap +++ b/test/codegen/__snapshots__/codegen.js.snap @@ -1,5 +1,5191 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP +exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'avro' 1`] = ` +{ + "key": "concerto@1.0.0.avdl", + "value": "@namespace("concerto@1.0.0") +protocol MyProtocol { + + + record Concept { + } + + record Asset { + string _identifier; + } + + record Participant { + string _identifier; + } + + record Transaction { + @logicalType("timestamp-micros") + long _timestamp; + } + + record Event { + @logicalType("timestamp-micros") + long _timestamp; + } + +} +", +} +`; + +exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'avro' 2`] = ` +{ + "key": "concerto.avdl", + "value": "@namespace("concerto") +protocol MyProtocol { + + + record Concept { + } + + record Asset { + string _identifier; + } + + record Participant { + string _identifier; + } + + record Transaction { + } + + record Event { + } + +} +", +} +`; + +exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'avro' 3`] = ` +{ + "key": "org.acme.hr.avdl", + "value": "@namespace("org.acme.hr") +protocol MyProtocol { + + import idl "concerto@1.0.0.avdl"; + + enum State { + MA, + NY, + CO, + WA, + IL, + CA + } + + record Address { + string street; + string city; + union { null, State } state; + string zipCode; + string country; + Map1 dictionary1; + Map2 dictionary2; + Map3 dictionary3; + Map4 dictionary4; + Map5 dictionary5; + Map6 dictionary6; + } + + record Company { + string name; + Address headquarters; + } + + enum Department { + Sales, + Marketing, + Finance, + HR, + Engineering, + Design + } + + record Equipment { + string serialNumber; + } + + enum LaptopMake { + Apple, + Microsoft + } + + record Laptop { + LaptopMake make; + string serialNumber; + } + + record Person { + string email; + string firstName; + string lastName; + union { null, string } middleNames; + Address homeAddress; + string ssn; + double height; + @logicalType("timestamp-micros") + long dob; + } + + record Employee { + string employeeId; + long salary; + int numDependents; + boolean retired; + Department department; + Address officeAddress; + array companyAssets; + union { null, string } manager; + string email; + string firstName; + string lastName; + union { null, string } middleNames; + Address homeAddress; + string ssn; + double height; + @logicalType("timestamp-micros") + long dob; + } + + record Contractor { + Company company; + union { null, string } manager; + string email; + string firstName; + string lastName; + union { null, string } middleNames; + Address homeAddress; + string ssn; + double height; + @logicalType("timestamp-micros") + long dob; + } + + record Manager { + union { null, array } reports; + string employeeId; + long salary; + int numDependents; + boolean retired; + Department department; + Address officeAddress; + array companyAssets; + union { null, string } manager; + string email; + string firstName; + string lastName; + union { null, string } middleNames; + Address homeAddress; + string ssn; + double height; + @logicalType("timestamp-micros") + long dob; + } + + record CompanyEvent { + @logicalType("timestamp-micros") + long _timestamp; + } + + record Onboarded { + string employee; + @logicalType("timestamp-micros") + long _timestamp; + } + + record ChangeOfAddress { + string Person; + Address newAddress; + @logicalType("timestamp-micros") + long _timestamp; + } + +} +", +} +`; + +exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'csharp' 1`] = ` +{ + "key": "concerto@1.0.0.cs", + "value": "namespace AccordProject.Concerto; +[AccordProject.Concerto.Type(Namespace = "concerto", Version = "1.0.0", Name = "Concept")] +[System.Text.Json.Serialization.JsonConverter(typeof(AccordProject.Concerto.ConcertoConverterFactorySystem))] +public abstract class Concept { + [System.Text.Json.Serialization.JsonPropertyName("$class")] + public virtual string _class { get; } = "concerto@1.0.0.Concept"; +} +[AccordProject.Concerto.Type(Namespace = "concerto", Version = "1.0.0", Name = "Asset")] +[System.Text.Json.Serialization.JsonConverter(typeof(AccordProject.Concerto.ConcertoConverterFactorySystem))] +public abstract class Asset : Concept { + [System.Text.Json.Serialization.JsonPropertyName("$class")] + public override string _class { get; } = "concerto@1.0.0.Asset"; + [AccordProject.Concerto.Identifier()] + [System.Text.Json.Serialization.JsonPropertyName("$identifier")] + public string _identifier { get; set; } +} +[AccordProject.Concerto.Type(Namespace = "concerto", Version = "1.0.0", Name = "Participant")] +[System.Text.Json.Serialization.JsonConverter(typeof(AccordProject.Concerto.ConcertoConverterFactorySystem))] +public abstract class Participant : Concept { + [System.Text.Json.Serialization.JsonPropertyName("$class")] + public override string _class { get; } = "concerto@1.0.0.Participant"; + [AccordProject.Concerto.Identifier()] + [System.Text.Json.Serialization.JsonPropertyName("$identifier")] + public string _identifier { get; set; } +} +[AccordProject.Concerto.Type(Namespace = "concerto", Version = "1.0.0", Name = "Transaction")] +[System.Text.Json.Serialization.JsonConverter(typeof(AccordProject.Concerto.ConcertoConverterFactorySystem))] +public abstract class Transaction : Concept { + [System.Text.Json.Serialization.JsonPropertyName("$class")] + public override string _class { get; } = "concerto@1.0.0.Transaction"; + [System.Text.Json.Serialization.JsonPropertyName("$timestamp")] + public System.DateTime _timestamp { get; set; } +} +[AccordProject.Concerto.Type(Namespace = "concerto", Version = "1.0.0", Name = "Event")] +[System.Text.Json.Serialization.JsonConverter(typeof(AccordProject.Concerto.ConcertoConverterFactorySystem))] +public abstract class Event : Concept { + [System.Text.Json.Serialization.JsonPropertyName("$class")] + public override string _class { get; } = "concerto@1.0.0.Event"; + [System.Text.Json.Serialization.JsonPropertyName("$timestamp")] + public System.DateTime _timestamp { get; set; } +} +", +} +`; + +exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'csharp' 2`] = ` +{ + "key": "concerto.cs", + "value": "namespace AccordProject.Concerto; +[AccordProject.Concerto.Type(Namespace = "concerto", Version = null, Name = "Concept")] +[System.Text.Json.Serialization.JsonConverter(typeof(AccordProject.Concerto.ConcertoConverterFactorySystem))] +public abstract class Concept { + [System.Text.Json.Serialization.JsonPropertyName("$class")] + public virtual string _class { get; } = "concerto.Concept"; +} +[AccordProject.Concerto.Type(Namespace = "concerto", Version = null, Name = "Asset")] +[System.Text.Json.Serialization.JsonConverter(typeof(AccordProject.Concerto.ConcertoConverterFactorySystem))] +public abstract class Asset : Concept { + [System.Text.Json.Serialization.JsonPropertyName("$class")] + public override string _class { get; } = "concerto.Asset"; + [AccordProject.Concerto.Identifier()] + [System.Text.Json.Serialization.JsonPropertyName("$identifier")] + public string _identifier { get; set; } +} +[AccordProject.Concerto.Type(Namespace = "concerto", Version = null, Name = "Participant")] +[System.Text.Json.Serialization.JsonConverter(typeof(AccordProject.Concerto.ConcertoConverterFactorySystem))] +public abstract class Participant : Concept { + [System.Text.Json.Serialization.JsonPropertyName("$class")] + public override string _class { get; } = "concerto.Participant"; + [AccordProject.Concerto.Identifier()] + [System.Text.Json.Serialization.JsonPropertyName("$identifier")] + public string _identifier { get; set; } +} +[AccordProject.Concerto.Type(Namespace = "concerto", Version = null, Name = "Transaction")] +[System.Text.Json.Serialization.JsonConverter(typeof(AccordProject.Concerto.ConcertoConverterFactorySystem))] +public abstract class Transaction : Concept { + [System.Text.Json.Serialization.JsonPropertyName("$class")] + public override string _class { get; } = "concerto.Transaction"; +} +[AccordProject.Concerto.Type(Namespace = "concerto", Version = null, Name = "Event")] +[System.Text.Json.Serialization.JsonConverter(typeof(AccordProject.Concerto.ConcertoConverterFactorySystem))] +public abstract class Event : Concept { + [System.Text.Json.Serialization.JsonPropertyName("$class")] + public override string _class { get; } = "concerto.Event"; +} +", +} +`; + +exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'csharp' 3`] = ` +{ + "key": "org.acme.hr.cs", + "value": "namespace org.acme.hr; +using AccordProject.Concerto; +[System.Text.Json.Serialization.JsonConverter(typeof(System.Text.Json.Serialization.JsonStringEnumConverter))] +public enum State { + MA, + NY, + CO, + WA, + IL, + CA, +} +[AccordProject.Concerto.Type(Namespace = "org.acme.hr", Version = null, Name = "Address")] +[System.Text.Json.Serialization.JsonConverter(typeof(AccordProject.Concerto.ConcertoConverterFactorySystem))] +public class Address : Concept { + [System.Text.Json.Serialization.JsonPropertyName("$class")] + public override string _class { get; } = "org.acme.hr.Address"; + public string street { get; set; } + public string city { get; set; } + public State? state { get; set; } + public string zipCode { get; set; } + public string country { get; set; } + public Dictionary dictionary1 { get; set; } + public Dictionary dictionary2 { get; set; } + public Dictionary dictionary3 { get; set; } + public Dictionary dictionary4 { get; set; } + public Dictionary dictionary5 { get; set; } + public Dictionary dictionary6 { get; set; } +} +//Dummy implementation of the scalar declaration to avoid compilation errors. +class Time_Dummy {} +[AccordProject.Concerto.Type(Namespace = "org.acme.hr", Version = null, Name = "Company")] +[System.Text.Json.Serialization.JsonConverter(typeof(AccordProject.Concerto.ConcertoConverterFactorySystem))] +public class Company : Concept { + [System.Text.Json.Serialization.JsonPropertyName("$class")] + public override string _class { get; } = "org.acme.hr.Company"; + public string name { get; set; } + public Address headquarters { get; set; } +} +[System.Text.Json.Serialization.JsonConverter(typeof(System.Text.Json.Serialization.JsonStringEnumConverter))] +public enum Department { + Sales, + Marketing, + Finance, + HR, + Engineering, + Design, +} +[AccordProject.Concerto.Type(Namespace = "org.acme.hr", Version = null, Name = "Equipment")] +[System.Text.Json.Serialization.JsonConverter(typeof(AccordProject.Concerto.ConcertoConverterFactorySystem))] +public abstract class Equipment : Asset { + [System.Text.Json.Serialization.JsonPropertyName("$class")] + public override string _class { get; } = "org.acme.hr.Equipment"; + [AccordProject.Concerto.Identifier()] + public string serialNumber { get; set; } +} +[System.Text.Json.Serialization.JsonConverter(typeof(System.Text.Json.Serialization.JsonStringEnumConverter))] +public enum LaptopMake { + Apple, + Microsoft, +} +[AccordProject.Concerto.Type(Namespace = "org.acme.hr", Version = null, Name = "Laptop")] +[System.Text.Json.Serialization.JsonConverter(typeof(AccordProject.Concerto.ConcertoConverterFactorySystem))] +public class Laptop : Equipment { + [System.Text.Json.Serialization.JsonPropertyName("$class")] + public override string _class { get; } = "org.acme.hr.Laptop"; + public LaptopMake make { get; set; } +} +//Dummy implementation of the scalar declaration to avoid compilation errors. +class SSN_Dummy {} +[AccordProject.Concerto.Type(Namespace = "org.acme.hr", Version = null, Name = "Person")] +[System.Text.Json.Serialization.JsonConverter(typeof(AccordProject.Concerto.ConcertoConverterFactorySystem))] +public abstract class Person : Participant { + [System.Text.Json.Serialization.JsonPropertyName("$class")] + public override string _class { get; } = "org.acme.hr.Person"; + [AccordProject.Concerto.Identifier()] + public string email { get; set; } + public string firstName { get; set; } + public string lastName { get; set; } + public string? middleNames { get; set; } + public Address homeAddress { get; set; } + [System.ComponentModel.DataAnnotations.RegularExpression(@"\\d{3}-\\d{2}-\\{4}+", ErrorMessage = "Invalid characters")] + public string ssn { get; set; } + public float height { get; set; } + public System.DateTime dob { get; set; } +} +[AccordProject.Concerto.Type(Namespace = "org.acme.hr", Version = null, Name = "Employee")] +[System.Text.Json.Serialization.JsonConverter(typeof(AccordProject.Concerto.ConcertoConverterFactorySystem))] +public class Employee : Person { + [System.Text.Json.Serialization.JsonPropertyName("$class")] + public override string _class { get; } = "org.acme.hr.Employee"; + public string employeeId { get; set; } + public long salary { get; set; } + public int numDependents { get; set; } + public bool retired { get; set; } + public Department department { get; set; } + public Address officeAddress { get; set; } + public Equipment[] companyAssets { get; set; } + public Manager manager { get; set; } +} +[AccordProject.Concerto.Type(Namespace = "org.acme.hr", Version = null, Name = "Contractor")] +[System.Text.Json.Serialization.JsonConverter(typeof(AccordProject.Concerto.ConcertoConverterFactorySystem))] +public class Contractor : Person { + [System.Text.Json.Serialization.JsonPropertyName("$class")] + public override string _class { get; } = "org.acme.hr.Contractor"; + public Company company { get; set; } + public Manager manager { get; set; } +} +[AccordProject.Concerto.Type(Namespace = "org.acme.hr", Version = null, Name = "Manager")] +[System.Text.Json.Serialization.JsonConverter(typeof(AccordProject.Concerto.ConcertoConverterFactorySystem))] +public class Manager : Employee { + [System.Text.Json.Serialization.JsonPropertyName("$class")] + public override string _class { get; } = "org.acme.hr.Manager"; + public Person[] reports { get; set; } +} +[AccordProject.Concerto.Type(Namespace = "org.acme.hr", Version = null, Name = "CompanyEvent")] +[System.Text.Json.Serialization.JsonConverter(typeof(AccordProject.Concerto.ConcertoConverterFactorySystem))] +public class CompanyEvent : Event { + [System.Text.Json.Serialization.JsonPropertyName("$class")] + public override string _class { get; } = "org.acme.hr.CompanyEvent"; +} +[AccordProject.Concerto.Type(Namespace = "org.acme.hr", Version = null, Name = "Onboarded")] +[System.Text.Json.Serialization.JsonConverter(typeof(AccordProject.Concerto.ConcertoConverterFactorySystem))] +public class Onboarded : CompanyEvent { + [System.Text.Json.Serialization.JsonPropertyName("$class")] + public override string _class { get; } = "org.acme.hr.Onboarded"; + public Employee employee { get; set; } +} +[AccordProject.Concerto.Type(Namespace = "org.acme.hr", Version = null, Name = "ChangeOfAddress")] +[System.Text.Json.Serialization.JsonConverter(typeof(AccordProject.Concerto.ConcertoConverterFactorySystem))] +public class ChangeOfAddress : Transaction { + [System.Text.Json.Serialization.JsonPropertyName("$class")] + public override string _class { get; } = "org.acme.hr.ChangeOfAddress"; + public Person Person { get; set; } + public Address newAddress { get; set; } +} +", +} +`; + +exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'golang' 1`] = ` +{ + "key": "concerto@1.0.0.go", + "value": "// Package concerto_1_0_0 contains domain objects and was generated from Concerto namespace concerto@1.0.0. +package concerto_1_0_0 +import "time" + +type Concept struct { +} +type Asset struct { + Concept + Identifier string \`json:"$identifier"\` +} +type Participant struct { + Concept + Identifier string \`json:"$identifier"\` +} +type Transaction struct { + Concept + Timestamp time.Time \`json:"$timestamp"\` +} +type Event struct { + Concept + Timestamp time.Time \`json:"$timestamp"\` +} +", +} +`; + +exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'golang' 2`] = ` +{ + "key": "concerto.go", + "value": "// Package concerto contains domain objects and was generated from Concerto namespace concerto. +package concerto + +type Concept struct { +} +type Asset struct { + Concept + Identifier string \`json:"$identifier"\` +} +type Participant struct { + Concept + Identifier string \`json:"$identifier"\` +} +type Transaction struct { + Concept +} +type Event struct { + Concept +} +", +} +`; + +exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'golang' 3`] = ` +{ + "key": "org.acme.hr.go", + "value": "// Package org_acme_hr contains domain objects and was generated from Concerto namespace org.acme.hr. +package org_acme_hr +import "time" +import "concerto_1_0_0"; + +type State int +const ( + MA State = 1 + iota + NY + CO + WA + IL + CA +) +type Address struct { + concerto_1_0_0.Concept + Street string \`json:"street"\` + City string \`json:"city"\` + State State \`json:"state"\` + ZipCode string \`json:"zipCode"\` + Country string \`json:"country"\` + Dictionary1 Map1 \`json:"dictionary1"\` + Dictionary2 Map2 \`json:"dictionary2"\` + Dictionary3 Map3 \`json:"dictionary3"\` + Dictionary4 Map4 \`json:"dictionary4"\` + Dictionary5 Map5 \`json:"dictionary5"\` + Dictionary6 Map6 \`json:"dictionary6"\` +} +type Company struct { + concerto_1_0_0.Concept + Name string \`json:"name"\` + Headquarters Address \`json:"headquarters"\` +} +type Department int +const ( + Sales Department = 1 + iota + Marketing + Finance + HR + Engineering + Design +) +type Equipment struct { + concerto_1_0_0.Asset + SerialNumber string \`json:"serialNumber"\` +} +type LaptopMake int +const ( + Apple LaptopMake = 1 + iota + Microsoft +) +type Laptop struct { + Equipment + Make LaptopMake \`json:"make"\` +} +type Person struct { + concerto_1_0_0.Participant + Email string \`json:"email"\` + FirstName string \`json:"firstName"\` + LastName string \`json:"lastName"\` + MiddleNames string \`json:"middleNames"\` + HomeAddress Address \`json:"homeAddress"\` + Ssn string \`json:"ssn"\` + Height float64 \`json:"height"\` + Dob time.Time \`json:"dob"\` +} +type Employee struct { + Person + EmployeeId string \`json:"employeeId"\` + Salary int64 \`json:"salary"\` + NumDependents int32 \`json:"numDependents"\` + Retired bool \`json:"retired"\` + Department Department \`json:"department"\` + OfficeAddress Address \`json:"officeAddress"\` + CompanyAssets []Equipment \`json:"companyAssets"\` + Manager *Manager \`json:"manager"\` +} +type Contractor struct { + Person + Company Company \`json:"company"\` + Manager *Manager \`json:"manager"\` +} +type Manager struct { + Employee + Reports []*Person \`json:"reports"\` +} +type CompanyEvent struct { + concerto_1_0_0.Event +} +type Onboarded struct { + CompanyEvent + Employee *Employee \`json:"employee"\` +} +type ChangeOfAddress struct { + concerto_1_0_0.Transaction + Person *Person \`json:"Person"\` + NewAddress Address \`json:"newAddress"\` +} +", +} +`; + +exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'graphql' 1`] = ` +{ + "key": "model.gql", + "value": "directive @resource on OBJECT | FIELD_DEFINITION +scalar DateTime +# namespace org.acme.hr +enum State { + MA + NY + CO + WA + IL + CA +} +type Address { + street: String! + city: String! + state: State + zipCode: String! + country: String! + dictionary1: Map1! + dictionary2: Map2! + dictionary3: Map3! + dictionary4: Map4! + dictionary5: Map5! + dictionary6: Map6! +} +type Company { + name: String! + headquarters: Address! +} +enum Department { + Sales + Marketing + Finance + HR + Engineering + Design +} +type Equipment @resource { + serialNumber: String! + _identifier: String! +} +enum LaptopMake { + Apple + Microsoft +} +type Laptop { + make: LaptopMake! + serialNumber: String! + _identifier: String! +} +type Person @resource { + email: String! + firstName: String! + lastName: String! + middleNames: String + homeAddress: Address! + ssn: String! + height: Float! + dob: DateTime! + _identifier: String! +} +type Employee { + employeeId: String! + salary: Int! + numDependents: Int! + retired: Boolean! + department: Department! + officeAddress: Address! + companyAssets: [Equipment]! + manager: ID # Manager + email: String! + firstName: String! + lastName: String! + middleNames: String + homeAddress: Address! + ssn: String! + height: Float! + dob: DateTime! + _identifier: String! +} +type Contractor { + company: Company! + manager: ID # Manager + email: String! + firstName: String! + lastName: String! + middleNames: String + homeAddress: Address! + ssn: String! + height: Float! + dob: DateTime! + _identifier: String! +} +type Manager { + reports: [ID] # Person + employeeId: String! + salary: Int! + numDependents: Int! + retired: Boolean! + department: Department! + officeAddress: Address! + companyAssets: [Equipment]! + manager: ID # Manager + email: String! + firstName: String! + lastName: String! + middleNames: String + homeAddress: Address! + ssn: String! + height: Float! + dob: DateTime! + _identifier: String! +} +type CompanyEvent { + _timestamp: DateTime! +} +type Onboarded { + employee: ID! # Employee + _timestamp: DateTime! +} +type ChangeOfAddress { + Person: ID! # Person + newAddress: Address! + _timestamp: DateTime! +} +", +} +`; + +exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'java' 1`] = ` +{ + "key": "concerto/Concept.java", + "value": "// this code is generated and should not be modified +package concerto; + +import com.fasterxml.jackson.annotation.*; + +@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, property = "$class") +public abstract class Concept { +} +", +} +`; + +exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'java' 2`] = ` +{ + "key": "concerto/Asset.java", + "value": "// this code is generated and should not be modified +package concerto; + +import com.fasterxml.jackson.annotation.*; + +@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, property = "$class") +@JsonIgnoreProperties({"id"}) +@JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "$identifier") +public abstract class Asset extends Concept { + private String $id; + @JsonProperty("$id") + public String get$id() { + return $id; + } + @JsonProperty("$id") + public void set$id(String i) { + $id = i; + } + + // the accessor for the identifying field + public String getID() { + return this.get$identifier(); + } + + private String $identifier; + public String get$identifier() { + return this.$identifier; + } + public void set$identifier(String $identifier) { + this.$identifier = $identifier; + } +} +", +} +`; + +exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'java' 3`] = ` +{ + "key": "concerto/Participant.java", + "value": "// this code is generated and should not be modified +package concerto; + +import com.fasterxml.jackson.annotation.*; + +@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, property = "$class") +@JsonIgnoreProperties({"id"}) +@JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "$identifier") +public abstract class Participant extends Concept { + private String $id; + @JsonProperty("$id") + public String get$id() { + return $id; + } + @JsonProperty("$id") + public void set$id(String i) { + $id = i; + } + + // the accessor for the identifying field + public String getID() { + return this.get$identifier(); + } + + private String $identifier; + public String get$identifier() { + return this.$identifier; + } + public void set$identifier(String $identifier) { + this.$identifier = $identifier; + } +} +", +} +`; + +exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'java' 4`] = ` +{ + "key": "concerto/Transaction.java", + "value": "// this code is generated and should not be modified +package concerto; + +import com.fasterxml.jackson.annotation.*; + +@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, property = "$class") +public abstract class Transaction extends Concept { +} +", +} +`; + +exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'java' 5`] = ` +{ + "key": "concerto/Event.java", + "value": "// this code is generated and should not be modified +package concerto; + +import com.fasterxml.jackson.annotation.*; + +@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, property = "$class") +public abstract class Event extends Concept { +} +", +} +`; + +exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'java' 6`] = ` +{ + "key": "org/acme/hr/State.java", + "value": "// this code is generated and should not be modified +package org.acme.hr; + +import com.fasterxml.jackson.annotation.*; +@JsonIgnoreProperties({"$class"}) +public enum State { + MA, + NY, + CO, + WA, + IL, + CA, +} +", +} +`; + +exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'java' 7`] = ` +{ + "key": "org/acme/hr/Address.java", + "value": "// this code is generated and should not be modified +package org.acme.hr; + +import concerto.Concept; +import concerto.Asset; +import concerto.Transaction; +import concerto.Participant; +import concerto.Event; +import com.fasterxml.jackson.annotation.*; + +@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, property = "$class") +public class Address extends Concept { + private String street; + private String city; + private State state; + private String zipCode; + private String country; + private Map1 dictionary1; + private Map2 dictionary2; + private Map3 dictionary3; + private Map4 dictionary4; + private Map5 dictionary5; + private Map6 dictionary6; + public String getStreet() { + return this.street; + } + public String getCity() { + return this.city; + } + public State getState() { + return this.state; + } + public String getZipCode() { + return this.zipCode; + } + public String getCountry() { + return this.country; + } + public Map1 getDictionary1() { + return this.dictionary1; + } + public Map2 getDictionary2() { + return this.dictionary2; + } + public Map3 getDictionary3() { + return this.dictionary3; + } + public Map4 getDictionary4() { + return this.dictionary4; + } + public Map5 getDictionary5() { + return this.dictionary5; + } + public Map6 getDictionary6() { + return this.dictionary6; + } + public void setStreet(String street) { + this.street = street; + } + public void setCity(String city) { + this.city = city; + } + public void setState(State state) { + this.state = state; + } + public void setZipCode(String zipCode) { + this.zipCode = zipCode; + } + public void setCountry(String country) { + this.country = country; + } + public void setDictionary1(Map1 dictionary1) { + this.dictionary1 = dictionary1; + } + public void setDictionary2(Map2 dictionary2) { + this.dictionary2 = dictionary2; + } + public void setDictionary3(Map3 dictionary3) { + this.dictionary3 = dictionary3; + } + public void setDictionary4(Map4 dictionary4) { + this.dictionary4 = dictionary4; + } + public void setDictionary5(Map5 dictionary5) { + this.dictionary5 = dictionary5; + } + public void setDictionary6(Map6 dictionary6) { + this.dictionary6 = dictionary6; + } +} +", +} +`; + +exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'java' 8`] = ` +{ + "key": "org/acme/hr/Company.java", + "value": "// this code is generated and should not be modified +package org.acme.hr; + +import concerto.Concept; +import concerto.Asset; +import concerto.Transaction; +import concerto.Participant; +import concerto.Event; +import com.fasterxml.jackson.annotation.*; + +@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, property = "$class") +public class Company extends Concept { + private String name; + private Address headquarters; + public String getName() { + return this.name; + } + public Address getHeadquarters() { + return this.headquarters; + } + public void setName(String name) { + this.name = name; + } + public void setHeadquarters(Address headquarters) { + this.headquarters = headquarters; + } +} +", +} +`; + +exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'java' 9`] = ` +{ + "key": "org/acme/hr/Department.java", + "value": "// this code is generated and should not be modified +package org.acme.hr; + +import com.fasterxml.jackson.annotation.*; +@JsonIgnoreProperties({"$class"}) +public enum Department { + Sales, + Marketing, + Finance, + HR, + Engineering, + Design, +} +", +} +`; + +exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'java' 10`] = ` +{ + "key": "org/acme/hr/Equipment.java", + "value": "// this code is generated and should not be modified +package org.acme.hr; + +import concerto.Concept; +import concerto.Asset; +import concerto.Transaction; +import concerto.Participant; +import concerto.Event; +import com.fasterxml.jackson.annotation.*; + +@JsonIgnoreProperties({"id"}) +@JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "serialNumber") +public abstract class Equipment extends Asset { + + // the accessor for the identifying field + public String getID() { + return this.getSerialNumber(); + } + + private String serialNumber; + public String getSerialNumber() { + return this.serialNumber; + } + public void setSerialNumber(String serialNumber) { + this.serialNumber = serialNumber; + } +} +", +} +`; + +exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'java' 11`] = ` +{ + "key": "org/acme/hr/LaptopMake.java", + "value": "// this code is generated and should not be modified +package org.acme.hr; + +import com.fasterxml.jackson.annotation.*; +@JsonIgnoreProperties({"$class"}) +public enum LaptopMake { + Apple, + Microsoft, +} +", +} +`; + +exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'java' 12`] = ` +{ + "key": "org/acme/hr/Laptop.java", + "value": "// this code is generated and should not be modified +package org.acme.hr; + +import concerto.Concept; +import concerto.Asset; +import concerto.Transaction; +import concerto.Participant; +import concerto.Event; +import com.fasterxml.jackson.annotation.*; + +@JsonIgnoreProperties({"id"}) +@JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "serialNumber") +public class Laptop extends Equipment { + + // the accessor for the identifying field + public String getID() { + return this.getSerialNumber(); + } + + private LaptopMake make; + public LaptopMake getMake() { + return this.make; + } + public void setMake(LaptopMake make) { + this.make = make; + } +} +", +} +`; + +exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'java' 13`] = ` +{ + "key": "org/acme/hr/Person.java", + "value": "// this code is generated and should not be modified +package org.acme.hr; + +import concerto.Concept; +import concerto.Asset; +import concerto.Transaction; +import concerto.Participant; +import concerto.Event; +import com.fasterxml.jackson.annotation.*; + +@JsonIgnoreProperties({"id"}) +@JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "email") +public abstract class Person extends Participant { + + // the accessor for the identifying field + public String getID() { + return this.getEmail(); + } + + private String email; + private String firstName; + private String lastName; + private String middleNames; + private Address homeAddress; + private String ssn; + private double height; + private java.util.Date dob; + public String getEmail() { + return this.email; + } + public String getFirstName() { + return this.firstName; + } + public String getLastName() { + return this.lastName; + } + public String getMiddleNames() { + return this.middleNames; + } + public Address getHomeAddress() { + return this.homeAddress; + } + public String getSsn() { + return this.ssn; + } + public double getHeight() { + return this.height; + } + public java.util.Date getDob() { + return this.dob; + } + public void setEmail(String email) { + this.email = email; + } + public void setFirstName(String firstName) { + this.firstName = firstName; + } + public void setLastName(String lastName) { + this.lastName = lastName; + } + public void setMiddleNames(String middleNames) { + this.middleNames = middleNames; + } + public void setHomeAddress(Address homeAddress) { + this.homeAddress = homeAddress; + } + public void setSsn(String ssn) { + this.ssn = ssn; + } + public void setHeight(double height) { + this.height = height; + } + public void setDob(java.util.Date dob) { + this.dob = dob; + } +} +", +} +`; + +exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'java' 14`] = ` +{ + "key": "org/acme/hr/Employee.java", + "value": "// this code is generated and should not be modified +package org.acme.hr; + +import concerto.Concept; +import concerto.Asset; +import concerto.Transaction; +import concerto.Participant; +import concerto.Event; +import com.fasterxml.jackson.annotation.*; + +@JsonIgnoreProperties({"id"}) +@JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "email") +public class Employee extends Person { + + // the accessor for the identifying field + public String getID() { + return this.getEmail(); + } + + private String employeeId; + private long salary; + private int numDependents; + private boolean retired; + private Department department; + private Address officeAddress; + private Equipment[] companyAssets; + private Manager manager; + public String getEmployeeId() { + return this.employeeId; + } + public long getSalary() { + return this.salary; + } + public int getNumDependents() { + return this.numDependents; + } + public boolean getRetired() { + return this.retired; + } + public Department getDepartment() { + return this.department; + } + public Address getOfficeAddress() { + return this.officeAddress; + } + public Equipment[] getCompanyAssets() { + return this.companyAssets; + } + public Manager getManager() { + return this.manager; + } + public void setEmployeeId(String employeeId) { + this.employeeId = employeeId; + } + public void setSalary(long salary) { + this.salary = salary; + } + public void setNumDependents(int numDependents) { + this.numDependents = numDependents; + } + public void setRetired(boolean retired) { + this.retired = retired; + } + public void setDepartment(Department department) { + this.department = department; + } + public void setOfficeAddress(Address officeAddress) { + this.officeAddress = officeAddress; + } + public void setCompanyAssets(Equipment[] companyAssets) { + this.companyAssets = companyAssets; + } + public void setManager(Manager manager) { + this.manager = manager; + } +} +", +} +`; + +exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'java' 15`] = ` +{ + "key": "org/acme/hr/Contractor.java", + "value": "// this code is generated and should not be modified +package org.acme.hr; + +import concerto.Concept; +import concerto.Asset; +import concerto.Transaction; +import concerto.Participant; +import concerto.Event; +import com.fasterxml.jackson.annotation.*; + +@JsonIgnoreProperties({"id"}) +@JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "email") +public class Contractor extends Person { + + // the accessor for the identifying field + public String getID() { + return this.getEmail(); + } + + private Company company; + private Manager manager; + public Company getCompany() { + return this.company; + } + public Manager getManager() { + return this.manager; + } + public void setCompany(Company company) { + this.company = company; + } + public void setManager(Manager manager) { + this.manager = manager; + } +} +", +} +`; + +exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'java' 16`] = ` +{ + "key": "org/acme/hr/Manager.java", + "value": "// this code is generated and should not be modified +package org.acme.hr; + +import concerto.Concept; +import concerto.Asset; +import concerto.Transaction; +import concerto.Participant; +import concerto.Event; +import com.fasterxml.jackson.annotation.*; + +@JsonIgnoreProperties({"id"}) +@JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "email") +public class Manager extends Employee { + + // the accessor for the identifying field + public String getID() { + return this.getEmail(); + } + + private Person[] reports; + public Person[] getReports() { + return this.reports; + } + public void setReports(Person[] reports) { + this.reports = reports; + } +} +", +} +`; + +exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'java' 17`] = ` +{ + "key": "org/acme/hr/CompanyEvent.java", + "value": "// this code is generated and should not be modified +package org.acme.hr; + +import concerto.Concept; +import concerto.Asset; +import concerto.Transaction; +import concerto.Participant; +import concerto.Event; +import com.fasterxml.jackson.annotation.*; + +public class CompanyEvent extends Event { +} +", +} +`; + +exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'java' 18`] = ` +{ + "key": "org/acme/hr/Onboarded.java", + "value": "// this code is generated and should not be modified +package org.acme.hr; + +import concerto.Concept; +import concerto.Asset; +import concerto.Transaction; +import concerto.Participant; +import concerto.Event; +import com.fasterxml.jackson.annotation.*; + +public class Onboarded extends CompanyEvent { + private Employee employee; + public Employee getEmployee() { + return this.employee; + } + public void setEmployee(Employee employee) { + this.employee = employee; + } +} +", +} +`; + +exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'java' 19`] = ` +{ + "key": "org/acme/hr/ChangeOfAddress.java", + "value": "// this code is generated and should not be modified +package org.acme.hr; + +import concerto.Concept; +import concerto.Asset; +import concerto.Transaction; +import concerto.Participant; +import concerto.Event; +import com.fasterxml.jackson.annotation.*; + +public class ChangeOfAddress extends Transaction { + private Person Person; + private Address newAddress; + public Person getPerson() { + return this.Person; + } + public Address getNewAddress() { + return this.newAddress; + } + public void setPerson(Person Person) { + this.Person = Person; + } + public void setNewAddress(Address newAddress) { + this.newAddress = newAddress; + } +} +", +} +`; + +exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'jsonschema' 1`] = ` +{ + "key": "schema.json", + "value": "{ + "$schema": "http://json-schema.org/draft-07/schema#", + "definitions": { + "org.acme.hr.State": { + "title": "State", + "description": "An instance of org.acme.hr.State", + "enum": [ + "MA", + "NY", + "CO", + "WA", + "IL", + "CA" + ] + }, + "org.acme.hr.Address": { + "title": "Address", + "description": "An instance of org.acme.hr.Address", + "type": "object", + "properties": { + "$class": { + "type": "string", + "default": "org.acme.hr.Address", + "pattern": "^org\\\\.acme\\\\.hr\\\\.Address$", + "description": "The class identifier for org.acme.hr.Address" + }, + "street": { + "type": "string" + }, + "city": { + "type": "string" + }, + "state": { + "$ref": "#/definitions/org.acme.hr.State" + }, + "zipCode": { + "type": "string" + }, + "country": { + "type": "string" + } + }, + "required": [ + "$class", + "street", + "city", + "zipCode", + "country", + "dictionary1", + "dictionary2", + "dictionary3", + "dictionary4", + "dictionary5", + "dictionary6" + ] + }, + "org.acme.hr.Time": { + "format": "date-time", + "type": "string" + }, + "org.acme.hr.Company": { + "title": "Company", + "description": "An instance of org.acme.hr.Company", + "type": "object", + "properties": { + "$class": { + "type": "string", + "default": "org.acme.hr.Company", + "pattern": "^org\\\\.acme\\\\.hr\\\\.Company$", + "description": "The class identifier for org.acme.hr.Company" + }, + "name": { + "type": "string" + }, + "headquarters": { + "$ref": "#/definitions/org.acme.hr.Address" + } + }, + "required": [ + "$class", + "name", + "headquarters" + ] + }, + "org.acme.hr.Department": { + "title": "Department", + "description": "An instance of org.acme.hr.Department", + "enum": [ + "Sales", + "Marketing", + "Finance", + "HR", + "Engineering", + "Design" + ] + }, + "org.acme.hr.Equipment": { + "title": "Equipment", + "description": "An instance of org.acme.hr.Equipment", + "type": "object", + "properties": { + "$class": { + "type": "string", + "default": "org.acme.hr.Equipment", + "pattern": "^org\\\\.acme\\\\.hr\\\\.Equipment$", + "description": "The class identifier for org.acme.hr.Equipment" + }, + "serialNumber": { + "type": "string", + "description": "The instance identifier for this type" + } + }, + "required": [ + "$class", + "serialNumber" + ], + "$decorators": { + "resource": [] + } + }, + "org.acme.hr.LaptopMake": { + "title": "LaptopMake", + "description": "An instance of org.acme.hr.LaptopMake", + "enum": [ + "Apple", + "Microsoft" + ] + }, + "org.acme.hr.Laptop": { + "title": "Laptop", + "description": "An instance of org.acme.hr.Laptop", + "type": "object", + "properties": { + "$class": { + "type": "string", + "default": "org.acme.hr.Laptop", + "pattern": "^org\\\\.acme\\\\.hr\\\\.Laptop$", + "description": "The class identifier for org.acme.hr.Laptop" + }, + "make": { + "$ref": "#/definitions/org.acme.hr.LaptopMake" + }, + "serialNumber": { + "type": "string", + "description": "The instance identifier for this type" + } + }, + "required": [ + "$class", + "make", + "serialNumber" + ] + }, + "org.acme.hr.SSN": { + "type": "string", + "pattern": "\\\\d{3}-\\\\d{2}-\\\\{4}+" + }, + "org.acme.hr.Person": { + "title": "Person", + "description": "An instance of org.acme.hr.Person", + "type": "object", + "properties": { + "$class": { + "type": "string", + "default": "org.acme.hr.Person", + "pattern": "^org\\\\.acme\\\\.hr\\\\.Person$", + "description": "The class identifier for org.acme.hr.Person" + }, + "email": { + "type": "string", + "description": "The instance identifier for this type" + }, + "firstName": { + "type": "string" + }, + "lastName": { + "type": "string" + }, + "middleNames": { + "type": "string" + }, + "homeAddress": { + "$ref": "#/definitions/org.acme.hr.Address" + }, + "ssn": { + "default": "000-00-0000", + "type": "string", + "pattern": "\\\\d{3}-\\\\d{2}-\\\\{4}+" + }, + "height": { + "type": "number" + }, + "dob": { + "format": "date-time", + "type": "string" + } + }, + "required": [ + "$class", + "email", + "firstName", + "lastName", + "homeAddress", + "ssn", + "height", + "dob" + ], + "$decorators": { + "resource": [] + } + }, + "org.acme.hr.Employee": { + "title": "Employee", + "description": "An instance of org.acme.hr.Employee", + "type": "object", + "properties": { + "$class": { + "type": "string", + "default": "org.acme.hr.Employee", + "pattern": "^org\\\\.acme\\\\.hr\\\\.Employee$", + "description": "The class identifier for org.acme.hr.Employee" + }, + "employeeId": { + "type": "string" + }, + "salary": { + "type": "integer" + }, + "numDependents": { + "type": "integer" + }, + "retired": { + "type": "boolean" + }, + "department": { + "$ref": "#/definitions/org.acme.hr.Department" + }, + "officeAddress": { + "$ref": "#/definitions/org.acme.hr.Address" + }, + "companyAssets": { + "type": "array", + "items": { + "anyOf": [ + { + "$ref": "#/definitions/org.acme.hr.Equipment" + }, + { + "$ref": "#/definitions/org.acme.hr.Laptop" + } + ] + } + }, + "manager": { + "type": "string", + "description": "The identifier of an instance of org.acme.hr.Manager" + }, + "email": { + "type": "string", + "description": "The instance identifier for this type" + }, + "firstName": { + "type": "string" + }, + "lastName": { + "type": "string" + }, + "middleNames": { + "type": "string" + }, + "homeAddress": { + "$ref": "#/definitions/org.acme.hr.Address" + }, + "ssn": { + "default": "000-00-0000", + "type": "string", + "pattern": "\\\\d{3}-\\\\d{2}-\\\\{4}+" + }, + "height": { + "type": "number" + }, + "dob": { + "format": "date-time", + "type": "string" + } + }, + "required": [ + "$class", + "employeeId", + "salary", + "numDependents", + "retired", + "department", + "officeAddress", + "companyAssets", + "email", + "firstName", + "lastName", + "homeAddress", + "ssn", + "height", + "dob" + ] + }, + "org.acme.hr.Contractor": { + "title": "Contractor", + "description": "An instance of org.acme.hr.Contractor", + "type": "object", + "properties": { + "$class": { + "type": "string", + "default": "org.acme.hr.Contractor", + "pattern": "^org\\\\.acme\\\\.hr\\\\.Contractor$", + "description": "The class identifier for org.acme.hr.Contractor" + }, + "company": { + "$ref": "#/definitions/org.acme.hr.Company" + }, + "manager": { + "type": "string", + "description": "The identifier of an instance of org.acme.hr.Manager" + }, + "email": { + "type": "string", + "description": "The instance identifier for this type" + }, + "firstName": { + "type": "string" + }, + "lastName": { + "type": "string" + }, + "middleNames": { + "type": "string" + }, + "homeAddress": { + "$ref": "#/definitions/org.acme.hr.Address" + }, + "ssn": { + "default": "000-00-0000", + "type": "string", + "pattern": "\\\\d{3}-\\\\d{2}-\\\\{4}+" + }, + "height": { + "type": "number" + }, + "dob": { + "format": "date-time", + "type": "string" + } + }, + "required": [ + "$class", + "company", + "email", + "firstName", + "lastName", + "homeAddress", + "ssn", + "height", + "dob" + ] + }, + "org.acme.hr.Manager": { + "title": "Manager", + "description": "An instance of org.acme.hr.Manager", + "type": "object", + "properties": { + "$class": { + "type": "string", + "default": "org.acme.hr.Manager", + "pattern": "^org\\\\.acme\\\\.hr\\\\.Manager$", + "description": "The class identifier for org.acme.hr.Manager" + }, + "reports": { + "type": "array", + "items": { + "type": "string", + "description": "The identifier of an instance of org.acme.hr.Person" + } + }, + "employeeId": { + "type": "string" + }, + "salary": { + "type": "integer" + }, + "numDependents": { + "type": "integer" + }, + "retired": { + "type": "boolean" + }, + "department": { + "$ref": "#/definitions/org.acme.hr.Department" + }, + "officeAddress": { + "$ref": "#/definitions/org.acme.hr.Address" + }, + "companyAssets": { + "type": "array", + "items": { + "anyOf": [ + { + "$ref": "#/definitions/org.acme.hr.Equipment" + }, + { + "$ref": "#/definitions/org.acme.hr.Laptop" + } + ] + } + }, + "manager": { + "type": "string", + "description": "The identifier of an instance of org.acme.hr.Manager" + }, + "email": { + "type": "string", + "description": "The instance identifier for this type" + }, + "firstName": { + "type": "string" + }, + "lastName": { + "type": "string" + }, + "middleNames": { + "type": "string" + }, + "homeAddress": { + "$ref": "#/definitions/org.acme.hr.Address" + }, + "ssn": { + "default": "000-00-0000", + "type": "string", + "pattern": "\\\\d{3}-\\\\d{2}-\\\\{4}+" + }, + "height": { + "type": "number" + }, + "dob": { + "format": "date-time", + "type": "string" + } + }, + "required": [ + "$class", + "employeeId", + "salary", + "numDependents", + "retired", + "department", + "officeAddress", + "companyAssets", + "email", + "firstName", + "lastName", + "homeAddress", + "ssn", + "height", + "dob" + ] + }, + "org.acme.hr.CompanyEvent": { + "title": "CompanyEvent", + "description": "An instance of org.acme.hr.CompanyEvent", + "type": "object", + "properties": { + "$class": { + "type": "string", + "default": "org.acme.hr.CompanyEvent", + "pattern": "^org\\\\.acme\\\\.hr\\\\.CompanyEvent$", + "description": "The class identifier for org.acme.hr.CompanyEvent" + } + }, + "required": [ + "$class" + ] + }, + "org.acme.hr.Onboarded": { + "title": "Onboarded", + "description": "An instance of org.acme.hr.Onboarded", + "type": "object", + "properties": { + "$class": { + "type": "string", + "default": "org.acme.hr.Onboarded", + "pattern": "^org\\\\.acme\\\\.hr\\\\.Onboarded$", + "description": "The class identifier for org.acme.hr.Onboarded" + }, + "employee": { + "type": "string", + "description": "The identifier of an instance of org.acme.hr.Employee" + } + }, + "required": [ + "$class", + "employee" + ] + }, + "org.acme.hr.ChangeOfAddress": { + "title": "ChangeOfAddress", + "description": "An instance of org.acme.hr.ChangeOfAddress", + "type": "object", + "properties": { + "$class": { + "type": "string", + "default": "org.acme.hr.ChangeOfAddress", + "pattern": "^org\\\\.acme\\\\.hr\\\\.ChangeOfAddress$", + "description": "The class identifier for org.acme.hr.ChangeOfAddress" + }, + "Person": { + "type": "string", + "description": "The identifier of an instance of org.acme.hr.Person" + }, + "newAddress": { + "$ref": "#/definitions/org.acme.hr.Address" + } + }, + "required": [ + "$class", + "Person", + "newAddress" + ] + } + } +} +", +} +`; + +exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'markdown' 1`] = ` +{ + "key": "models.md", + "value": "# Namespace org.acme.hr + +## Overview +- 2 concepts +- 3 enumerations +- 2 assets +- 4 participants +- 1 transactions +- 2 events +- 22 total declarations + +## Imports +- concerto@1.0.0.Concept +- concerto@1.0.0.Asset +- concerto@1.0.0.Transaction +- concerto@1.0.0.Participant +- concerto@1.0.0.Event + +## Diagram +\`\`\`mermaid +classDiagram +class \`org.acme.hr.State\` { +<< enumeration>> + + \`MA\` + + \`NY\` + + \`CO\` + + \`WA\` + + \`IL\` + + \`CA\` +} + +class \`org.acme.hr.Address\` { +<< concept>> + + \`String\` \`street\` + + \`String\` \`city\` + + \`State\` \`state\` + + \`String\` \`zipCode\` + + \`String\` \`country\` + + \`Map1\` \`dictionary1\` + + \`Map2\` \`dictionary2\` + + \`Map3\` \`dictionary3\` + + \`Map4\` \`dictionary4\` + + \`Map5\` \`dictionary5\` + + \`Map6\` \`dictionary6\` +} + +\`org.acme.hr.Address\` "1" *-- "1" \`org.acme.hr.State\` +\`org.acme.hr.Address\` "1" *-- "1" \`org.acme.hr.Map1\` +\`org.acme.hr.Address\` "1" *-- "1" \`org.acme.hr.Map2\` +\`org.acme.hr.Address\` "1" *-- "1" \`org.acme.hr.Map3\` +\`org.acme.hr.Address\` "1" *-- "1" \`org.acme.hr.Map4\` +\`org.acme.hr.Address\` "1" *-- "1" \`org.acme.hr.Map5\` +\`org.acme.hr.Address\` "1" *-- "1" \`org.acme.hr.Map6\` +class \`org.acme.hr.Company\` { +<< concept>> + + \`String\` \`name\` + + \`Address\` \`headquarters\` +} + +\`org.acme.hr.Company\` "1" *-- "1" \`org.acme.hr.Address\` +class \`org.acme.hr.Department\` { +<< enumeration>> + + \`Sales\` + + \`Marketing\` + + \`Finance\` + + \`HR\` + + \`Engineering\` + + \`Design\` +} + +class \`org.acme.hr.Equipment\` { +<< asset>> + + \`String\` \`serialNumber\` +} + +class \`org.acme.hr.LaptopMake\` { +<< enumeration>> + + \`Apple\` + + \`Microsoft\` +} + +class \`org.acme.hr.Laptop\` { +<< asset>> + + \`LaptopMake\` \`make\` +} + +\`org.acme.hr.Laptop\` "1" *-- "1" \`org.acme.hr.LaptopMake\` +\`org.acme.hr.Laptop\` --|> \`org.acme.hr.Equipment\` +class \`org.acme.hr.Person\` { +<< participant>> + + \`String\` \`email\` + + \`String\` \`firstName\` + + \`String\` \`lastName\` + + \`String\` \`middleNames\` + + \`Address\` \`homeAddress\` + + \`String\` \`ssn\` + + \`Double\` \`height\` + + \`DateTime\` \`dob\` +} + +\`org.acme.hr.Person\` "1" *-- "1" \`org.acme.hr.Address\` +\`org.acme.hr.Person\` "1" *-- "1" \`org.acme.hr.SSN\` +class \`org.acme.hr.Employee\` { +<< participant>> + + \`String\` \`employeeId\` + + \`Long\` \`salary\` + + \`Integer\` \`numDependents\` + + \`Boolean\` \`retired\` + + \`Department\` \`department\` + + \`Address\` \`officeAddress\` + + \`Equipment[]\` \`companyAssets\` + + \`Manager\` \`manager\` +} + +\`org.acme.hr.Employee\` "1" *-- "1" \`org.acme.hr.Department\` +\`org.acme.hr.Employee\` "1" *-- "1" \`org.acme.hr.Address\` +\`org.acme.hr.Employee\` "1" *-- "*" \`org.acme.hr.Equipment\` +\`org.acme.hr.Employee\` "1" o-- "1" \`org.acme.hr.Manager\` : manager +\`org.acme.hr.Employee\` --|> \`org.acme.hr.Person\` +class \`org.acme.hr.Contractor\` { +<< participant>> + + \`Company\` \`company\` + + \`Manager\` \`manager\` +} + +\`org.acme.hr.Contractor\` "1" *-- "1" \`org.acme.hr.Company\` +\`org.acme.hr.Contractor\` "1" o-- "1" \`org.acme.hr.Manager\` : manager +\`org.acme.hr.Contractor\` --|> \`org.acme.hr.Person\` +class \`org.acme.hr.Manager\` { +<< participant>> + + \`Person[]\` \`reports\` +} + +\`org.acme.hr.Manager\` "1" o-- "*" \`org.acme.hr.Person\` : reports +\`org.acme.hr.Manager\` --|> \`org.acme.hr.Employee\` +class \`org.acme.hr.CompanyEvent\` +<< event>> \`org.acme.hr.CompanyEvent\` + +class \`org.acme.hr.Onboarded\` { +<< event>> + + \`Employee\` \`employee\` +} + +\`org.acme.hr.Onboarded\` "1" o-- "1" \`org.acme.hr.Employee\` : employee +\`org.acme.hr.Onboarded\` --|> \`org.acme.hr.CompanyEvent\` +class \`org.acme.hr.ChangeOfAddress\` { +<< transaction>> + + \`Person\` \`Person\` + + \`Address\` \`newAddress\` +} + +\`org.acme.hr.ChangeOfAddress\` "1" o-- "1" \`org.acme.hr.Person\` : Person +\`org.acme.hr.ChangeOfAddress\` "1" *-- "1" \`org.acme.hr.Address\` +\`\`\` + +", +} +`; + +exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'mermaid' 1`] = ` +{ + "key": "model.mmd", + "value": "classDiagram +class \`org.acme.hr.State\` { +<< enumeration>> + + \`MA\` + + \`NY\` + + \`CO\` + + \`WA\` + + \`IL\` + + \`CA\` +} + +\`org.acme.hr.State\` --|> \`concerto@1.0.0.Concept\` +class \`org.acme.hr.Address\` { +<< concept>> + + \`String\` \`street\` + + \`String\` \`city\` + + \`State\` \`state\` + + \`String\` \`zipCode\` + + \`String\` \`country\` + + \`Map1\` \`dictionary1\` + + \`Map2\` \`dictionary2\` + + \`Map3\` \`dictionary3\` + + \`Map4\` \`dictionary4\` + + \`Map5\` \`dictionary5\` + + \`Map6\` \`dictionary6\` +} + +\`org.acme.hr.Address\` --|> \`concerto@1.0.0.Concept\` +class \`org.acme.hr.Company\` { +<< concept>> + + \`String\` \`name\` + + \`Address\` \`headquarters\` +} + +\`org.acme.hr.Company\` --|> \`concerto@1.0.0.Concept\` +class \`org.acme.hr.Department\` { +<< enumeration>> + + \`Sales\` + + \`Marketing\` + + \`Finance\` + + \`HR\` + + \`Engineering\` + + \`Design\` +} + +\`org.acme.hr.Department\` --|> \`concerto@1.0.0.Concept\` +class \`org.acme.hr.Equipment\` { +<< asset>> + + \`String\` \`serialNumber\` +} + +\`org.acme.hr.Equipment\` --|> \`concerto@1.0.0.Asset\` +class \`org.acme.hr.LaptopMake\` { +<< enumeration>> + + \`Apple\` + + \`Microsoft\` +} + +\`org.acme.hr.LaptopMake\` --|> \`concerto@1.0.0.Concept\` +class \`org.acme.hr.Laptop\` { +<< asset>> + + \`LaptopMake\` \`make\` +} + +\`org.acme.hr.Laptop\` --|> \`org.acme.hr.Equipment\` +class \`org.acme.hr.Person\` { +<< participant>> + + \`String\` \`email\` + + \`String\` \`firstName\` + + \`String\` \`lastName\` + + \`String\` \`middleNames\` + + \`Address\` \`homeAddress\` + + \`String\` \`ssn\` + + \`Double\` \`height\` + + \`DateTime\` \`dob\` +} + +\`org.acme.hr.Person\` --|> \`concerto@1.0.0.Participant\` +class \`org.acme.hr.Employee\` { +<< participant>> + + \`String\` \`employeeId\` + + \`Long\` \`salary\` + + \`Integer\` \`numDependents\` + + \`Boolean\` \`retired\` + + \`Department\` \`department\` + + \`Address\` \`officeAddress\` + + \`Equipment[]\` \`companyAssets\` + + \`Manager\` \`manager\` +} + +\`org.acme.hr.Employee\` "1" o-- "1" \`org.acme.hr.Manager\` : manager +\`org.acme.hr.Employee\` --|> \`org.acme.hr.Person\` +class \`org.acme.hr.Contractor\` { +<< participant>> + + \`Company\` \`company\` + + \`Manager\` \`manager\` +} + +\`org.acme.hr.Contractor\` "1" o-- "1" \`org.acme.hr.Manager\` : manager +\`org.acme.hr.Contractor\` --|> \`org.acme.hr.Person\` +class \`org.acme.hr.Manager\` { +<< participant>> + + \`Person[]\` \`reports\` +} + +\`org.acme.hr.Manager\` "1" o-- "*" \`org.acme.hr.Person\` : reports +\`org.acme.hr.Manager\` --|> \`org.acme.hr.Employee\` +class \`org.acme.hr.CompanyEvent\` +<< event>> \`org.acme.hr.CompanyEvent\` + +\`org.acme.hr.CompanyEvent\` --|> \`concerto@1.0.0.Event\` +class \`org.acme.hr.Onboarded\` { +<< event>> + + \`Employee\` \`employee\` +} + +\`org.acme.hr.Onboarded\` "1" o-- "1" \`org.acme.hr.Employee\` : employee +\`org.acme.hr.Onboarded\` --|> \`org.acme.hr.CompanyEvent\` +class \`org.acme.hr.ChangeOfAddress\` { +<< transaction>> + + \`Person\` \`Person\` + + \`Address\` \`newAddress\` +} + +\`org.acme.hr.ChangeOfAddress\` "1" o-- "1" \`org.acme.hr.Person\` : Person +\`org.acme.hr.ChangeOfAddress\` --|> \`concerto@1.0.0.Transaction\` +", +} +`; + +exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'odata' 1`] = ` +{ + "key": "concerto.csdl", + "value": " + + + + + + + + + + + + + + + + + + + + + + + + + +", +} +`; + +exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'odata' 2`] = ` +{ + "key": "org.acme.hr.csdl", + "value": " + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +", +} +`; + +exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'openapi' 1`] = ` +{ + "key": "openapi.json", + "value": "{ + "openapi": "3.0.2", + "servers": [], + "info": { + "title": "Generated Open API from Concerto Models", + "version": "1.0.0", + "description": "Create, read, update and delete entities" + }, + "components": { + "schemas": { + "org.acme.hr.State": { + "title": "State", + "description": "An instance of org.acme.hr.State", + "enum": [ + "MA", + "NY", + "CO", + "WA", + "IL", + "CA" + ] + }, + "org.acme.hr.Address": { + "title": "Address", + "description": "An instance of org.acme.hr.Address", + "type": "object", + "properties": { + "$class": { + "type": "string", + "default": "org.acme.hr.Address", + "pattern": "^org\\\\.acme\\\\.hr\\\\.Address$", + "description": "The class identifier for org.acme.hr.Address" + }, + "street": { + "type": "string" + }, + "city": { + "type": "string" + }, + "state": { + "$ref": "#/components/schemas/org.acme.hr.State" + }, + "zipCode": { + "type": "string" + }, + "country": { + "type": "string" + } + }, + "required": [ + "$class", + "street", + "city", + "zipCode", + "country", + "dictionary1", + "dictionary2", + "dictionary3", + "dictionary4", + "dictionary5", + "dictionary6" + ] + }, + "org.acme.hr.Time": { + "format": "date-time", + "type": "string" + }, + "org.acme.hr.Company": { + "title": "Company", + "description": "An instance of org.acme.hr.Company", + "type": "object", + "properties": { + "$class": { + "type": "string", + "default": "org.acme.hr.Company", + "pattern": "^org\\\\.acme\\\\.hr\\\\.Company$", + "description": "The class identifier for org.acme.hr.Company" + }, + "name": { + "type": "string" + }, + "headquarters": { + "$ref": "#/components/schemas/org.acme.hr.Address" + } + }, + "required": [ + "$class", + "name", + "headquarters" + ] + }, + "org.acme.hr.Department": { + "title": "Department", + "description": "An instance of org.acme.hr.Department", + "enum": [ + "Sales", + "Marketing", + "Finance", + "HR", + "Engineering", + "Design" + ] + }, + "org.acme.hr.Equipment": { + "title": "Equipment", + "description": "An instance of org.acme.hr.Equipment", + "type": "object", + "properties": { + "$class": { + "type": "string", + "default": "org.acme.hr.Equipment", + "pattern": "^org\\\\.acme\\\\.hr\\\\.Equipment$", + "description": "The class identifier for org.acme.hr.Equipment" + }, + "serialNumber": { + "type": "string", + "description": "The instance identifier for this type" + } + }, + "required": [ + "$class", + "serialNumber" + ], + "$decorators": { + "resource": [] + } + }, + "org.acme.hr.LaptopMake": { + "title": "LaptopMake", + "description": "An instance of org.acme.hr.LaptopMake", + "enum": [ + "Apple", + "Microsoft" + ] + }, + "org.acme.hr.Laptop": { + "title": "Laptop", + "description": "An instance of org.acme.hr.Laptop", + "type": "object", + "properties": { + "$class": { + "type": "string", + "default": "org.acme.hr.Laptop", + "pattern": "^org\\\\.acme\\\\.hr\\\\.Laptop$", + "description": "The class identifier for org.acme.hr.Laptop" + }, + "make": { + "$ref": "#/components/schemas/org.acme.hr.LaptopMake" + }, + "serialNumber": { + "type": "string", + "description": "The instance identifier for this type" + } + }, + "required": [ + "$class", + "make", + "serialNumber" + ] + }, + "org.acme.hr.SSN": { + "type": "string", + "pattern": "\\\\d{3}-\\\\d{2}-\\\\{4}+" + }, + "org.acme.hr.Person": { + "title": "Person", + "description": "An instance of org.acme.hr.Person", + "type": "object", + "properties": { + "$class": { + "type": "string", + "default": "org.acme.hr.Person", + "pattern": "^org\\\\.acme\\\\.hr\\\\.Person$", + "description": "The class identifier for org.acme.hr.Person" + }, + "email": { + "type": "string", + "description": "The instance identifier for this type" + }, + "firstName": { + "type": "string" + }, + "lastName": { + "type": "string" + }, + "middleNames": { + "type": "string" + }, + "homeAddress": { + "$ref": "#/components/schemas/org.acme.hr.Address" + }, + "ssn": { + "default": "000-00-0000", + "type": "string", + "pattern": "\\\\d{3}-\\\\d{2}-\\\\{4}+" + }, + "height": { + "type": "number" + }, + "dob": { + "format": "date-time", + "type": "string" + } + }, + "required": [ + "$class", + "email", + "firstName", + "lastName", + "homeAddress", + "ssn", + "height", + "dob" + ], + "$decorators": { + "resource": [] + } + }, + "org.acme.hr.Employee": { + "title": "Employee", + "description": "An instance of org.acme.hr.Employee", + "type": "object", + "properties": { + "$class": { + "type": "string", + "default": "org.acme.hr.Employee", + "pattern": "^org\\\\.acme\\\\.hr\\\\.Employee$", + "description": "The class identifier for org.acme.hr.Employee" + }, + "employeeId": { + "type": "string" + }, + "salary": { + "type": "integer" + }, + "numDependents": { + "type": "integer" + }, + "retired": { + "type": "boolean" + }, + "department": { + "$ref": "#/components/schemas/org.acme.hr.Department" + }, + "officeAddress": { + "$ref": "#/components/schemas/org.acme.hr.Address" + }, + "companyAssets": { + "type": "array", + "items": { + "anyOf": [ + { + "$ref": "#/components/schemas/org.acme.hr.Equipment" + }, + { + "$ref": "#/components/schemas/org.acme.hr.Laptop" + } + ] + } + }, + "manager": { + "type": "string", + "description": "The identifier of an instance of org.acme.hr.Manager" + }, + "email": { + "type": "string", + "description": "The instance identifier for this type" + }, + "firstName": { + "type": "string" + }, + "lastName": { + "type": "string" + }, + "middleNames": { + "type": "string" + }, + "homeAddress": { + "$ref": "#/components/schemas/org.acme.hr.Address" + }, + "ssn": { + "default": "000-00-0000", + "type": "string", + "pattern": "\\\\d{3}-\\\\d{2}-\\\\{4}+" + }, + "height": { + "type": "number" + }, + "dob": { + "format": "date-time", + "type": "string" + } + }, + "required": [ + "$class", + "employeeId", + "salary", + "numDependents", + "retired", + "department", + "officeAddress", + "companyAssets", + "email", + "firstName", + "lastName", + "homeAddress", + "ssn", + "height", + "dob" + ] + }, + "org.acme.hr.Contractor": { + "title": "Contractor", + "description": "An instance of org.acme.hr.Contractor", + "type": "object", + "properties": { + "$class": { + "type": "string", + "default": "org.acme.hr.Contractor", + "pattern": "^org\\\\.acme\\\\.hr\\\\.Contractor$", + "description": "The class identifier for org.acme.hr.Contractor" + }, + "company": { + "$ref": "#/components/schemas/org.acme.hr.Company" + }, + "manager": { + "type": "string", + "description": "The identifier of an instance of org.acme.hr.Manager" + }, + "email": { + "type": "string", + "description": "The instance identifier for this type" + }, + "firstName": { + "type": "string" + }, + "lastName": { + "type": "string" + }, + "middleNames": { + "type": "string" + }, + "homeAddress": { + "$ref": "#/components/schemas/org.acme.hr.Address" + }, + "ssn": { + "default": "000-00-0000", + "type": "string", + "pattern": "\\\\d{3}-\\\\d{2}-\\\\{4}+" + }, + "height": { + "type": "number" + }, + "dob": { + "format": "date-time", + "type": "string" + } + }, + "required": [ + "$class", + "company", + "email", + "firstName", + "lastName", + "homeAddress", + "ssn", + "height", + "dob" + ] + }, + "org.acme.hr.Manager": { + "title": "Manager", + "description": "An instance of org.acme.hr.Manager", + "type": "object", + "properties": { + "$class": { + "type": "string", + "default": "org.acme.hr.Manager", + "pattern": "^org\\\\.acme\\\\.hr\\\\.Manager$", + "description": "The class identifier for org.acme.hr.Manager" + }, + "reports": { + "type": "array", + "items": { + "type": "string", + "description": "The identifier of an instance of org.acme.hr.Person" + } + }, + "employeeId": { + "type": "string" + }, + "salary": { + "type": "integer" + }, + "numDependents": { + "type": "integer" + }, + "retired": { + "type": "boolean" + }, + "department": { + "$ref": "#/components/schemas/org.acme.hr.Department" + }, + "officeAddress": { + "$ref": "#/components/schemas/org.acme.hr.Address" + }, + "companyAssets": { + "type": "array", + "items": { + "anyOf": [ + { + "$ref": "#/components/schemas/org.acme.hr.Equipment" + }, + { + "$ref": "#/components/schemas/org.acme.hr.Laptop" + } + ] + } + }, + "manager": { + "type": "string", + "description": "The identifier of an instance of org.acme.hr.Manager" + }, + "email": { + "type": "string", + "description": "The instance identifier for this type" + }, + "firstName": { + "type": "string" + }, + "lastName": { + "type": "string" + }, + "middleNames": { + "type": "string" + }, + "homeAddress": { + "$ref": "#/components/schemas/org.acme.hr.Address" + }, + "ssn": { + "default": "000-00-0000", + "type": "string", + "pattern": "\\\\d{3}-\\\\d{2}-\\\\{4}+" + }, + "height": { + "type": "number" + }, + "dob": { + "format": "date-time", + "type": "string" + } + }, + "required": [ + "$class", + "employeeId", + "salary", + "numDependents", + "retired", + "department", + "officeAddress", + "companyAssets", + "email", + "firstName", + "lastName", + "homeAddress", + "ssn", + "height", + "dob" + ] + }, + "org.acme.hr.CompanyEvent": { + "title": "CompanyEvent", + "description": "An instance of org.acme.hr.CompanyEvent", + "type": "object", + "properties": { + "$class": { + "type": "string", + "default": "org.acme.hr.CompanyEvent", + "pattern": "^org\\\\.acme\\\\.hr\\\\.CompanyEvent$", + "description": "The class identifier for org.acme.hr.CompanyEvent" + } + }, + "required": [ + "$class" + ] + }, + "org.acme.hr.Onboarded": { + "title": "Onboarded", + "description": "An instance of org.acme.hr.Onboarded", + "type": "object", + "properties": { + "$class": { + "type": "string", + "default": "org.acme.hr.Onboarded", + "pattern": "^org\\\\.acme\\\\.hr\\\\.Onboarded$", + "description": "The class identifier for org.acme.hr.Onboarded" + }, + "employee": { + "type": "string", + "description": "The identifier of an instance of org.acme.hr.Employee" + } + }, + "required": [ + "$class", + "employee" + ] + }, + "org.acme.hr.ChangeOfAddress": { + "title": "ChangeOfAddress", + "description": "An instance of org.acme.hr.ChangeOfAddress", + "type": "object", + "properties": { + "$class": { + "type": "string", + "default": "org.acme.hr.ChangeOfAddress", + "pattern": "^org\\\\.acme\\\\.hr\\\\.ChangeOfAddress$", + "description": "The class identifier for org.acme.hr.ChangeOfAddress" + }, + "Person": { + "type": "string", + "description": "The identifier of an instance of org.acme.hr.Person" + }, + "newAddress": { + "$ref": "#/components/schemas/org.acme.hr.Address" + } + }, + "required": [ + "$class", + "Person", + "newAddress" + ] + } + } + }, + "paths": { + "/equipment": { + "summary": "Path used to manage the list of equipment.", + "description": "The REST endpoint/path used to list and create zero or more \`equipment\` entities. This path contains a \`GET\` and \`POST\` operation to perform the list and create tasks, respectively.", + "get": { + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/org.acme.hr.Equipment" + } + } + } + }, + "description": "Successful response - returns an array of \`equipment\` entities." + } + }, + "operationId": "listEquipment", + "summary": "List All Equipment", + "description": "Gets a list of all \`equipment\` entities.", + "tags": [ + "equipment" + ] + }, + "post": { + "requestBody": { + "description": "A new \`equipment\` to be created.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/org.acme.hr.Equipment" + } + } + }, + "required": true + }, + "responses": { + "201": { + "description": "Successful response." + } + }, + "operationId": "createEquipment", + "summary": "Create a Equipment", + "description": "Creates a new instance of a \`equipment\`.", + "tags": [ + "equipment" + ] + } + }, + "/equipment/{serialNumber}": { + "summary": "Path used to manage a single equipment.", + "description": "The REST endpoint/path used to get, update, and delete single instances of a \`equipment\`. This path contains \`GET\`, \`PUT\`, and \`DELETE\` operations used to perform the get, update, and delete tasks, respectively.", + "get": { + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/org.acme.hr.Equipment" + } + } + }, + "description": "Successful response - returns a single \`equipment\`." + } + }, + "operationId": "getEquipment", + "summary": "Get a equipment", + "description": "Gets the details of a single instance of a \`equipment\`.", + "tags": [ + "equipment" + ] + }, + "put": { + "requestBody": { + "description": "Updated \`equipment\` information.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/org.acme.hr.Equipment" + } + } + }, + "required": true + }, + "responses": { + "202": { + "description": "Successful response." + } + }, + "operationId": "replaceEquipment", + "summary": "Update a equipment", + "description": "Updates an existing \`equipment\`.", + "tags": [ + "equipment" + ] + }, + "delete": { + "responses": { + "204": { + "description": "Successful response." + } + }, + "operationId": "deleteEquipment", + "summary": "Delete a equipment", + "description": "Deletes an existing \`equipment\`.", + "tags": [ + "equipment" + ] + }, + "parameters": [ + { + "name": "serialNumber", + "description": "A unique identifier for a \`Equipment\`.", + "schema": { + "type": "string" + }, + "in": "path", + "required": true + } + ] + }, + "/people": { + "summary": "Path used to manage the list of people.", + "description": "The REST endpoint/path used to list and create zero or more \`person\` entities. This path contains a \`GET\` and \`POST\` operation to perform the list and create tasks, respectively.", + "get": { + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/org.acme.hr.Person" + } + } + } + }, + "description": "Successful response - returns an array of \`person\` entities." + } + }, + "operationId": "listPeople", + "summary": "List All People", + "description": "Gets a list of all \`person\` entities.", + "tags": [ + "people" + ] + }, + "post": { + "requestBody": { + "description": "A new \`person\` to be created.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/org.acme.hr.Person" + } + } + }, + "required": true + }, + "responses": { + "201": { + "description": "Successful response." + } + }, + "operationId": "createPerson", + "summary": "Create a Person", + "description": "Creates a new instance of a \`person\`.", + "tags": [ + "people" + ] + } + }, + "/people/{email}": { + "summary": "Path used to manage a single person.", + "description": "The REST endpoint/path used to get, update, and delete single instances of a \`person\`. This path contains \`GET\`, \`PUT\`, and \`DELETE\` operations used to perform the get, update, and delete tasks, respectively.", + "get": { + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/org.acme.hr.Person" + } + } + }, + "description": "Successful response - returns a single \`person\`." + } + }, + "operationId": "getPerson", + "summary": "Get a person", + "description": "Gets the details of a single instance of a \`person\`.", + "tags": [ + "people" + ] + }, + "put": { + "requestBody": { + "description": "Updated \`person\` information.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/org.acme.hr.Person" + } + } + }, + "required": true + }, + "responses": { + "202": { + "description": "Successful response." + } + }, + "operationId": "replacePerson", + "summary": "Update a person", + "description": "Updates an existing \`person\`.", + "tags": [ + "people" + ] + }, + "delete": { + "responses": { + "204": { + "description": "Successful response." + } + }, + "operationId": "deletePerson", + "summary": "Delete a person", + "description": "Deletes an existing \`person\`.", + "tags": [ + "people" + ] + }, + "parameters": [ + { + "name": "email", + "description": "A unique identifier for a \`Person\`.", + "schema": { + "type": "string" + }, + "in": "path", + "required": true + } + ] + } + } +} +", +} +`; + +exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'plantuml' 1`] = ` +{ + "key": "model.puml", + "value": "@startuml +title +Model +endtitle +class org.acme.hr.State << (E,grey) >> { + + MA + + NY + + CO + + WA + + IL + + CA +} +org.acme.hr.State --|> concerto_1_0_0.Concept +class org.acme.hr.Address { + + String street + + String city + + State state + + String zipCode + + String country + + Map1 dictionary1 + + Map2 dictionary2 + + Map3 dictionary3 + + Map4 dictionary4 + + Map5 dictionary5 + + Map6 dictionary6 +} +org.acme.hr.Address --|> concerto_1_0_0.Concept +class org.acme.hr.Company { + + String name + + Address headquarters +} +org.acme.hr.Company --|> concerto_1_0_0.Concept +class org.acme.hr.Department << (E,grey) >> { + + Sales + + Marketing + + Finance + + HR + + Engineering + + Design +} +org.acme.hr.Department --|> concerto_1_0_0.Concept +class org.acme.hr.Equipment << (A,green) >> { + + String serialNumber +} +org.acme.hr.Equipment --|> concerto_1_0_0.Asset +class org.acme.hr.LaptopMake << (E,grey) >> { + + Apple + + Microsoft +} +org.acme.hr.LaptopMake --|> concerto_1_0_0.Concept +class org.acme.hr.Laptop << (A,green) >> { + + LaptopMake make +} +org.acme.hr.Laptop --|> org.acme.hr.Equipment +class org.acme.hr.Person << (P,lightblue) >> { + + String email + + String firstName + + String lastName + + String middleNames + + Address homeAddress + + String ssn + + Double height + + DateTime dob +} +org.acme.hr.Person --|> concerto_1_0_0.Participant +class org.acme.hr.Employee << (P,lightblue) >> { + + String employeeId + + Long salary + + Integer numDependents + + Boolean retired + + Department department + + Address officeAddress + + Equipment[] companyAssets + + Manager manager +} +org.acme.hr.Employee "1" o-- "1" org.acme.hr.Manager : manager +org.acme.hr.Employee --|> org.acme.hr.Person +class org.acme.hr.Contractor << (P,lightblue) >> { + + Company company + + Manager manager +} +org.acme.hr.Contractor "1" o-- "1" org.acme.hr.Manager : manager +org.acme.hr.Contractor --|> org.acme.hr.Person +class org.acme.hr.Manager << (P,lightblue) >> { + + Person[] reports +} +org.acme.hr.Manager "1" o-- "*" org.acme.hr.Person : reports +org.acme.hr.Manager --|> org.acme.hr.Employee +class org.acme.hr.CompanyEvent { +} +org.acme.hr.CompanyEvent --|> concerto_1_0_0.Event +class org.acme.hr.Onboarded { + + Employee employee +} +org.acme.hr.Onboarded "1" o-- "1" org.acme.hr.Employee : employee +org.acme.hr.Onboarded --|> org.acme.hr.CompanyEvent +class org.acme.hr.ChangeOfAddress << (T,yellow) >> { + + Person Person + + Address newAddress +} +org.acme.hr.ChangeOfAddress "1" o-- "1" org.acme.hr.Person : Person +org.acme.hr.ChangeOfAddress --|> concerto_1_0_0.Transaction +@enduml +", +} +`; + +exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'protobuf' 1`] = ` +{ + "key": "org.acme.hr.v.proto", + "value": "syntax = "proto3"; + +package org.acme.hr.v; + +import "google/protobuf/timestamp.proto"; + +enum State { + State_CA = 0; + State_CO = 1; + State_IL = 2; + State_MA = 3; + State_NY = 4; + State_WA = 5; +} + +message Address { + string city = 1; + string country = 2; + Map1 dictionary1 = 3; + Map2 dictionary2 = 4; + Map3 dictionary3 = 5; + Map4 dictionary4 = 6; + Map5 dictionary5 = 7; + Map6 dictionary6 = 8; + optional State state = 9; + string street = 10; + string zipCode = 11; +} + +message Company { + Address headquarters = 1; + string name = 2; +} + +enum Department { + Department_Design = 0; + Department_Engineering = 1; + Department_Finance = 2; + Department_HR = 3; + Department_Marketing = 4; + Department_Sales = 5; +} + +message _Subclasses_of_class_Equipment { + oneof _class_oneof_Equipment { + Laptop _subclass_of_class_Equipment_Laptop = 1; + } +} + +enum LaptopMake { + LaptopMake_Apple = 0; + LaptopMake_Microsoft = 1; +} + +message Laptop { + LaptopMake make = 1; + string serialNumber = 2; +} + +message _Subclasses_of_class_Person { + oneof _class_oneof_Person { + Contractor _subclass_of_class_Person_Contractor = 1; + Employee _subclass_of_class_Person_Employee = 2; + Manager _subclass_of_class_Person_Manager = 3; + } +} + +message Employee { + repeated _Subclasses_of_class_Equipment companyAssets = 1; + Department department = 2; + google.protobuf.Timestamp dob = 3; + string email = 4; + string employeeId = 5; + string firstName = 6; + double height = 7; + Address homeAddress = 8; + string lastName = 9; + optional string manager = 10; + optional string middleNames = 11; + sint64 numDependents = 12; + Address officeAddress = 13; + bool retired = 14; + sint64 salary = 15; + string ssn = 16; +} + +message _Subclasses_of_class_Employee { + oneof _class_oneof_Employee { + Employee _subclass_of_class_Employee_Employee = 1; + Manager _subclass_of_class_Employee_Manager = 2; + } +} + +message Contractor { + Company company = 1; + google.protobuf.Timestamp dob = 2; + string email = 3; + string firstName = 4; + double height = 5; + Address homeAddress = 6; + string lastName = 7; + optional string manager = 8; + optional string middleNames = 9; + string ssn = 10; +} + +message Manager { + repeated _Subclasses_of_class_Equipment companyAssets = 1; + Department department = 2; + google.protobuf.Timestamp dob = 3; + string email = 4; + string employeeId = 5; + string firstName = 6; + double height = 7; + Address homeAddress = 8; + string lastName = 9; + optional string manager = 10; + optional string middleNames = 11; + sint64 numDependents = 12; + Address officeAddress = 13; + repeated string reports = 14; + bool retired = 15; + sint64 salary = 16; + string ssn = 17; +} + +message CompanyEvent { +} + +message _Subclasses_of_class_CompanyEvent { + oneof _class_oneof_CompanyEvent { + CompanyEvent _subclass_of_class_CompanyEvent_CompanyEvent = 1; + Onboarded _subclass_of_class_CompanyEvent_Onboarded = 2; + } +} + +message Onboarded { + string employee = 1; +} + +message ChangeOfAddress { + Address newAddress = 1; + string Person = 2; +} + +", +} +`; + +exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'rust' 1`] = ` +{ + "key": "mod.rs", + "value": "#[allow(unused_imports)] +pub mod concerto_1_0_0; +#[allow(unused_imports)] +pub mod concerto; +#[allow(unused_imports)] +pub mod org_acme_hr; +#[allow(unused_imports)] +pub mod utils; +", +} +`; + +exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'rust' 2`] = ` +{ + "key": "utils.rs", + "value": "use chrono::{ DateTime, TimeZone, Utc }; +use serde::{ Deserialize, Serialize, Deserializer, Serializer }; + +pub fn serialize_datetime_option(datetime: &Option>, serializer: S) -> Result +where + S: Serializer, +{ + match datetime { + Some(dt) => { + serialize_datetime(&dt, serializer) + }, + _ => unreachable!(), + } +} + +pub fn deserialize_datetime_option<'de, D>(deserializer: D) -> Result>, D::Error> +where + D: Deserializer<'de>, +{ + match deserialize_datetime(deserializer) { + Ok(result)=>Ok(Some(result)), + Err(error) => Err(error), + } +} + +pub fn deserialize_datetime<'de, D>(deserializer: D) -> Result, D::Error> +where + D: Deserializer<'de>, +{ + let datetime_str = String::deserialize(deserializer)?; + Utc.datetime_from_str(&datetime_str, "%Y-%m-%dT%H:%M:%S%.3f%Z").map_err(serde::de::Error::custom) +} + +pub fn serialize_datetime(datetime: &chrono::DateTime, serializer: S) -> Result +where + S: Serializer, +{ + let datetime_str = datetime.format("%+").to_string(); + serializer.serialize_str(&datetime_str) +} +", +} +`; + +exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'rust' 3`] = ` +{ + "key": "concerto_1_0_0.rs", + "value": "use serde::{ Deserialize, Serialize }; +use chrono::{ DateTime, TimeZone, Utc }; + +use crate::utils::*; + +#[derive(Debug, Serialize, Deserialize)] +pub struct Concept { + #[serde( + rename = "$class", + )] + pub _class: String, +} + +#[derive(Debug, Serialize, Deserialize)] +pub struct Asset { + #[serde( + rename = "$class", + )] + pub _class: String, + + #[serde( + rename = "$identifier", + )] + pub _identifier: String, +} + +#[derive(Debug, Serialize, Deserialize)] +pub struct Participant { + #[serde( + rename = "$class", + )] + pub _class: String, + + #[serde( + rename = "$identifier", + )] + pub _identifier: String, +} + +#[derive(Debug, Serialize, Deserialize)] +pub struct Transaction { + #[serde( + rename = "$class", + )] + pub _class: String, + + #[serde( + rename = "$timestamp", + serialize_with = "serialize_datetime", + deserialize_with = "deserialize_datetime", + )] + pub _timestamp: DateTime, +} + +#[derive(Debug, Serialize, Deserialize)] +pub struct Event { + #[serde( + rename = "$class", + )] + pub _class: String, + + #[serde( + rename = "$timestamp", + serialize_with = "serialize_datetime", + deserialize_with = "deserialize_datetime", + )] + pub _timestamp: DateTime, +} + +", +} +`; + +exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'rust' 4`] = ` +{ + "key": "concerto.rs", + "value": "use serde::{ Deserialize, Serialize }; +use chrono::{ DateTime, TimeZone, Utc }; + +use crate::utils::*; + +#[derive(Debug, Serialize, Deserialize)] +pub struct Concept { + #[serde( + rename = "$class", + )] + pub _class: String, +} + +#[derive(Debug, Serialize, Deserialize)] +pub struct Asset { + #[serde( + rename = "$class", + )] + pub _class: String, + + #[serde( + rename = "$identifier", + )] + pub _identifier: String, +} + +#[derive(Debug, Serialize, Deserialize)] +pub struct Participant { + #[serde( + rename = "$class", + )] + pub _class: String, + + #[serde( + rename = "$identifier", + )] + pub _identifier: String, +} + +#[derive(Debug, Serialize, Deserialize)] +pub struct Transaction { + #[serde( + rename = "$class", + )] + pub _class: String, +} + +#[derive(Debug, Serialize, Deserialize)] +pub struct Event { + #[serde( + rename = "$class", + )] + pub _class: String, +} + +", +} +`; + +exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'rust' 5`] = ` +{ + "key": "org_acme_hr.rs", + "value": "use serde::{ Deserialize, Serialize }; +use chrono::{ DateTime, TimeZone, Utc }; + +use crate::concerto_1_0_0::*; +use crate::utils::*; + +#[derive(Debug, Serialize, Deserialize)] +pub enum State { + #[allow(non_camel_case_types)] + MA, + #[allow(non_camel_case_types)] + NY, + #[allow(non_camel_case_types)] + CO, + #[allow(non_camel_case_types)] + WA, + #[allow(non_camel_case_types)] + IL, + #[allow(non_camel_case_types)] + CA, +} + +#[derive(Debug, Serialize, Deserialize)] +pub struct Address { + #[serde( + rename = "$class", + )] + pub _class: String, + + #[serde( + rename = "street", + )] + pub street: String, + + #[serde( + rename = "city", + )] + pub city: String, + + #[serde( + rename = "state", + skip_serializing_if = "Option::is_none", + )] + pub state: Option, + + #[serde( + rename = "zipCode", + )] + pub zip_code: String, + + #[serde( + rename = "country", + )] + pub country: String, + + #[serde( + rename = "dictionary1", + )] + pub dictionary1: Map1, + + #[serde( + rename = "dictionary2", + )] + pub dictionary2: Map2, + + #[serde( + rename = "dictionary3", + )] + pub dictionary3: Map3, + + #[serde( + rename = "dictionary4", + )] + pub dictionary4: Map4, + + #[serde( + rename = "dictionary5", + )] + pub dictionary5: Map5, + + #[serde( + rename = "dictionary6", + )] + pub dictionary6: Map6, +} + +#[derive(Debug, Serialize, Deserialize)] +pub struct Company { + #[serde( + rename = "$class", + )] + pub _class: String, + + #[serde( + rename = "name", + )] + pub name: String, + + #[serde( + rename = "headquarters", + )] + pub headquarters: Address, +} + +#[derive(Debug, Serialize, Deserialize)] +pub enum Department { + #[allow(non_camel_case_types)] + Sales, + #[allow(non_camel_case_types)] + Marketing, + #[allow(non_camel_case_types)] + Finance, + #[allow(non_camel_case_types)] + HR, + #[allow(non_camel_case_types)] + Engineering, + #[allow(non_camel_case_types)] + Design, +} + +#[derive(Debug, Serialize, Deserialize)] +pub struct Equipment { + #[serde( + rename = "$class", + )] + pub _class: String, + + #[serde( + rename = "serialNumber", + )] + pub serial_number: String, + + #[serde( + rename = "$identifier", + )] + pub _identifier: String, +} + +#[derive(Debug, Serialize, Deserialize)] +pub enum LaptopMake { + #[allow(non_camel_case_types)] + Apple, + #[allow(non_camel_case_types)] + Microsoft, +} + +#[derive(Debug, Serialize, Deserialize)] +pub struct Laptop { + #[serde( + rename = "$class", + )] + pub _class: String, + + #[serde( + rename = "make", + )] + pub make: LaptopMake, + + #[serde( + rename = "serialNumber", + )] + pub serial_number: String, + + #[serde( + rename = "$identifier", + )] + pub _identifier: String, +} + +#[derive(Debug, Serialize, Deserialize)] +pub struct Person { + #[serde( + rename = "$class", + )] + pub _class: String, + + #[serde( + rename = "email", + )] + pub email: String, + + #[serde( + rename = "firstName", + )] + pub first_name: String, + + #[serde( + rename = "lastName", + )] + pub last_name: String, + + #[serde( + rename = "middleNames", + skip_serializing_if = "Option::is_none", + )] + pub middle_names: Option, + + #[serde( + rename = "homeAddress", + )] + pub home_address: Address, + + #[serde( + rename = "ssn", + )] + pub ssn: String, + + #[serde( + rename = "height", + )] + pub height: f64, + + #[serde( + rename = "dob", + serialize_with = "serialize_datetime", + deserialize_with = "deserialize_datetime", + )] + pub dob: DateTime, + + #[serde( + rename = "$identifier", + )] + pub _identifier: String, +} + +#[derive(Debug, Serialize, Deserialize)] +pub struct Employee { + #[serde( + rename = "$class", + )] + pub _class: String, + + #[serde( + rename = "employeeId", + )] + pub employee_id: String, + + #[serde( + rename = "salary", + )] + pub salary: u64, + + #[serde( + rename = "numDependents", + )] + pub num_dependents: Integer, + + #[serde( + rename = "retired", + )] + pub retired: bool, + + #[serde( + rename = "department", + )] + pub department: Department, + + #[serde( + rename = "officeAddress", + )] + pub office_address: Address, + + #[serde( + rename = "companyAssets", + )] + pub company_assets: Vec, + + #[serde(rename = "manager")] + pub manager: Option, + + #[serde( + rename = "email", + )] + pub email: String, + + #[serde( + rename = "firstName", + )] + pub first_name: String, + + #[serde( + rename = "lastName", + )] + pub last_name: String, + + #[serde( + rename = "middleNames", + skip_serializing_if = "Option::is_none", + )] + pub middle_names: Option, + + #[serde( + rename = "homeAddress", + )] + pub home_address: Address, + + #[serde( + rename = "ssn", + )] + pub ssn: String, + + #[serde( + rename = "height", + )] + pub height: f64, + + #[serde( + rename = "dob", + serialize_with = "serialize_datetime", + deserialize_with = "deserialize_datetime", + )] + pub dob: DateTime, + + #[serde( + rename = "$identifier", + )] + pub _identifier: String, +} + +#[derive(Debug, Serialize, Deserialize)] +pub struct Contractor { + #[serde( + rename = "$class", + )] + pub _class: String, + + #[serde( + rename = "company", + )] + pub company: Company, + + #[serde(rename = "manager")] + pub manager: Option, + + #[serde( + rename = "email", + )] + pub email: String, + + #[serde( + rename = "firstName", + )] + pub first_name: String, + + #[serde( + rename = "lastName", + )] + pub last_name: String, + + #[serde( + rename = "middleNames", + skip_serializing_if = "Option::is_none", + )] + pub middle_names: Option, + + #[serde( + rename = "homeAddress", + )] + pub home_address: Address, + + #[serde( + rename = "ssn", + )] + pub ssn: String, + + #[serde( + rename = "height", + )] + pub height: f64, + + #[serde( + rename = "dob", + serialize_with = "serialize_datetime", + deserialize_with = "deserialize_datetime", + )] + pub dob: DateTime, + + #[serde( + rename = "$identifier", + )] + pub _identifier: String, +} + +#[derive(Debug, Serialize, Deserialize)] +pub struct Manager { + #[serde( + rename = "$class", + )] + pub _class: String, + + #[serde(rename = "reports")] + pub reports: Option>, + + #[serde( + rename = "employeeId", + )] + pub employee_id: String, + + #[serde( + rename = "salary", + )] + pub salary: u64, + + #[serde( + rename = "numDependents", + )] + pub num_dependents: Integer, + + #[serde( + rename = "retired", + )] + pub retired: bool, + + #[serde( + rename = "department", + )] + pub department: Department, + + #[serde( + rename = "officeAddress", + )] + pub office_address: Address, + + #[serde( + rename = "companyAssets", + )] + pub company_assets: Vec, + + #[serde(rename = "manager")] + pub manager: Option, + + #[serde( + rename = "email", + )] + pub email: String, + + #[serde( + rename = "firstName", + )] + pub first_name: String, + + #[serde( + rename = "lastName", + )] + pub last_name: String, + + #[serde( + rename = "middleNames", + skip_serializing_if = "Option::is_none", + )] + pub middle_names: Option, + + #[serde( + rename = "homeAddress", + )] + pub home_address: Address, + + #[serde( + rename = "ssn", + )] + pub ssn: String, + + #[serde( + rename = "height", + )] + pub height: f64, + + #[serde( + rename = "dob", + serialize_with = "serialize_datetime", + deserialize_with = "deserialize_datetime", + )] + pub dob: DateTime, + + #[serde( + rename = "$identifier", + )] + pub _identifier: String, +} + +#[derive(Debug, Serialize, Deserialize)] +pub struct CompanyEvent { + #[serde( + rename = "$class", + )] + pub _class: String, + + #[serde( + rename = "$timestamp", + serialize_with = "serialize_datetime", + deserialize_with = "deserialize_datetime", + )] + pub _timestamp: DateTime, +} + +#[derive(Debug, Serialize, Deserialize)] +pub struct Onboarded { + #[serde( + rename = "$class", + )] + pub _class: String, + + #[serde(rename = "employee")] + pub employee: Employee, + + #[serde( + rename = "$timestamp", + serialize_with = "serialize_datetime", + deserialize_with = "deserialize_datetime", + )] + pub _timestamp: DateTime, +} + +#[derive(Debug, Serialize, Deserialize)] +pub struct ChangeOfAddress { + #[serde( + rename = "$class", + )] + pub _class: String, + + #[serde(rename = "Person")] + pub person: Person, + + #[serde( + rename = "newAddress", + )] + pub new_address: Address, + + #[serde( + rename = "$timestamp", + serialize_with = "serialize_datetime", + deserialize_with = "deserialize_datetime", + )] + pub _timestamp: DateTime, +} + +", +} +`; + +exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'typescript' 1`] = ` +{ + "key": "concerto@1.0.0.ts", + "value": "/* eslint-disable @typescript-eslint/no-empty-interface */ +// Generated code for namespace: concerto@1.0.0 + +// imports + +// Warning: Beware of circular dependencies when modifying these imports +import type { + State, + IAddress, + ICompany, + Department, + LaptopMake +} from './org.acme.hr'; + +// Warning: Beware of circular dependencies when modifying these imports +import type { + IEquipment +} from './org.acme.hr'; + +// Warning: Beware of circular dependencies when modifying these imports +import type { + IPerson +} from './org.acme.hr'; + +// Warning: Beware of circular dependencies when modifying these imports +import type { + IChangeOfAddress +} from './org.acme.hr'; + +// Warning: Beware of circular dependencies when modifying these imports +import type { + ICompanyEvent +} from './org.acme.hr'; + +// interfaces +export interface IConcept { + $class: string; +} + +export type ConceptUnion = IAddress | +ICompany; + +export interface IAsset extends IConcept { + $identifier: string; +} + +export type AssetUnion = IEquipment; + +export interface IParticipant extends IConcept { + $identifier: string; +} + +export type ParticipantUnion = IPerson; + +export interface ITransaction extends IConcept { + $timestamp: Date; +} + +export type TransactionUnion = IChangeOfAddress; + +export interface IEvent extends IConcept { + $timestamp: Date; +} + +export type EventUnion = ICompanyEvent; + +", +} +`; + +exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'typescript' 2`] = ` +{ + "key": "concerto.ts", + "value": "/* eslint-disable @typescript-eslint/no-empty-interface */ +// Generated code for namespace: concerto + +// imports + +// interfaces +export interface IConcept { + $class: string; +} + +export interface IAsset extends IConcept { + $identifier: string; +} + +export interface IParticipant extends IConcept { + $identifier: string; +} + +export interface ITransaction extends IConcept { +} + +export interface IEvent extends IConcept { +} + +", +} +`; + +exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'typescript' 3`] = ` +{ + "key": "org.acme.hr.ts", + "value": "/* eslint-disable @typescript-eslint/no-empty-interface */ +// Generated code for namespace: org.acme.hr + +// imports + +// Warning: Beware of circular dependencies when modifying these imports + +// Warning: Beware of circular dependencies when modifying these imports + +// Warning: Beware of circular dependencies when modifying these imports + +// Warning: Beware of circular dependencies when modifying these imports +import {IConcept,IAsset,IParticipant,IEvent,ITransaction} from './concerto@1.0.0'; + +// interfaces +export enum State { + MA = 'MA', + NY = 'NY', + CO = 'CO', + WA = 'WA', + IL = 'IL', + CA = 'CA', +} + +export interface IAddress extends IConcept { + street: string; + city: string; + state?: State; + zipCode: string; + country: string; + dictionary1: Map1; + dictionary2: Map2; + dictionary3: Map3; + dictionary4: Map4; + dictionary5: Map5; + dictionary6: Map6; +} + +export type Map1 = Map; + +export type Map2 = Map; + +export type Map3 = Map; + +export type Map4 = Map; + +export type Map5 = Map; + +export type Map6 = Map; + +export interface ICompany extends IConcept { + name: string; + headquarters: IAddress; +} + +export enum Department { + Sales = 'Sales', + Marketing = 'Marketing', + Finance = 'Finance', + HR = 'HR', + Engineering = 'Engineering', + Design = 'Design', +} + +export interface IEquipment extends IAsset { + serialNumber: string; +} + +export type EquipmentUnion = ILaptop; + +export enum LaptopMake { + Apple = 'Apple', + Microsoft = 'Microsoft', +} + +export interface ILaptop extends IEquipment { + make: LaptopMake; +} + +export interface IPerson extends IParticipant { + email: string; + firstName: string; + lastName: string; + middleNames?: string; + homeAddress: IAddress; + ssn: string; + height: number; + dob: Date; +} + +export type PersonUnion = IEmployee | +IContractor; + +export interface IEmployee extends IPerson { + employeeId: string; + salary: number; + numDependents: number; + retired: boolean; + department: Department; + officeAddress: IAddress; + companyAssets: IEquipment[]; + manager?: IManager; +} + +export type EmployeeUnion = IManager; + +export interface IContractor extends IPerson { + company: ICompany; + manager?: IManager; +} + +export interface IManager extends IEmployee { + reports?: IPerson[]; +} + +export interface ICompanyEvent extends IEvent { +} + +export type CompanyEventUnion = IOnboarded; + +export interface IOnboarded extends ICompanyEvent { + employee: IEmployee; +} + +export interface IChangeOfAddress extends ITransaction { + Person: IPerson; + newAddress: IAddress; +} + +", +} +`; + +exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'vocabulary' 1`] = ` +{ + "key": "org.acme.hr_en.voc", + "value": "#Generated vocabulary for namespace: org.acme.hr +locale: en +namespace: org.acme.hr +declarations: + - State: State + properties: + - MA: MA of the State + - NY: NY of the State + - CO: CO of the State + - WA: WA of the State + - IL: IL of the State + - CA: CA of the State + - Address: Address + properties: + - street: Street of the Address + - city: City of the Address + - state: State of the Address + - zipCode: Zip Code of the Address + - country: Country of the Address + - dictionary1: Dictionary1 of the Address + - dictionary2: Dictionary2 of the Address + - dictionary3: Dictionary3 of the Address + - dictionary4: Dictionary4 of the Address + - dictionary5: Dictionary5 of the Address + - dictionary6: Dictionary6 of the Address + - Time: Time + - Company: Company + properties: + - name: Name of the Company + - headquarters: Headquarters of the Company + - Department: Department + properties: + - Sales: Sales of the Department + - Marketing: Marketing of the Department + - Finance: Finance of the Department + - HR: HR of the Department + - Engineering: Engineering of the Department + - Design: Design of the Department + - Equipment: Equipment + properties: + - serialNumber: Serial Number of the Equipment + - LaptopMake: Laptop Make + properties: + - Apple: Apple of the Laptop Make + - Microsoft: Microsoft of the Laptop Make + - Laptop: Laptop + properties: + - make: Make of the Laptop + - SSN: SSN + - Person: Person + properties: + - email: Email of the Person + - firstName: First Name of the Person + - lastName: Last Name of the Person + - middleNames: Middle Names of the Person + - homeAddress: Home Address of the Person + - ssn: Ssn of the Person + - height: Height of the Person + - dob: Dob of the Person + - Employee: Employee + properties: + - employeeId: Employee Id of the Employee + - salary: Salary of the Employee + - numDependents: Num Dependents of the Employee + - retired: Retired of the Employee + - department: Department of the Employee + - officeAddress: Office Address of the Employee + - companyAssets: Company Assets of the Employee + - manager: Manager of the Employee + - Contractor: Contractor + properties: + - company: Company of the Contractor + - manager: Manager of the Contractor + - Manager: Manager + properties: + - reports: Reports of the Manager + - CompanyEvent: Company Event + - Onboarded: Onboarded + properties: + - employee: Employee of the Onboarded + - ChangeOfAddress: Change Of Address + properties: + - Person: Person of the Change Of Address + - newAddress: New Address of the Change Of Address +", +} +`; + +exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'xmlschema' 1`] = ` +{ + "key": "concerto@1.0.0.xsd", + "value": " + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +", +} +`; + +exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'xmlschema' 2`] = ` +{ + "key": "concerto.xsd", + "value": " + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +", +} +`; + +exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'xmlschema' 3`] = ` +{ + "key": "org.acme.hr.xsd", + "value": " + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +", +} +`; + +exports[`codegen #formats check we can convert all formats from namespace versioned CTO without the base model, format 'mermaid' 1`] = ` +{ + "key": "model.mmd", + "value": "classDiagram +class \`org.acme.hr@1.0.0.State\` { +<< enumeration>> + + \`MA\` + + \`NY\` + + \`CO\` + + \`WA\` + + \`IL\` + + \`CA\` +} + +class \`org.acme.hr@1.0.0.Address\` { +<< concept>> + + \`String\` \`street\` + + \`String\` \`city\` + + \`State\` \`state\` + + \`String\` \`zipCode\` + + \`String\` \`country\` + + \`Map1\` \`dictionary1\` + + \`Map2\` \`dictionary2\` + + \`Map3\` \`dictionary3\` + + \`Map4\` \`dictionary4\` + + \`Map5\` \`dictionary5\` + + \`Map6\` \`dictionary6\` +} + +\`org.acme.hr@1.0.0.Address\` "1" *-- "1" \`org.acme.hr@1.0.0.State\` +\`org.acme.hr@1.0.0.Address\` "1" *-- "1" \`org.acme.hr@1.0.0.Map1\` +\`org.acme.hr@1.0.0.Address\` "1" *-- "1" \`org.acme.hr@1.0.0.Map2\` +\`org.acme.hr@1.0.0.Address\` "1" *-- "1" \`org.acme.hr@1.0.0.Map3\` +\`org.acme.hr@1.0.0.Address\` "1" *-- "1" \`org.acme.hr@1.0.0.Map4\` +\`org.acme.hr@1.0.0.Address\` "1" *-- "1" \`org.acme.hr@1.0.0.Map5\` +\`org.acme.hr@1.0.0.Address\` "1" *-- "1" \`org.acme.hr@1.0.0.Map6\` +class \`org.acme.hr@1.0.0.Company\` { +<< concept>> + + \`String\` \`name\` + + \`Address\` \`headquarters\` +} + +\`org.acme.hr@1.0.0.Company\` "1" *-- "1" \`org.acme.hr@1.0.0.Address\` +class \`org.acme.hr@1.0.0.Department\` { +<< enumeration>> + + \`Sales\` + + \`Marketing\` + + \`Finance\` + + \`HR\` + + \`Engineering\` + + \`Design\` +} + +class \`org.acme.hr@1.0.0.Equipment\` { +<< asset>> + + \`String\` \`serialNumber\` +} + +class \`org.acme.hr@1.0.0.LaptopMake\` { +<< enumeration>> + + \`Apple\` + + \`Microsoft\` +} + +class \`org.acme.hr@1.0.0.Laptop\` { +<< asset>> + + \`LaptopMake\` \`make\` +} + +\`org.acme.hr@1.0.0.Laptop\` "1" *-- "1" \`org.acme.hr@1.0.0.LaptopMake\` +\`org.acme.hr@1.0.0.Laptop\` --|> \`org.acme.hr@1.0.0.Equipment\` +class \`org.acme.hr@1.0.0.Person\` { +<< participant>> + + \`String\` \`email\` + + \`String\` \`firstName\` + + \`String\` \`lastName\` + + \`String\` \`middleNames\` + + \`Address\` \`homeAddress\` + + \`String\` \`ssn\` + + \`Double\` \`height\` + + \`DateTime\` \`dob\` +} + +\`org.acme.hr@1.0.0.Person\` "1" *-- "1" \`org.acme.hr@1.0.0.Address\` +\`org.acme.hr@1.0.0.Person\` "1" *-- "1" \`org.acme.hr@1.0.0.SSN\` +class \`org.acme.hr@1.0.0.Employee\` { +<< participant>> + + \`String\` \`employeeId\` + + \`Long\` \`salary\` + + \`Integer\` \`numDependents\` + + \`Boolean\` \`retired\` + + \`Department\` \`department\` + + \`Address\` \`officeAddress\` + + \`Equipment[]\` \`companyAssets\` + + \`Manager\` \`manager\` +} + +\`org.acme.hr@1.0.0.Employee\` "1" *-- "1" \`org.acme.hr@1.0.0.Department\` +\`org.acme.hr@1.0.0.Employee\` "1" *-- "1" \`org.acme.hr@1.0.0.Address\` +\`org.acme.hr@1.0.0.Employee\` "1" *-- "*" \`org.acme.hr@1.0.0.Equipment\` +\`org.acme.hr@1.0.0.Employee\` "1" o-- "1" \`org.acme.hr@1.0.0.Manager\` : manager +\`org.acme.hr@1.0.0.Employee\` --|> \`org.acme.hr@1.0.0.Person\` +class \`org.acme.hr@1.0.0.Contractor\` { +<< participant>> + + \`Company\` \`company\` + + \`Manager\` \`manager\` +} + +\`org.acme.hr@1.0.0.Contractor\` "1" *-- "1" \`org.acme.hr@1.0.0.Company\` +\`org.acme.hr@1.0.0.Contractor\` "1" o-- "1" \`org.acme.hr@1.0.0.Manager\` : manager +\`org.acme.hr@1.0.0.Contractor\` --|> \`org.acme.hr@1.0.0.Person\` +class \`org.acme.hr@1.0.0.Manager\` { +<< participant>> + + \`Person[]\` \`reports\` +} + +\`org.acme.hr@1.0.0.Manager\` "1" o-- "*" \`org.acme.hr@1.0.0.Person\` : reports +\`org.acme.hr@1.0.0.Manager\` --|> \`org.acme.hr@1.0.0.Employee\` +class \`org.acme.hr@1.0.0.CompanyEvent\` +<< event>> \`org.acme.hr@1.0.0.CompanyEvent\` + +class \`org.acme.hr@1.0.0.Onboarded\` { +<< event>> + + \`Employee\` \`employee\` +} + +\`org.acme.hr@1.0.0.Onboarded\` "1" o-- "1" \`org.acme.hr@1.0.0.Employee\` : employee +\`org.acme.hr@1.0.0.Onboarded\` --|> \`org.acme.hr@1.0.0.CompanyEvent\` +class \`org.acme.hr@1.0.0.ChangeOfAddress\` { +<< transaction>> + + \`Person\` \`Person\` + + \`Address\` \`newAddress\` +} + +\`org.acme.hr@1.0.0.ChangeOfAddress\` "1" o-- "1" \`org.acme.hr@1.0.0.Person\` : Person +\`org.acme.hr@1.0.0.ChangeOfAddress\` "1" *-- "1" \`org.acme.hr@1.0.0.Address\` +", +} +`; + +exports[`codegen #formats check we can convert all formats from namespace versioned CTO without the base model, format 'plantuml' 1`] = ` +{ + "key": "model.puml", + "value": "@startuml +title +Model +endtitle +class org.acme.hr_1_0_0.State << (E,grey) >> { + + MA + + NY + + CO + + WA + + IL + + CA +} +class org.acme.hr_1_0_0.Address { + + String street + + String city + + State state + + String zipCode + + String country + + Map1 dictionary1 + + Map2 dictionary2 + + Map3 dictionary3 + + Map4 dictionary4 + + Map5 dictionary5 + + Map6 dictionary6 +} +org.acme.hr_1_0_0.Address "1" *-- "1" org.acme.hr_1_0_0.State : state +org.acme.hr_1_0_0.Address "1" *-- "1" org.acme.hr_1_0_0.Map1 : dictionary1 +org.acme.hr_1_0_0.Address "1" *-- "1" org.acme.hr_1_0_0.Map2 : dictionary2 +org.acme.hr_1_0_0.Address "1" *-- "1" org.acme.hr_1_0_0.Map3 : dictionary3 +org.acme.hr_1_0_0.Address "1" *-- "1" org.acme.hr_1_0_0.Map4 : dictionary4 +org.acme.hr_1_0_0.Address "1" *-- "1" org.acme.hr_1_0_0.Map5 : dictionary5 +org.acme.hr_1_0_0.Address "1" *-- "1" org.acme.hr_1_0_0.Map6 : dictionary6 +class org.acme.hr_1_0_0.Company { + + String name + + Address headquarters +} +org.acme.hr_1_0_0.Company "1" *-- "1" org.acme.hr_1_0_0.Address : headquarters +class org.acme.hr_1_0_0.Department << (E,grey) >> { + + Sales + + Marketing + + Finance + + HR + + Engineering + + Design +} +class org.acme.hr_1_0_0.Equipment << (A,green) >> { + + String serialNumber +} +class org.acme.hr_1_0_0.LaptopMake << (E,grey) >> { + + Apple + + Microsoft +} +class org.acme.hr_1_0_0.Laptop << (A,green) >> { + + LaptopMake make +} +org.acme.hr_1_0_0.Laptop "1" *-- "1" org.acme.hr_1_0_0.LaptopMake : make +org.acme.hr_1_0_0.Laptop --|> org.acme.hr_1_0_0.Equipment +class org.acme.hr_1_0_0.Person << (P,lightblue) >> { + + String email + + String firstName + + String lastName + + String middleNames + + Address homeAddress + + String ssn + + Double height + + DateTime dob +} +org.acme.hr_1_0_0.Person "1" *-- "1" org.acme.hr_1_0_0.Address : homeAddress +org.acme.hr_1_0_0.Person "1" *-- "1" org.acme.hr_1_0_0.SSN : ssn +class org.acme.hr_1_0_0.Employee << (P,lightblue) >> { + + String employeeId + + Long salary + + Integer numDependents + + Boolean retired + + Department department + + Address officeAddress + + Equipment[] companyAssets + + Manager manager +} +org.acme.hr_1_0_0.Employee "1" *-- "1" org.acme.hr_1_0_0.Department : department +org.acme.hr_1_0_0.Employee "1" *-- "1" org.acme.hr_1_0_0.Address : officeAddress +org.acme.hr_1_0_0.Employee "1" *-- "*" org.acme.hr_1_0_0.Equipment : companyAssets +org.acme.hr_1_0_0.Employee "1" o-- "1" org.acme.hr_1_0_0.Manager : manager +org.acme.hr_1_0_0.Employee --|> org.acme.hr_1_0_0.Person +class org.acme.hr_1_0_0.Contractor << (P,lightblue) >> { + + Company company + + Manager manager +} +org.acme.hr_1_0_0.Contractor "1" *-- "1" org.acme.hr_1_0_0.Company : company +org.acme.hr_1_0_0.Contractor "1" o-- "1" org.acme.hr_1_0_0.Manager : manager +org.acme.hr_1_0_0.Contractor --|> org.acme.hr_1_0_0.Person +class org.acme.hr_1_0_0.Manager << (P,lightblue) >> { + + Person[] reports +} +org.acme.hr_1_0_0.Manager "1" o-- "*" org.acme.hr_1_0_0.Person : reports +org.acme.hr_1_0_0.Manager --|> org.acme.hr_1_0_0.Employee +class org.acme.hr_1_0_0.CompanyEvent { +} +class org.acme.hr_1_0_0.Onboarded { + + Employee employee +} +org.acme.hr_1_0_0.Onboarded "1" o-- "1" org.acme.hr_1_0_0.Employee : employee +org.acme.hr_1_0_0.Onboarded --|> org.acme.hr_1_0_0.CompanyEvent +class org.acme.hr_1_0_0.ChangeOfAddress << (T,yellow) >> { + + Person Person + + Address newAddress +} +org.acme.hr_1_0_0.ChangeOfAddress "1" o-- "1" org.acme.hr_1_0_0.Person : Person +org.acme.hr_1_0_0.ChangeOfAddress "1" *-- "1" org.acme.hr_1_0_0.Address : newAddress +@enduml +", +} +`; + exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'avro' 1`] = ` { "key": "concerto@1.0.0.avdl", @@ -4787,7 +9973,7 @@ xmlns:concerto="concerto" - + @@ -4806,7 +9992,7 @@ xmlns:concerto="concerto" - + From 2cce59ea235aaa8da1101580ed0ae424ce0f71c9 Mon Sep 17 00:00:00 2001 From: Jonathan Casey Date: Thu, 9 Nov 2023 15:23:39 +0000 Subject: [PATCH 07/20] test(*): update snapshot Signed-off-by: Jonathan Casey --- test/codegen/__snapshots__/codegen.js.snap | 620 +++++++++++++-------- 1 file changed, 380 insertions(+), 240 deletions(-) diff --git a/test/codegen/__snapshots__/codegen.js.snap b/test/codegen/__snapshots__/codegen.js.snap index 66c07675..cc7052d8 100644 --- a/test/codegen/__snapshots__/codegen.js.snap +++ b/test/codegen/__snapshots__/codegen.js.snap @@ -6,7 +6,7 @@ exports[`codegen #formats check we can convert all formats from namespace unvers "value": "@namespace("concerto@1.0.0") protocol MyProtocol { - + record Concept { } @@ -39,7 +39,7 @@ exports[`codegen #formats check we can convert all formats from namespace unvers "value": "@namespace("concerto") protocol MyProtocol { - + record Concept { } @@ -69,7 +69,7 @@ exports[`codegen #formats check we can convert all formats from namespace unvers protocol MyProtocol { import idl "concerto@1.0.0.avdl"; - + enum State { MA, NY, @@ -106,7 +106,7 @@ protocol MyProtocol { import idl "org.acme.hr.base.avdl"; import idl "concerto@1.0.0.avdl"; - + record Company { string name; Address headquarters; @@ -494,7 +494,7 @@ exports[`codegen #formats check we can convert all formats from namespace unvers "value": "// Package concerto_1_0_0 contains domain objects and was generated from Concerto namespace concerto@1.0.0. package concerto_1_0_0 import "time" - + type Concept struct { } type Asset struct { @@ -522,7 +522,7 @@ exports[`codegen #formats check we can convert all formats from namespace unvers "key": "concerto.go", "value": "// Package concerto contains domain objects and was generated from Concerto namespace concerto. package concerto - + type Concept struct { } type Asset struct { @@ -549,7 +549,7 @@ exports[`codegen #formats check we can convert all formats from namespace unvers "value": "// Package org_acme_hr_base contains domain objects and was generated from Concerto namespace org.acme.hr.base. package org_acme_hr_base import "concerto_1_0_0"; - + type State int const ( MA State = 1 + iota @@ -585,7 +585,7 @@ package org_acme_hr import "time" import "org_acme_hr_base"; import "concerto_1_0_0"; - + type Company struct { concerto_1_0_0.Concept Name string \`json:"name"\` @@ -870,7 +870,7 @@ public abstract class Asset extends Concept { public void set$id(String i) { $id = i; } - + // the accessor for the identifying field public String getID() { return this.get$identifier(); @@ -909,7 +909,7 @@ public abstract class Participant extends Concept { public void set$id(String i) { $id = i; } - + // the accessor for the identifying field public String getID() { return this.get$identifier(); @@ -1166,7 +1166,7 @@ import com.fasterxml.jackson.annotation.*; @JsonIgnoreProperties({"id"}) @JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "serialNumber") public abstract class Equipment extends Asset { - + // the accessor for the identifying field public String getID() { return this.getSerialNumber(); @@ -1221,7 +1221,7 @@ import com.fasterxml.jackson.annotation.*; @JsonIgnoreProperties({"id"}) @JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "serialNumber") public class Laptop extends Equipment { - + // the accessor for the identifying field public String getID() { return this.getSerialNumber(); @@ -1262,7 +1262,7 @@ import com.fasterxml.jackson.annotation.*; @JsonIgnoreProperties({"id"}) @JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "email") public abstract class Person extends Participant { - + // the accessor for the identifying field public String getID() { return this.getEmail(); @@ -1357,7 +1357,7 @@ import com.fasterxml.jackson.annotation.*; @JsonIgnoreProperties({"id"}) @JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "email") public class Employee extends Person { - + // the accessor for the identifying field public String getID() { return this.getEmail(); @@ -1445,7 +1445,7 @@ import com.fasterxml.jackson.annotation.*; @JsonIgnoreProperties({"id"}) @JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "email") public class Contractor extends Person { - + // the accessor for the identifying field public String getID() { return this.getEmail(); @@ -1491,7 +1491,7 @@ import com.fasterxml.jackson.annotation.*; @JsonIgnoreProperties({"id"}) @JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "email") public class Manager extends Employee { - + // the accessor for the identifying field public String getID() { return this.getEmail(); @@ -3830,7 +3830,7 @@ exports[`codegen #formats check we can convert all formats from namespace unvers "key": "utils.rs", "value": "use chrono::{ DateTime, TimeZone, Utc }; use serde::{ Deserialize, Serialize, Deserializer, Serializer }; - + pub fn serialize_datetime_option(datetime: &Option>, serializer: S) -> Result where S: Serializer, @@ -3860,7 +3860,7 @@ where let datetime_str = String::deserialize(deserializer)?; Utc.datetime_from_str(&datetime_str, "%Y-%m-%dT%H:%M:%S%.3f%Z").map_err(serde::de::Error::custom) } - + pub fn serialize_datetime(datetime: &chrono::DateTime, serializer: S) -> Result where S: Serializer, @@ -3877,9 +3877,9 @@ exports[`codegen #formats check we can convert all formats from namespace unvers "key": "concerto_1_0_0.rs", "value": "use serde::{ Deserialize, Serialize }; use chrono::{ DateTime, TimeZone, Utc }; - + use crate::utils::*; - + #[derive(Debug, Serialize, Deserialize)] pub struct Concept { #[serde( @@ -3894,7 +3894,7 @@ pub struct Asset { rename = "$class", )] pub _class: String, - + #[serde( rename = "$identifier", )] @@ -3907,7 +3907,7 @@ pub struct Participant { rename = "$class", )] pub _class: String, - + #[serde( rename = "$identifier", )] @@ -3920,7 +3920,7 @@ pub struct Transaction { rename = "$class", )] pub _class: String, - + #[serde( rename = "$timestamp", serialize_with = "serialize_datetime", @@ -3935,7 +3935,7 @@ pub struct Event { rename = "$class", )] pub _class: String, - + #[serde( rename = "$timestamp", serialize_with = "serialize_datetime", @@ -3953,9 +3953,9 @@ exports[`codegen #formats check we can convert all formats from namespace unvers "key": "concerto.rs", "value": "use serde::{ Deserialize, Serialize }; use chrono::{ DateTime, TimeZone, Utc }; - + use crate::utils::*; - + #[derive(Debug, Serialize, Deserialize)] pub struct Concept { #[serde( @@ -3970,7 +3970,7 @@ pub struct Asset { rename = "$class", )] pub _class: String, - + #[serde( rename = "$identifier", )] @@ -3983,7 +3983,7 @@ pub struct Participant { rename = "$class", )] pub _class: String, - + #[serde( rename = "$identifier", )] @@ -4015,10 +4015,10 @@ exports[`codegen #formats check we can convert all formats from namespace unvers "key": "org_acme_hr_base.rs", "value": "use serde::{ Deserialize, Serialize }; use chrono::{ DateTime, TimeZone, Utc }; - + use crate::concerto_1_0_0::*; use crate::utils::*; - + #[derive(Debug, Serialize, Deserialize)] pub enum State { #[allow(non_camel_case_types)] @@ -4051,28 +4051,28 @@ pub struct Address { rename = "$class", )] pub _class: String, - + #[serde( rename = "street", )] pub street: String, - + #[serde( rename = "city", )] pub city: String, - + #[serde( rename = "state", skip_serializing_if = "Option::is_none", )] pub state: Option, - + #[serde( rename = "zipCode", )] pub zip_code: String, - + #[serde( rename = "country", )] @@ -4088,52 +4088,52 @@ exports[`codegen #formats check we can convert all formats from namespace unvers "key": "org_acme_hr.rs", "value": "use serde::{ Deserialize, Serialize }; use chrono::{ DateTime, TimeZone, Utc }; - + use crate::org_acme_hr_base::*; use crate::concerto_1_0_0::*; use crate::utils::*; - + #[derive(Debug, Serialize, Deserialize)] pub struct Company { #[serde( rename = "$class", )] pub _class: String, - + #[serde( rename = "name", )] pub name: String, - + #[serde( rename = "headquarters", )] pub headquarters: Address, - + #[serde( rename = "companyProperties", skip_serializing_if = "Option::is_none", )] pub company_properties: Option, - + #[serde( rename = "employeeDirectory", skip_serializing_if = "Option::is_none", )] pub employee_directory: Option, - + #[serde( rename = "employeeTShirtSizes", skip_serializing_if = "Option::is_none", )] pub employee_t_shirt_sizes: Option, - + #[serde( rename = "employeeProfiles", skip_serializing_if = "Option::is_none", )] pub employee_profiles: Option, - + #[serde( rename = "employeeSocialSecurityNumbers", skip_serializing_if = "Option::is_none", @@ -4163,12 +4163,12 @@ pub struct Equipment { rename = "$class", )] pub _class: String, - + #[serde( rename = "serialNumber", )] pub serial_number: String, - + #[serde( rename = "$identifier", )] @@ -4189,17 +4189,17 @@ pub struct Laptop { rename = "$class", )] pub _class: String, - + #[serde( rename = "make", )] pub make: LaptopMake, - + #[serde( rename = "serialNumber", )] pub serial_number: String, - + #[serde( rename = "$identifier", )] @@ -4212,55 +4212,55 @@ pub struct Person { rename = "$class", )] pub _class: String, - + #[serde( rename = "email", )] pub email: String, - + #[serde( rename = "firstName", )] pub first_name: String, - + #[serde( rename = "lastName", )] pub last_name: String, - + #[serde( rename = "middleNames", skip_serializing_if = "Option::is_none", )] pub middle_names: Option, - + #[serde( rename = "homeAddress", )] pub home_address: Address, - + #[serde( rename = "ssn", )] pub ssn: String, - + #[serde( rename = "height", )] pub height: f64, - + #[serde( rename = "dob", serialize_with = "serialize_datetime", deserialize_with = "deserialize_datetime", )] pub dob: DateTime, - + #[serde( rename = "nextOfKin", )] pub next_of_kin: NextOfKin, - + #[serde( rename = "$identifier", )] @@ -4273,93 +4273,93 @@ pub struct Employee { rename = "$class", )] pub _class: String, - + #[serde( rename = "employeeId", )] pub employee_id: String, - + #[serde( rename = "salary", )] pub salary: u64, - + #[serde( rename = "numDependents", )] pub num_dependents: Integer, - + #[serde( rename = "retired", )] pub retired: bool, - + #[serde( rename = "department", )] pub department: Department, - + #[serde( rename = "officeAddress", )] pub office_address: Address, - + #[serde( rename = "companyAssets", )] pub company_assets: Vec, - + #[serde(rename = "manager")] pub manager: Option, - + #[serde( rename = "email", )] pub email: String, - + #[serde( rename = "firstName", )] pub first_name: String, - + #[serde( rename = "lastName", )] pub last_name: String, - + #[serde( rename = "middleNames", skip_serializing_if = "Option::is_none", )] pub middle_names: Option, - + #[serde( rename = "homeAddress", )] pub home_address: Address, - + #[serde( rename = "ssn", )] pub ssn: String, - + #[serde( rename = "height", )] pub height: f64, - + #[serde( rename = "dob", serialize_with = "serialize_datetime", deserialize_with = "deserialize_datetime", )] pub dob: DateTime, - + #[serde( rename = "nextOfKin", )] pub next_of_kin: NextOfKin, - + #[serde( rename = "$identifier", )] @@ -4372,63 +4372,63 @@ pub struct Contractor { rename = "$class", )] pub _class: String, - + #[serde( rename = "company", )] pub company: Company, - + #[serde(rename = "manager")] pub manager: Option, - + #[serde( rename = "email", )] pub email: String, - + #[serde( rename = "firstName", )] pub first_name: String, - + #[serde( rename = "lastName", )] pub last_name: String, - + #[serde( rename = "middleNames", skip_serializing_if = "Option::is_none", )] pub middle_names: Option, - + #[serde( rename = "homeAddress", )] pub home_address: Address, - + #[serde( rename = "ssn", )] pub ssn: String, - + #[serde( rename = "height", )] pub height: f64, - + #[serde( rename = "dob", serialize_with = "serialize_datetime", deserialize_with = "deserialize_datetime", )] pub dob: DateTime, - + #[serde( rename = "nextOfKin", )] pub next_of_kin: NextOfKin, - + #[serde( rename = "$identifier", )] @@ -4441,96 +4441,96 @@ pub struct Manager { rename = "$class", )] pub _class: String, - + #[serde(rename = "reports")] pub reports: Option>, - + #[serde( rename = "employeeId", )] pub employee_id: String, - + #[serde( rename = "salary", )] pub salary: u64, - + #[serde( rename = "numDependents", )] pub num_dependents: Integer, - + #[serde( rename = "retired", )] pub retired: bool, - + #[serde( rename = "department", )] pub department: Department, - + #[serde( rename = "officeAddress", )] pub office_address: Address, - + #[serde( rename = "companyAssets", )] pub company_assets: Vec, - + #[serde(rename = "manager")] pub manager: Option, - + #[serde( rename = "email", )] pub email: String, - + #[serde( rename = "firstName", )] pub first_name: String, - + #[serde( rename = "lastName", )] pub last_name: String, - + #[serde( rename = "middleNames", skip_serializing_if = "Option::is_none", )] pub middle_names: Option, - + #[serde( rename = "homeAddress", )] pub home_address: Address, - + #[serde( rename = "ssn", )] pub ssn: String, - + #[serde( rename = "height", )] pub height: f64, - + #[serde( rename = "dob", serialize_with = "serialize_datetime", deserialize_with = "deserialize_datetime", )] pub dob: DateTime, - + #[serde( rename = "nextOfKin", )] pub next_of_kin: NextOfKin, - + #[serde( rename = "$identifier", )] @@ -4543,7 +4543,7 @@ pub struct CompanyEvent { rename = "$class", )] pub _class: String, - + #[serde( rename = "$timestamp", serialize_with = "serialize_datetime", @@ -4558,10 +4558,10 @@ pub struct Onboarded { rename = "$class", )] pub _class: String, - + #[serde(rename = "employee")] pub employee: Employee, - + #[serde( rename = "$timestamp", serialize_with = "serialize_datetime", @@ -4576,15 +4576,15 @@ pub struct ChangeOfAddress { rename = "$class", )] pub _class: String, - + #[serde(rename = "Person")] pub person: Person, - + #[serde( rename = "newAddress", )] pub new_address: Address, - + #[serde( rename = "$timestamp", serialize_with = "serialize_datetime", @@ -4642,7 +4642,7 @@ export interface IConcept { $class: string; } -export type ConceptUnion = IAddress | +export type ConceptUnion = IAddress | ICompany; export interface IAsset extends IConcept { @@ -4820,7 +4820,7 @@ export interface IPerson extends IParticipant { nextOfKin: NextOfKin; } -export type PersonUnion = IEmployee | +export type PersonUnion = IEmployee | IContractor; export interface IEmployee extends IPerson { @@ -4976,7 +4976,7 @@ exports[`codegen #formats check we can convert all formats from namespace unvers { "key": "concerto@1.0.0.xsd", "value": " - @@ -5032,7 +5032,7 @@ exports[`codegen #formats check we can convert all formats from namespace unvers { "key": "concerto.xsd", "value": " - @@ -5086,7 +5086,7 @@ exports[`codegen #formats check we can convert all formats from namespace unvers { "key": "org.acme.hr.base.xsd", "value": " - @@ -5109,6 +5109,16 @@ xmlns:concerto="concerto" + + + + + + + + + + @@ -5132,12 +5142,72 @@ exports[`codegen #formats check we can convert all formats from namespace unvers { "key": "org.acme.hr.xsd", "value": " - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -5558,7 +5628,7 @@ exports[`codegen #formats check we can convert all formats from namespace versio "value": "@namespace("concerto@1.0.0") protocol MyProtocol { - + record Concept { } @@ -5591,7 +5661,7 @@ exports[`codegen #formats check we can convert all formats from namespace versio "value": "@namespace("concerto") protocol MyProtocol { - + record Concept { } @@ -5621,7 +5691,7 @@ exports[`codegen #formats check we can convert all formats from namespace versio protocol MyProtocol { import idl "concerto@1.0.0.avdl"; - + enum State { MA, NY, @@ -5658,7 +5728,7 @@ protocol MyProtocol { import idl "org.acme.hr.base@1.0.0.avdl"; import idl "concerto@1.0.0.avdl"; - + record Company { string name; Address headquarters; @@ -6046,7 +6116,7 @@ exports[`codegen #formats check we can convert all formats from namespace versio "value": "// Package concerto_1_0_0 contains domain objects and was generated from Concerto namespace concerto@1.0.0. package concerto_1_0_0 import "time" - + type Concept struct { } type Asset struct { @@ -6074,7 +6144,7 @@ exports[`codegen #formats check we can convert all formats from namespace versio "key": "concerto.go", "value": "// Package concerto contains domain objects and was generated from Concerto namespace concerto. package concerto - + type Concept struct { } type Asset struct { @@ -6101,7 +6171,7 @@ exports[`codegen #formats check we can convert all formats from namespace versio "value": "// Package org_acme_hr_base_1_0_0 contains domain objects and was generated from Concerto namespace org.acme.hr.base@1.0.0. package org_acme_hr_base_1_0_0 import "concerto_1_0_0"; - + type State int const ( MA State = 1 + iota @@ -6137,7 +6207,7 @@ package org_acme_hr_1_0_0 import "time" import "org_acme_hr_base_1_0_0"; import "concerto_1_0_0"; - + type Company struct { concerto_1_0_0.Concept Name string \`json:"name"\` @@ -6422,7 +6492,7 @@ public abstract class Asset extends Concept { public void set$id(String i) { $id = i; } - + // the accessor for the identifying field public String getID() { return this.get$identifier(); @@ -6461,7 +6531,7 @@ public abstract class Participant extends Concept { public void set$id(String i) { $id = i; } - + // the accessor for the identifying field public String getID() { return this.get$identifier(); @@ -6718,7 +6788,7 @@ import com.fasterxml.jackson.annotation.*; @JsonIgnoreProperties({"id"}) @JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "serialNumber") public abstract class Equipment extends Asset { - + // the accessor for the identifying field public String getID() { return this.getSerialNumber(); @@ -6773,7 +6843,7 @@ import com.fasterxml.jackson.annotation.*; @JsonIgnoreProperties({"id"}) @JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "serialNumber") public class Laptop extends Equipment { - + // the accessor for the identifying field public String getID() { return this.getSerialNumber(); @@ -6814,7 +6884,7 @@ import com.fasterxml.jackson.annotation.*; @JsonIgnoreProperties({"id"}) @JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "email") public abstract class Person extends Participant { - + // the accessor for the identifying field public String getID() { return this.getEmail(); @@ -6909,7 +6979,7 @@ import com.fasterxml.jackson.annotation.*; @JsonIgnoreProperties({"id"}) @JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "email") public class Employee extends Person { - + // the accessor for the identifying field public String getID() { return this.getEmail(); @@ -6997,7 +7067,7 @@ import com.fasterxml.jackson.annotation.*; @JsonIgnoreProperties({"id"}) @JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "email") public class Contractor extends Person { - + // the accessor for the identifying field public String getID() { return this.getEmail(); @@ -7043,7 +7113,7 @@ import com.fasterxml.jackson.annotation.*; @JsonIgnoreProperties({"id"}) @JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "email") public class Manager extends Employee { - + // the accessor for the identifying field public String getID() { return this.getEmail(); @@ -9414,7 +9484,7 @@ exports[`codegen #formats check we can convert all formats from namespace versio "key": "utils.rs", "value": "use chrono::{ DateTime, TimeZone, Utc }; use serde::{ Deserialize, Serialize, Deserializer, Serializer }; - + pub fn serialize_datetime_option(datetime: &Option>, serializer: S) -> Result where S: Serializer, @@ -9444,7 +9514,7 @@ where let datetime_str = String::deserialize(deserializer)?; Utc.datetime_from_str(&datetime_str, "%Y-%m-%dT%H:%M:%S%.3f%Z").map_err(serde::de::Error::custom) } - + pub fn serialize_datetime(datetime: &chrono::DateTime, serializer: S) -> Result where S: Serializer, @@ -9461,9 +9531,9 @@ exports[`codegen #formats check we can convert all formats from namespace versio "key": "concerto_1_0_0.rs", "value": "use serde::{ Deserialize, Serialize }; use chrono::{ DateTime, TimeZone, Utc }; - + use crate::utils::*; - + #[derive(Debug, Serialize, Deserialize)] pub struct Concept { #[serde( @@ -9478,7 +9548,7 @@ pub struct Asset { rename = "$class", )] pub _class: String, - + #[serde( rename = "$identifier", )] @@ -9491,7 +9561,7 @@ pub struct Participant { rename = "$class", )] pub _class: String, - + #[serde( rename = "$identifier", )] @@ -9504,7 +9574,7 @@ pub struct Transaction { rename = "$class", )] pub _class: String, - + #[serde( rename = "$timestamp", serialize_with = "serialize_datetime", @@ -9519,7 +9589,7 @@ pub struct Event { rename = "$class", )] pub _class: String, - + #[serde( rename = "$timestamp", serialize_with = "serialize_datetime", @@ -9537,9 +9607,9 @@ exports[`codegen #formats check we can convert all formats from namespace versio "key": "concerto.rs", "value": "use serde::{ Deserialize, Serialize }; use chrono::{ DateTime, TimeZone, Utc }; - + use crate::utils::*; - + #[derive(Debug, Serialize, Deserialize)] pub struct Concept { #[serde( @@ -9554,7 +9624,7 @@ pub struct Asset { rename = "$class", )] pub _class: String, - + #[serde( rename = "$identifier", )] @@ -9567,7 +9637,7 @@ pub struct Participant { rename = "$class", )] pub _class: String, - + #[serde( rename = "$identifier", )] @@ -9599,10 +9669,10 @@ exports[`codegen #formats check we can convert all formats from namespace versio "key": "org_acme_hr_base_1_0_0.rs", "value": "use serde::{ Deserialize, Serialize }; use chrono::{ DateTime, TimeZone, Utc }; - + use crate::concerto_1_0_0::*; use crate::utils::*; - + #[derive(Debug, Serialize, Deserialize)] pub enum State { #[allow(non_camel_case_types)] @@ -9635,28 +9705,28 @@ pub struct Address { rename = "$class", )] pub _class: String, - + #[serde( rename = "street", )] pub street: String, - + #[serde( rename = "city", )] pub city: String, - + #[serde( rename = "state", skip_serializing_if = "Option::is_none", )] pub state: Option, - + #[serde( rename = "zipCode", )] pub zip_code: String, - + #[serde( rename = "country", )] @@ -9672,52 +9742,52 @@ exports[`codegen #formats check we can convert all formats from namespace versio "key": "org_acme_hr_1_0_0.rs", "value": "use serde::{ Deserialize, Serialize }; use chrono::{ DateTime, TimeZone, Utc }; - + use crate::org_acme_hr_base_1_0_0::*; use crate::concerto_1_0_0::*; use crate::utils::*; - + #[derive(Debug, Serialize, Deserialize)] pub struct Company { #[serde( rename = "$class", )] pub _class: String, - + #[serde( rename = "name", )] pub name: String, - + #[serde( rename = "headquarters", )] pub headquarters: Address, - + #[serde( rename = "companyProperties", skip_serializing_if = "Option::is_none", )] pub company_properties: Option, - + #[serde( rename = "employeeDirectory", skip_serializing_if = "Option::is_none", )] pub employee_directory: Option, - + #[serde( rename = "employeeTShirtSizes", skip_serializing_if = "Option::is_none", )] pub employee_t_shirt_sizes: Option, - + #[serde( rename = "employeeProfiles", skip_serializing_if = "Option::is_none", )] pub employee_profiles: Option, - + #[serde( rename = "employeeSocialSecurityNumbers", skip_serializing_if = "Option::is_none", @@ -9747,12 +9817,12 @@ pub struct Equipment { rename = "$class", )] pub _class: String, - + #[serde( rename = "serialNumber", )] pub serial_number: String, - + #[serde( rename = "$identifier", )] @@ -9773,17 +9843,17 @@ pub struct Laptop { rename = "$class", )] pub _class: String, - + #[serde( rename = "make", )] pub make: LaptopMake, - + #[serde( rename = "serialNumber", )] pub serial_number: String, - + #[serde( rename = "$identifier", )] @@ -9796,55 +9866,55 @@ pub struct Person { rename = "$class", )] pub _class: String, - + #[serde( rename = "email", )] pub email: String, - + #[serde( rename = "firstName", )] pub first_name: String, - + #[serde( rename = "lastName", )] pub last_name: String, - + #[serde( rename = "middleNames", skip_serializing_if = "Option::is_none", )] pub middle_names: Option, - + #[serde( rename = "homeAddress", )] pub home_address: Address, - + #[serde( rename = "ssn", )] pub ssn: String, - + #[serde( rename = "height", )] pub height: f64, - + #[serde( rename = "dob", serialize_with = "serialize_datetime", deserialize_with = "deserialize_datetime", )] pub dob: DateTime, - + #[serde( rename = "nextOfKin", )] pub next_of_kin: NextOfKin, - + #[serde( rename = "$identifier", )] @@ -9857,93 +9927,93 @@ pub struct Employee { rename = "$class", )] pub _class: String, - + #[serde( rename = "employeeId", )] pub employee_id: String, - + #[serde( rename = "salary", )] pub salary: u64, - + #[serde( rename = "numDependents", )] pub num_dependents: Integer, - + #[serde( rename = "retired", )] pub retired: bool, - + #[serde( rename = "department", )] pub department: Department, - + #[serde( rename = "officeAddress", )] pub office_address: Address, - + #[serde( rename = "companyAssets", )] pub company_assets: Vec, - + #[serde(rename = "manager")] pub manager: Option, - + #[serde( rename = "email", )] pub email: String, - + #[serde( rename = "firstName", )] pub first_name: String, - + #[serde( rename = "lastName", )] pub last_name: String, - + #[serde( rename = "middleNames", skip_serializing_if = "Option::is_none", )] pub middle_names: Option, - + #[serde( rename = "homeAddress", )] pub home_address: Address, - + #[serde( rename = "ssn", )] pub ssn: String, - + #[serde( rename = "height", )] pub height: f64, - + #[serde( rename = "dob", serialize_with = "serialize_datetime", deserialize_with = "deserialize_datetime", )] pub dob: DateTime, - + #[serde( rename = "nextOfKin", )] pub next_of_kin: NextOfKin, - + #[serde( rename = "$identifier", )] @@ -9956,63 +10026,63 @@ pub struct Contractor { rename = "$class", )] pub _class: String, - + #[serde( rename = "company", )] pub company: Company, - + #[serde(rename = "manager")] pub manager: Option, - + #[serde( rename = "email", )] pub email: String, - + #[serde( rename = "firstName", )] pub first_name: String, - + #[serde( rename = "lastName", )] pub last_name: String, - + #[serde( rename = "middleNames", skip_serializing_if = "Option::is_none", )] pub middle_names: Option, - + #[serde( rename = "homeAddress", )] pub home_address: Address, - + #[serde( rename = "ssn", )] pub ssn: String, - + #[serde( rename = "height", )] pub height: f64, - + #[serde( rename = "dob", serialize_with = "serialize_datetime", deserialize_with = "deserialize_datetime", )] pub dob: DateTime, - + #[serde( rename = "nextOfKin", )] pub next_of_kin: NextOfKin, - + #[serde( rename = "$identifier", )] @@ -10025,96 +10095,96 @@ pub struct Manager { rename = "$class", )] pub _class: String, - + #[serde(rename = "reports")] pub reports: Option>, - + #[serde( rename = "employeeId", )] pub employee_id: String, - + #[serde( rename = "salary", )] pub salary: u64, - + #[serde( rename = "numDependents", )] pub num_dependents: Integer, - + #[serde( rename = "retired", )] pub retired: bool, - + #[serde( rename = "department", )] pub department: Department, - + #[serde( rename = "officeAddress", )] pub office_address: Address, - + #[serde( rename = "companyAssets", )] pub company_assets: Vec, - + #[serde(rename = "manager")] pub manager: Option, - + #[serde( rename = "email", )] pub email: String, - + #[serde( rename = "firstName", )] pub first_name: String, - + #[serde( rename = "lastName", )] pub last_name: String, - + #[serde( rename = "middleNames", skip_serializing_if = "Option::is_none", )] pub middle_names: Option, - + #[serde( rename = "homeAddress", )] pub home_address: Address, - + #[serde( rename = "ssn", )] pub ssn: String, - + #[serde( rename = "height", )] pub height: f64, - + #[serde( rename = "dob", serialize_with = "serialize_datetime", deserialize_with = "deserialize_datetime", )] pub dob: DateTime, - + #[serde( rename = "nextOfKin", )] pub next_of_kin: NextOfKin, - + #[serde( rename = "$identifier", )] @@ -10127,7 +10197,7 @@ pub struct CompanyEvent { rename = "$class", )] pub _class: String, - + #[serde( rename = "$timestamp", serialize_with = "serialize_datetime", @@ -10142,10 +10212,10 @@ pub struct Onboarded { rename = "$class", )] pub _class: String, - + #[serde(rename = "employee")] pub employee: Employee, - + #[serde( rename = "$timestamp", serialize_with = "serialize_datetime", @@ -10160,15 +10230,15 @@ pub struct ChangeOfAddress { rename = "$class", )] pub _class: String, - + #[serde(rename = "Person")] pub person: Person, - + #[serde( rename = "newAddress", )] pub new_address: Address, - + #[serde( rename = "$timestamp", serialize_with = "serialize_datetime", @@ -10226,7 +10296,7 @@ export interface IConcept { $class: string; } -export type ConceptUnion = IAddress | +export type ConceptUnion = IAddress | ICompany; export interface IAsset extends IConcept { @@ -10404,7 +10474,7 @@ export interface IPerson extends IParticipant { nextOfKin: NextOfKin; } -export type PersonUnion = IEmployee | +export type PersonUnion = IEmployee | IContractor; export interface IEmployee extends IPerson { @@ -10560,7 +10630,7 @@ exports[`codegen #formats check we can convert all formats from namespace versio { "key": "concerto@1.0.0.xsd", "value": " - @@ -10616,7 +10686,7 @@ exports[`codegen #formats check we can convert all formats from namespace versio { "key": "concerto.xsd", "value": " - @@ -10670,7 +10740,7 @@ exports[`codegen #formats check we can convert all formats from namespace versio { "key": "org.acme.hr.base@1.0.0.xsd", "value": " - @@ -10693,6 +10763,16 @@ xmlns:concerto="concerto" + + + + + + + + + + @@ -10716,12 +10796,72 @@ exports[`codegen #formats check we can convert all formats from namespace versio { "key": "org.acme.hr@1.0.0.xsd", "value": " - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 5e2dcc5dc5163f651dabc30eafb124310ba5df7b Mon Sep 17 00:00:00 2001 From: Jonathan Casey Date: Thu, 9 Nov 2023 15:23:55 +0000 Subject: [PATCH 08/20] feat(*): add type def Signed-off-by: Jonathan Casey --- types/lib/codegen/fromcto/golang/golangvisitor.d.ts | 7 ------- .../codegen/fromcto/xmlschema/xmlschemavisitor.d.ts | 10 ++++++++++ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/types/lib/codegen/fromcto/golang/golangvisitor.d.ts b/types/lib/codegen/fromcto/golang/golangvisitor.d.ts index 5f350707..f8588223 100644 --- a/types/lib/codegen/fromcto/golang/golangvisitor.d.ts +++ b/types/lib/codegen/fromcto/golang/golangvisitor.d.ts @@ -99,11 +99,4 @@ declare class GoLangVisitor { * @private */ private toGoPackageName; - /** - * Check if field is a Map Declaration - * @param {Field} field - the field being visited - * @return {boolean} true if field is a Map Declaration - * @private - */ - private isMap; } diff --git a/types/lib/codegen/fromcto/xmlschema/xmlschemavisitor.d.ts b/types/lib/codegen/fromcto/xmlschema/xmlschemavisitor.d.ts index 77f4b5b7..8b2d9454 100644 --- a/types/lib/codegen/fromcto/xmlschema/xmlschemavisitor.d.ts +++ b/types/lib/codegen/fromcto/xmlschema/xmlschemavisitor.d.ts @@ -42,6 +42,14 @@ declare class XmlSchemaVisitor { * @private */ private visitEnumDeclaration; + /** + * Visitor design pattern + * @param {MapDeclaration} mapDeclaration - the object being visited + * @param {Object} parameters - the parameter + * @return {Object} the result of visiting or null + * @private + */ + private visitMapDeclaration; /** * Visitor design pattern * @param {ClassDeclaration} classDeclaration - the object being visited @@ -85,6 +93,8 @@ declare class XmlSchemaVisitor { * Converts a Concerto type to a XML Schema type. Primitive types are converted * everything else is passed through unchanged. * @param {string} type - the fully qualified concerto type name + * @param {Object} mapElement - the mapElement representing either the Key or Value of a MapDeclaration + * @param {MapDeclaration} mapDeclaration - the object representing a MapDeclaration * @return {string} the corresponding type in XML Schema * @private */ From 3412f86027a7085443f63e93afe8265beed519f1 Mon Sep 17 00:00:00 2001 From: Jonathan Casey Date: Thu, 9 Nov 2023 16:48:54 +0000 Subject: [PATCH 09/20] feat(*): removes superflous tags, declares element Signed-off-by: Jonathan Casey --- lib/codegen/fromcto/xmlschema/xmlschemavisitor.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/lib/codegen/fromcto/xmlschema/xmlschemavisitor.js b/lib/codegen/fromcto/xmlschema/xmlschemavisitor.js index 1a6e9542..21f6ba72 100644 --- a/lib/codegen/fromcto/xmlschema/xmlschemavisitor.js +++ b/lib/codegen/fromcto/xmlschema/xmlschemavisitor.js @@ -167,15 +167,14 @@ class XmlSchemaVisitor { parameters.fileWriter.writeLine(0, `` ); parameters.fileWriter.writeLine(1, ''); - parameters.fileWriter.writeLine(2, ''); - parameters.fileWriter.writeLine(3, ''); - parameters.fileWriter.writeLine(4, ``); - parameters.fileWriter.writeLine(4, ``); - parameters.fileWriter.writeLine(3, ''); - parameters.fileWriter.writeLine(2, ''); + parameters.fileWriter.writeLine(2, ``); + parameters.fileWriter.writeLine(2, ``); parameters.fileWriter.writeLine(1, ''); parameters.fileWriter.writeLine(0, ''); + // declare the element + const { name: namespace } = ModelUtil.parseNamespace(mapDeclaration.getNamespace()); + parameters.fileWriter.writeLine(0, `` ); return null; } From 97f1b3f9ef9fafbffeb2a316fc9d491a3fcd982e Mon Sep 17 00:00:00 2001 From: Jonathan Casey Date: Thu, 9 Nov 2023 16:49:01 +0000 Subject: [PATCH 10/20] test(*): fix test regression Signed-off-by: Jonathan Casey --- .../fromcto/xmlschema/xmlschemavisitor.js | 86 +++++++------------ 1 file changed, 31 insertions(+), 55 deletions(-) diff --git a/test/codegen/fromcto/xmlschema/xmlschemavisitor.js b/test/codegen/fromcto/xmlschema/xmlschemavisitor.js index b9cf89aa..0f673c71 100644 --- a/test/codegen/fromcto/xmlschema/xmlschemavisitor.js +++ b/test/codegen/fromcto/xmlschema/xmlschemavisitor.js @@ -411,17 +411,13 @@ describe('XmlSchemaVisitor', function () { xmlSchemaVisitor.visitMapDeclaration(mockMapDeclaration, param); - param.fileWriter.writeLine.callCount.should.deep.equal(10); + param.fileWriter.writeLine.callCount.should.deep.equal(7); param.fileWriter.writeLine.getCall(0).args.should.deep.equal([0, '']); param.fileWriter.writeLine.getCall(1).args.should.deep.equal([1, '']); - param.fileWriter.writeLine.getCall(2).args.should.deep.equal([2, '']); - param.fileWriter.writeLine.getCall(3).args.should.deep.equal([3, '']); - param.fileWriter.writeLine.getCall(4).args.should.deep.equal([4, '']); - param.fileWriter.writeLine.getCall(5).args.should.deep.equal([4, '']); - param.fileWriter.writeLine.getCall(6).args.should.deep.equal([3, '']); - param.fileWriter.writeLine.getCall(7).args.should.deep.equal([2, '']); - param.fileWriter.writeLine.getCall(8).args.should.deep.equal([1, '']); - param.fileWriter.writeLine.getCall(9).args.should.deep.equal([0, '']); + param.fileWriter.writeLine.getCall(2).args.should.deep.equal([2, '']); + param.fileWriter.writeLine.getCall(3).args.should.deep.equal([2, '']); + param.fileWriter.writeLine.getCall(4).args.should.deep.equal([1, '']); + param.fileWriter.writeLine.getCall(5).args.should.deep.equal([0, '']); }); @@ -455,17 +451,13 @@ describe('XmlSchemaVisitor', function () { xmlSchemaVisitor.visitMapDeclaration(mockMapDeclaration, param); - param.fileWriter.writeLine.callCount.should.deep.equal(10); + param.fileWriter.writeLine.callCount.should.deep.equal(7); param.fileWriter.writeLine.getCall(0).args.should.deep.equal([0, '']); param.fileWriter.writeLine.getCall(1).args.should.deep.equal([1, '']); - param.fileWriter.writeLine.getCall(2).args.should.deep.equal([2, '']); - param.fileWriter.writeLine.getCall(3).args.should.deep.equal([3, '']); - param.fileWriter.writeLine.getCall(4).args.should.deep.equal([4, '']); - param.fileWriter.writeLine.getCall(5).args.should.deep.equal([4, '']); - param.fileWriter.writeLine.getCall(6).args.should.deep.equal([3, '']); - param.fileWriter.writeLine.getCall(7).args.should.deep.equal([2, '']); - param.fileWriter.writeLine.getCall(8).args.should.deep.equal([1, '']); - param.fileWriter.writeLine.getCall(9).args.should.deep.equal([0, '']); + param.fileWriter.writeLine.getCall(2).args.should.deep.equal([2, '']); + param.fileWriter.writeLine.getCall(3).args.should.deep.equal([2, '']); + param.fileWriter.writeLine.getCall(4).args.should.deep.equal([1, '']); + param.fileWriter.writeLine.getCall(5).args.should.deep.equal([0, '']); }); it('should write the map declaration for a map ', () => { @@ -496,17 +488,13 @@ describe('XmlSchemaVisitor', function () { xmlSchemaVisitor.visitMapDeclaration(mockMapDeclaration, param); - param.fileWriter.writeLine.callCount.should.deep.equal(10); + param.fileWriter.writeLine.callCount.should.deep.equal(7); param.fileWriter.writeLine.getCall(0).args.should.deep.equal([0, '']); param.fileWriter.writeLine.getCall(1).args.should.deep.equal([1, '']); - param.fileWriter.writeLine.getCall(2).args.should.deep.equal([2, '']); - param.fileWriter.writeLine.getCall(3).args.should.deep.equal([3, '']); - param.fileWriter.writeLine.getCall(4).args.should.deep.equal([4, '']); - param.fileWriter.writeLine.getCall(5).args.should.deep.equal([4, '']); - param.fileWriter.writeLine.getCall(6).args.should.deep.equal([3, '']); - param.fileWriter.writeLine.getCall(7).args.should.deep.equal([2, '']); - param.fileWriter.writeLine.getCall(8).args.should.deep.equal([1, '']); - param.fileWriter.writeLine.getCall(9).args.should.deep.equal([0, '']); + param.fileWriter.writeLine.getCall(2).args.should.deep.equal([2, '']); + param.fileWriter.writeLine.getCall(3).args.should.deep.equal([2, '']); + param.fileWriter.writeLine.getCall(4).args.should.deep.equal([1, '']); + param.fileWriter.writeLine.getCall(5).args.should.deep.equal([0, '']); }); @@ -536,17 +524,13 @@ describe('XmlSchemaVisitor', function () { xmlSchemaVisitor.visitMapDeclaration(mockMapDeclaration, param); - param.fileWriter.writeLine.callCount.should.deep.equal(10); + param.fileWriter.writeLine.callCount.should.deep.equal(7); param.fileWriter.writeLine.getCall(0).args.should.deep.equal([0, '']); param.fileWriter.writeLine.getCall(1).args.should.deep.equal([1, '']); - param.fileWriter.writeLine.getCall(2).args.should.deep.equal([2, '']); - param.fileWriter.writeLine.getCall(3).args.should.deep.equal([3, '']); - param.fileWriter.writeLine.getCall(4).args.should.deep.equal([4, '']); - param.fileWriter.writeLine.getCall(5).args.should.deep.equal([4, '']); - param.fileWriter.writeLine.getCall(6).args.should.deep.equal([3, '']); - param.fileWriter.writeLine.getCall(7).args.should.deep.equal([2, '']); - param.fileWriter.writeLine.getCall(8).args.should.deep.equal([1, '']); - param.fileWriter.writeLine.getCall(9).args.should.deep.equal([0, '']); + param.fileWriter.writeLine.getCall(2).args.should.deep.equal([2, '']); + param.fileWriter.writeLine.getCall(3).args.should.deep.equal([2, '']); + param.fileWriter.writeLine.getCall(4).args.should.deep.equal([1, '']); + param.fileWriter.writeLine.getCall(5).args.should.deep.equal([0, '']); }); it('should write the map declaration for a map ', () => { @@ -576,17 +560,13 @@ describe('XmlSchemaVisitor', function () { xmlSchemaVisitor.visitMapDeclaration(mockMapDeclaration, param); - param.fileWriter.writeLine.callCount.should.deep.equal(10); + param.fileWriter.writeLine.callCount.should.deep.equal(7); param.fileWriter.writeLine.getCall(0).args.should.deep.equal([0, '']); param.fileWriter.writeLine.getCall(1).args.should.deep.equal([1, '']); - param.fileWriter.writeLine.getCall(2).args.should.deep.equal([2, '']); - param.fileWriter.writeLine.getCall(3).args.should.deep.equal([3, '']); - param.fileWriter.writeLine.getCall(4).args.should.deep.equal([4, '']); - param.fileWriter.writeLine.getCall(5).args.should.deep.equal([4, '']); - param.fileWriter.writeLine.getCall(6).args.should.deep.equal([3, '']); - param.fileWriter.writeLine.getCall(7).args.should.deep.equal([2, '']); - param.fileWriter.writeLine.getCall(8).args.should.deep.equal([1, '']); - param.fileWriter.writeLine.getCall(9).args.should.deep.equal([0, '']); + param.fileWriter.writeLine.getCall(2).args.should.deep.equal([2, '']); + param.fileWriter.writeLine.getCall(3).args.should.deep.equal([2, '']); + param.fileWriter.writeLine.getCall(4).args.should.deep.equal([1, '']); + param.fileWriter.writeLine.getCall(5).args.should.deep.equal([0, '']); }); it('should write the map declaration for a map ', () => { @@ -616,17 +596,13 @@ describe('XmlSchemaVisitor', function () { xmlSchemaVisitor.visitMapDeclaration(mockMapDeclaration, param); - param.fileWriter.writeLine.callCount.should.deep.equal(10); + param.fileWriter.writeLine.callCount.should.deep.equal(7); param.fileWriter.writeLine.getCall(0).args.should.deep.equal([0, '']); param.fileWriter.writeLine.getCall(1).args.should.deep.equal([1, '']); - param.fileWriter.writeLine.getCall(2).args.should.deep.equal([2, '']); - param.fileWriter.writeLine.getCall(3).args.should.deep.equal([3, '']); - param.fileWriter.writeLine.getCall(4).args.should.deep.equal([4, '']); - param.fileWriter.writeLine.getCall(5).args.should.deep.equal([4, '']); - param.fileWriter.writeLine.getCall(6).args.should.deep.equal([3, '']); - param.fileWriter.writeLine.getCall(7).args.should.deep.equal([2, '']); - param.fileWriter.writeLine.getCall(8).args.should.deep.equal([1, '']); - param.fileWriter.writeLine.getCall(9).args.should.deep.equal([0, '']); + param.fileWriter.writeLine.getCall(2).args.should.deep.equal([2, '']); + param.fileWriter.writeLine.getCall(3).args.should.deep.equal([2, '']); + param.fileWriter.writeLine.getCall(4).args.should.deep.equal([1, '']); + param.fileWriter.writeLine.getCall(5).args.should.deep.equal([0, '']); }); }); @@ -794,4 +770,4 @@ describe('XmlSchemaVisitor', function () { param.fileWriter.writeLine.withArgs(1, '+ string Bob'); }); }); -}); \ No newline at end of file +}); From 63d37c737cf9b82b3c16f210cc6cfbcfd7376d16 Mon Sep 17 00:00:00 2001 From: Jonathan Casey Date: Thu, 9 Nov 2023 16:49:11 +0000 Subject: [PATCH 11/20] test(*): update snapshot Signed-off-by: Jonathan Casey --- test/codegen/__snapshots__/codegen.js.snap | 126 +++++++-------------- 1 file changed, 42 insertions(+), 84 deletions(-) diff --git a/test/codegen/__snapshots__/codegen.js.snap b/test/codegen/__snapshots__/codegen.js.snap index cc7052d8..d2266d94 100644 --- a/test/codegen/__snapshots__/codegen.js.snap +++ b/test/codegen/__snapshots__/codegen.js.snap @@ -5111,14 +5111,11 @@ xmlns:concerto="concerto" - - - - - - + + + @@ -5150,64 +5147,46 @@ xmlns:concerto="concerto" - - - - - - + + + - - - - - - + + + - - - - - - + + + - - - - - - + + + - - - - - - + + + - - - - - - + + + @@ -10765,14 +10744,11 @@ xmlns:concerto="concerto" - - - - - - + + + @@ -10804,64 +10780,46 @@ xmlns:concerto="concerto" - - - - - - + + + - - - - - - + + + - - - - - - + + + - - - - - - + + + - - - - - - + + + - - - - - - + + + From 74ce780015da23d7f242e7b3fc2a60ccf912c0b3 Mon Sep 17 00:00:00 2001 From: Jonathan Casey Date: Thu, 9 Nov 2023 21:11:53 +0000 Subject: [PATCH 12/20] feat(*): get type from model file Signed-off-by: Jonathan Casey --- lib/codegen/fromcto/xmlschema/xmlschemavisitor.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/codegen/fromcto/xmlschema/xmlschemavisitor.js b/lib/codegen/fromcto/xmlschema/xmlschemavisitor.js index 21f6ba72..9f751050 100644 --- a/lib/codegen/fromcto/xmlschema/xmlschemavisitor.js +++ b/lib/codegen/fromcto/xmlschema/xmlschemavisitor.js @@ -303,8 +303,8 @@ class XmlSchemaVisitor { return 'xs:integer'; default: if(!ModelUtil.getNamespace(type)) { - const typeDeclaration = mapDeclaration.getModelFile().getAllDeclarations().find(d => d.name === type); - if (typeDeclaration?.isClassDeclaration?.() ) { + const typeDeclaration = mapDeclaration.getModelFile().getType(type); + if (typeDeclaration?.isClassDeclaration?.()) { return `${ModelUtil.parseNamespace(mapDeclaration.getModelFile().getNamespace()).name}:${mapElement.getType()}`; } else if (typeDeclaration?.isScalarDeclaration?.()) { return this.toXsType(typeDeclaration.getType()); From 7619ed63c1367dd2a2cb2e6258e28158f0fc640d Mon Sep 17 00:00:00 2001 From: Jonathan Casey Date: Fri, 10 Nov 2023 10:42:21 +0000 Subject: [PATCH 13/20] test(*): fix test regression Signed-off-by: Jonathan Casey --- .../fromcto/xmlschema/xmlschemavisitor.js | 29 ++++++++++++------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/test/codegen/fromcto/xmlschema/xmlschemavisitor.js b/test/codegen/fromcto/xmlschema/xmlschemavisitor.js index 0f673c71..54e11797 100644 --- a/test/codegen/fromcto/xmlschema/xmlschemavisitor.js +++ b/test/codegen/fromcto/xmlschema/xmlschemavisitor.js @@ -428,18 +428,19 @@ describe('XmlSchemaVisitor', function () { }; const mockMapDeclaration = sinon.createStubInstance(MapDeclaration); - const getAllDeclarations = sinon.stub(); + const mockDeclaration = sinon.createStubInstance(ClassDeclaration); const isScalarDeclaration = sinon.stub(); - const findStub = sinon.stub(); const getKeyType = sinon.stub(); const getValueType = sinon.stub(); + const getType = sinon.stub(); const getScalarType = sinon.stub(); - getAllDeclarations.returns({ find: findStub }); - mockMapDeclaration.getModelFile.returns({ getAllDeclarations: getAllDeclarations}); - mockMapDeclaration.isScalarDeclaration.returns(true); + mockMapDeclaration.getModelFile.returns({ getType: getType}); - findStub.returns(mockMapDeclaration); + getType.returns(mockDeclaration); + mockDeclaration.isClassDeclaration.returns(false); + mockDeclaration.isScalarDeclaration.returns(true); + mockDeclaration.getType.returns('String'); getKeyType.returns('String'); getValueType.returns('SSN'); getScalarType.returns('String'); @@ -466,19 +467,25 @@ describe('XmlSchemaVisitor', function () { fileWriter: mockFileWriter }; + sinon.stub(ModelUtil, 'getNamespace').callsFake(() => { + return {name:'org.acme'}; + }); + const mockMapDeclaration = sinon.createStubInstance(MapDeclaration); - const findStub = sinon.stub(); - const getAllDeclarations = sinon.stub(); + const mockDeclaration = sinon.createStubInstance(ClassDeclaration); const isClassDeclaration = sinon.stub(); const getNamespaceStub = sinon.stub(); const getKeyType = sinon.stub(); const getValueType = sinon.stub(); + const getType = sinon.stub(); - getAllDeclarations.returns({ find: findStub }); + mockMapDeclaration.getModelFile.returns({ getType: getType}); + getType.returns(mockDeclaration); + mockDeclaration.isClassDeclaration.returns(true); + mockDeclaration.isScalarDeclaration.returns(false); + mockDeclaration.getType.returns('Person'); getNamespaceStub.returns(''); - mockMapDeclaration.getModelFile.returns({ getAllDeclarations: getAllDeclarations, getNamespace: getNamespaceStub}); mockMapDeclaration.isClassDeclaration.returns(true); - findStub.returns(mockMapDeclaration); getKeyType.returns('String'); getValueType.returns('Person'); isClassDeclaration.returns(true); From ce647a10507230614f5568cfc9df2c9e3a41a680 Mon Sep 17 00:00:00 2001 From: Jonathan Casey Date: Fri, 10 Nov 2023 10:42:28 +0000 Subject: [PATCH 14/20] test(*): update snapshot Signed-off-by: Jonathan Casey --- test/codegen/__snapshots__/codegen.js.snap | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/test/codegen/__snapshots__/codegen.js.snap b/test/codegen/__snapshots__/codegen.js.snap index d2266d94..35c8d7ed 100644 --- a/test/codegen/__snapshots__/codegen.js.snap +++ b/test/codegen/__snapshots__/codegen.js.snap @@ -5155,14 +5155,14 @@ xmlns:concerto="concerto" - + - + @@ -5176,13 +5176,13 @@ xmlns:concerto="concerto" - + - + @@ -10788,14 +10788,14 @@ xmlns:concerto="concerto" - + - + @@ -10809,13 +10809,13 @@ xmlns:concerto="concerto" - + - + From 7dd8d4f52de291370692224a498ca1e9ea472060 Mon Sep 17 00:00:00 2001 From: Jonathan Casey Date: Fri, 10 Nov 2023 14:02:30 +0000 Subject: [PATCH 15/20] test(*): fix tests Signed-off-by: Jonathan Casey --- .../fromcto/xmlschema/xmlschemavisitor.js | 37 ++++--------------- 1 file changed, 7 insertions(+), 30 deletions(-) diff --git a/test/codegen/fromcto/xmlschema/xmlschemavisitor.js b/test/codegen/fromcto/xmlschema/xmlschemavisitor.js index 54e11797..c43844fc 100644 --- a/test/codegen/fromcto/xmlschema/xmlschemavisitor.js +++ b/test/codegen/fromcto/xmlschema/xmlschemavisitor.js @@ -30,6 +30,7 @@ const ModelManager = require('@accordproject/concerto-core').ModelManager; const RelationshipDeclaration = require('@accordproject/concerto-core').RelationshipDeclaration; const FileWriter = require('@accordproject/concerto-util').FileWriter; const ModelUtil = require('@accordproject/concerto-core').ModelUtil; +let sandbox = sinon.createSandbox(); describe('XmlSchemaVisitor', function () { let xmlSchemaVisitor; @@ -383,11 +384,15 @@ describe('XmlSchemaVisitor', function () { describe('visitMapDeclaration', () => { before(() => { - sinon.stub(ModelUtil, 'parseNamespace').callsFake(() => { + sandbox.stub(ModelUtil, 'parseNamespace').callsFake(() => { return {name:'org.acme'}; }); }); + after(() => { + sandbox.restore(); + }); + it('should write the map declaration for a map ', () => { let param = { @@ -422,7 +427,6 @@ describe('XmlSchemaVisitor', function () { it('should write the map declaration for a map ', () => { - let param = { fileWriter: mockFileWriter }; @@ -436,7 +440,6 @@ describe('XmlSchemaVisitor', function () { const getScalarType = sinon.stub(); mockMapDeclaration.getModelFile.returns({ getType: getType}); - getType.returns(mockDeclaration); mockDeclaration.isClassDeclaration.returns(false); mockDeclaration.isScalarDeclaration.returns(true); @@ -446,7 +449,6 @@ describe('XmlSchemaVisitor', function () { getScalarType.returns('String'); mockMapDeclaration.getName.returns('Map1'); mockMapDeclaration.getKey.returns({ getType: getKeyType }); - mockMapDeclaration.getType.returns('String'); mockMapDeclaration.getValue.returns({ getType: getValueType }); isScalarDeclaration.returns(true); @@ -467,7 +469,7 @@ describe('XmlSchemaVisitor', function () { fileWriter: mockFileWriter }; - sinon.stub(ModelUtil, 'getNamespace').callsFake(() => { + sandbox.stub(ModelUtil, 'getNamespace').callsFake(() => { return {name:'org.acme'}; }); @@ -502,7 +504,6 @@ describe('XmlSchemaVisitor', function () { param.fileWriter.writeLine.getCall(3).args.should.deep.equal([2, '']); param.fileWriter.writeLine.getCall(4).args.should.deep.equal([1, '']); param.fileWriter.writeLine.getCall(5).args.should.deep.equal([0, '']); - }); it('should write the map declaration for a map ', () => { @@ -511,20 +512,12 @@ describe('XmlSchemaVisitor', function () { fileWriter: mockFileWriter }; - const findStub = sinon.stub(); - const getAllDeclarations = sinon.stub(); - const isClassDeclaration = sinon.stub(); const getKeyType = sinon.stub(); const getValueType = sinon.stub(); const mockMapDeclaration = sinon.createStubInstance(MapDeclaration); - getAllDeclarations.returns({ find: findStub }); - mockMapDeclaration.getModelFile.returns({ getAllDeclarations: getAllDeclarations}); - mockMapDeclaration.isClassDeclaration.returns(true); - findStub.returns(mockMapDeclaration); getKeyType.returns('String'); getValueType.returns('Long'); - isClassDeclaration.returns(true); mockMapDeclaration.getName.returns('Map1'); mockMapDeclaration.getKey.returns({ getType: getKeyType }); mockMapDeclaration.getValue.returns({ getType: getValueType }); @@ -546,21 +539,12 @@ describe('XmlSchemaVisitor', function () { fileWriter: mockFileWriter }; - const findStub = sinon.stub(); - const getAllDeclarations = sinon.stub(); - const isClassDeclaration = sinon.stub(); const getKeyType = sinon.stub(); const getValueType = sinon.stub(); const mockMapDeclaration = sinon.createStubInstance(MapDeclaration); - getAllDeclarations.returns({ find: findStub }); - - mockMapDeclaration.getModelFile.returns({ getAllDeclarations: getAllDeclarations}); - mockMapDeclaration.isClassDeclaration.returns(true); - findStub.returns(mockMapDeclaration); getKeyType.returns('String'); getValueType.returns('Double'); - isClassDeclaration.returns(true); mockMapDeclaration.getName.returns('Map1'); mockMapDeclaration.getKey.returns({ getType: getKeyType }); mockMapDeclaration.getValue.returns({ getType: getValueType }); @@ -582,18 +566,11 @@ describe('XmlSchemaVisitor', function () { fileWriter: mockFileWriter }; - const findStub = sinon.stub(); - const getAllDeclarations = sinon.stub(); const isClassDeclaration = sinon.stub(); const getKeyType = sinon.stub(); const getValueType = sinon.stub(); const mockMapDeclaration = sinon.createStubInstance(MapDeclaration); - - getAllDeclarations.returns({ find: findStub }); - mockMapDeclaration.getModelFile.returns({ getAllDeclarations: getAllDeclarations}); - mockMapDeclaration.isClassDeclaration.returns(true); - findStub.returns(mockMapDeclaration); getKeyType.returns('String'); getValueType.returns('Integer'); isClassDeclaration.returns(true); From 435a37f7573ab82210aa8dbf3217e40e06c7e878 Mon Sep 17 00:00:00 2001 From: Jonathan-Casey <109082377+Jonathan-Casey@users.noreply.github.com> Date: Mon, 13 Nov 2023 19:43:35 +0000 Subject: [PATCH 16/20] feat(map): Extend supported Key Types for Typescript codegen (#70) * feat(*): keys are variable typed Signed-off-by: Jonathan Casey * test(*): update test Signed-off-by: Jonathan Casey * test(*): update snapshot Signed-off-by: Jonathan Casey * test(*): adds scalar test coverage Signed-off-by: Jonathan Casey * feat(*): minor refactor, update tests Signed-off-by: Jonathan Casey * test(*): update snapshot Signed-off-by: Jonathan Casey --------- Signed-off-by: Jonathan Casey --- .../fromcto/typescript/typescriptvisitor.js | 35 +++-- test/codegen/__snapshots__/codegen.js.snap | 20 ++- test/codegen/fromcto/data/model/hr.cto | 2 +- .../fromcto/typescript/typescriptvisitor.js | 128 ++++++++++++++++-- 4 files changed, 151 insertions(+), 34 deletions(-) diff --git a/lib/codegen/fromcto/typescript/typescriptvisitor.js b/lib/codegen/fromcto/typescript/typescriptvisitor.js index fc001537..2e7d516b 100644 --- a/lib/codegen/fromcto/typescript/typescriptvisitor.js +++ b/lib/codegen/fromcto/typescript/typescriptvisitor.js @@ -281,24 +281,33 @@ class TypescriptVisitor { * @private */ visitMapDeclaration(mapDeclaration, parameters) { - // const keyType = mapDeclaration.getKey().getType(); // for now, key is always string. - let valueType = mapDeclaration.getValue().getType(); - - const isScalar = ModelUtil.isScalar(mapDeclaration.getValue()); - const isPrimitive = ModelUtil.isPrimitiveType(mapDeclaration.getValue().getType()); + const mapKeyType = mapDeclaration.getKey().getType(); + const mapValueType = mapDeclaration.getValue().getType(); + + let keyType; + let valueType; + + // Map Key Type + if (ModelUtil.isPrimitiveType(mapKeyType)) { + keyType = this.toTsType(mapDeclaration.getKey().getType(), false, false); + } else if (ModelUtil.isScalar(mapDeclaration.getKey())) { + const scalarDeclaration = mapDeclaration.getModelFile().getType(mapDeclaration.getKey().getType()); + const scalarType = scalarDeclaration.getType(); + keyType = this.toTsType(scalarType, false, false); + } - if (isScalar) { - const scalar = mapDeclaration.getModelFile(mapDeclaration.getValue().getType()); - const scalarType = scalar.getType(); - valueType = this.toTsType(scalarType, false, false); - } else if (isPrimitive) { + // Map Value Type + if (ModelUtil.isPrimitiveType(mapValueType)) { valueType = this.toTsType(mapDeclaration.getValue().getType(), false, false); + } else if (ModelUtil.isScalar(mapDeclaration.getValue())) { + const scalarDeclaration = mapDeclaration.getModelFile().getType(mapDeclaration.getValue().getType()); + const scalarType = scalarDeclaration.getType(); + valueType = this.toTsType(scalarType, false, false); } else { - valueType = this.toTsType(valueType, true, false); - + valueType = this.toTsType(mapValueType, true, false); } - parameters.fileWriter.writeLine(0, 'export type ' + mapDeclaration.getName() + ` = Map;\n` ); + parameters.fileWriter.writeLine(0, 'export type ' + mapDeclaration.getName() + ` = Map<${keyType}, ${valueType}>;\n` ); return null; } diff --git a/test/codegen/__snapshots__/codegen.js.snap b/test/codegen/__snapshots__/codegen.js.snap index 3a3846ab..37ad1bb4 100644 --- a/test/codegen/__snapshots__/codegen.js.snap +++ b/test/codegen/__snapshots__/codegen.js.snap @@ -628,7 +628,7 @@ type Person struct { Ssn string \`json:"ssn"\` Height float64 \`json:"height"\` Dob time.Time \`json:"dob"\` - nextOfKin := make(map[string]time.Time) \`json:"nextOfKin"\` + nextOfKin := make(map[string]string) \`json:"nextOfKin"\` } type Employee struct { Person @@ -2141,7 +2141,6 @@ exports[`codegen #formats check we can convert all formats from namespace unvers "type": "string" }, "org.acme.hr.KinTelephone": { - "format": "date-time", "type": "string" } } @@ -3260,7 +3259,6 @@ exports[`codegen #formats check we can convert all formats from namespace unvers "type": "string" }, "org.acme.hr.KinTelephone": { - "format": "date-time", "type": "string" } } @@ -4764,11 +4762,11 @@ import {IConcept,IAsset,IParticipant,IEvent,ITransaction} from './concerto@1.0.0 // interfaces export type CompanyProperties = Map; -export type EmployeeLoginTimes = Map; +export type EmployeeLoginTimes = Map; -export type EmployeeSocialSecurityNumbers = Map; +export type EmployeeSocialSecurityNumbers = Map; -export type NextOfKin = Map; +export type NextOfKin = Map; export type EmployeeProfiles = Map; @@ -6229,7 +6227,7 @@ type Person struct { Ssn string \`json:"ssn"\` Height float64 \`json:"height"\` Dob time.Time \`json:"dob"\` - nextOfKin := make(map[string]time.Time) \`json:"nextOfKin"\` + nextOfKin := make(map[string]string) \`json:"nextOfKin"\` } type Employee struct { Person @@ -7742,7 +7740,6 @@ exports[`codegen #formats check we can convert all formats from namespace versio "type": "string" }, "org.acme.hr@1.0.0.KinTelephone": { - "format": "date-time", "type": "string" } } @@ -8877,7 +8874,6 @@ exports[`codegen #formats check we can convert all formats from namespace versio "type": "string" }, "org.acme.hr@1.0.0.KinTelephone": { - "format": "date-time", "type": "string" } } @@ -10397,11 +10393,11 @@ import {IConcept,IAsset,IParticipant,IEvent,ITransaction} from './concerto@1.0.0 // interfaces export type CompanyProperties = Map; -export type EmployeeLoginTimes = Map; +export type EmployeeLoginTimes = Map; -export type EmployeeSocialSecurityNumbers = Map; +export type EmployeeSocialSecurityNumbers = Map; -export type NextOfKin = Map; +export type NextOfKin = Map; export type EmployeeProfiles = Map; diff --git a/test/codegen/fromcto/data/model/hr.cto b/test/codegen/fromcto/data/model/hr.cto index cabf4d71..e121ab57 100644 --- a/test/codegen/fromcto/data/model/hr.cto +++ b/test/codegen/fromcto/data/model/hr.cto @@ -111,4 +111,4 @@ transaction ChangeOfAddress { } scalar KinName extends String -scalar KinTelephone extends DateTime +scalar KinTelephone extends String diff --git a/test/codegen/fromcto/typescript/typescriptvisitor.js b/test/codegen/fromcto/typescript/typescriptvisitor.js index 610ad6bb..3d772097 100644 --- a/test/codegen/fromcto/typescript/typescriptvisitor.js +++ b/test/codegen/fromcto/typescript/typescriptvisitor.js @@ -19,7 +19,7 @@ chai.should(); const sinon = require('sinon'); const TypescriptVisitor = require('../../../../lib/codegen/fromcto/typescript/typescriptvisitor.js'); -const { MapDeclaration, ModelUtil } = require('@accordproject/concerto-core'); +const { MapDeclaration, MapKeyType, ModelUtil, ScalarDeclaration } = require('@accordproject/concerto-core'); const ClassDeclaration = require('@accordproject/concerto-core').ClassDeclaration; const EnumDeclaration = require('@accordproject/concerto-core').EnumDeclaration; @@ -29,6 +29,7 @@ const ModelFile = require('@accordproject/concerto-core').ModelFile; const ModelManager = require('@accordproject/concerto-core').ModelManager; const RelationshipDeclaration = require('@accordproject/concerto-core').RelationshipDeclaration; const FileWriter = require('@accordproject/concerto-util').FileWriter; +let sandbox = sinon.createSandbox(); describe('TypescriptVisitor', function () { let typescriptVisitor; @@ -642,20 +643,27 @@ describe('TypescriptVisitor', function () { }); describe('visitMapValueDeclaration', () => { + + before(() => { + sandbox.stub(ModelUtil, 'isScalar').callsFake(() => { + return false; + }); + }); + it('should write a line with the name, key and value of the map ', () => { let param = { fileWriter: mockFileWriter }; + sandbox.stub(ModelUtil, 'isPrimitiveType').callsFake(() => { + return true; + }); + let mockMapDeclaration = sinon.createStubInstance(MapDeclaration); const getKeyType = sinon.stub(); const getValueType = sinon.stub(); - sinon.stub(ModelUtil, 'isScalar').callsFake(() => { - return false; - }); - getKeyType.returns('String'); getValueType.returns('String'); mockMapDeclaration.getName.returns('Map1'); @@ -695,16 +703,22 @@ describe('TypescriptVisitor', function () { fileWriter: mockFileWriter }; + sandbox.restore(); + sandbox.stub(ModelUtil, 'isScalar').callsFake(() => { + return false; + }); let mockMapDeclaration = sinon.createStubInstance(MapDeclaration); + let mockMapKeyType = sinon.createStubInstance(MapKeyType); const getKeyType = sinon.stub(); const getValueType = sinon.stub(); + mockMapKeyType.getType.returns('String'); getKeyType.returns('String'); getValueType.returns('Address'); mockMapDeclaration.getName.returns('Map1'); mockMapDeclaration.isMapDeclaration.returns(true); - mockMapDeclaration.getKey.returns({ getType: getKeyType }); + mockMapDeclaration.getKey.returns(mockMapKeyType); mockMapDeclaration.getValue.returns({ getType: getValueType }); typescriptVisitor.visitMapDeclaration(mockMapDeclaration, param); @@ -717,21 +731,119 @@ describe('TypescriptVisitor', function () { fileWriter: mockFileWriter }; + sandbox.restore(); + sandbox.stub(ModelUtil, 'isScalar').callsFake(() => { + return false; + }); let mockMapDeclaration = sinon.createStubInstance(MapDeclaration); + let mockMapKeyType = sinon.createStubInstance(MapKeyType); const getKeyType = sinon.stub(); const getValueType = sinon.stub(); - getKeyType.returns('String'); + mockMapKeyType.getType.returns('DateTime'); + getKeyType.returns('DateTime'); getValueType.returns('Address'); mockMapDeclaration.getName.returns('Map1'); mockMapDeclaration.isMapDeclaration.returns(true); + mockMapDeclaration.getKey.returns(mockMapKeyType); + mockMapDeclaration.getValue.returns({ getType: getValueType }); + + typescriptVisitor.visitMapDeclaration(mockMapDeclaration, param); + + param.fileWriter.writeLine.withArgs(0, 'export type Map1 = Map;\n').calledOnce.should.be.ok; + }); + + it('should write a line with the name, key and value of the map ', () => { + let param = { + fileWriter: mockFileWriter + }; + sandbox.restore(); + sandbox.stub(ModelUtil, 'isScalar').callsFake(() => { + return false; + }); + + let mockMapDeclaration = sinon.createStubInstance(MapDeclaration); + + const getKeyType = sinon.stub(); + const getValueType = sinon.stub(); + + getKeyType.returns('String'); + getValueType.returns('Concept'); + mockMapDeclaration.getName.returns('Map1'); + mockMapDeclaration.isMapDeclaration.returns(true); mockMapDeclaration.getKey.returns({ getType: getKeyType }); mockMapDeclaration.getValue.returns({ getType: getValueType }); typescriptVisitor.visitMapDeclaration(mockMapDeclaration, param); - param.fileWriter.writeLine.withArgs(0, 'export type Map1 = Map;\n').calledOnce.should.be.ok; + param.fileWriter.writeLine.withArgs(0, 'export type Map1 = Map;\n').calledOnce.should.be.ok; + }); + + it('should write a line with the name, key and value of the map ', () => { + let param = { + fileWriter: mockFileWriter + }; + + sandbox.restore(); + sandbox.stub(ModelUtil, 'isScalar').callsFake(() => { + return true; + }); + + let mockMapDeclaration = sinon.createStubInstance(MapDeclaration); + let mockScalarDeclaration = sinon.createStubInstance(ScalarDeclaration); + const mockModelFile = sinon.createStubInstance(ModelFile); + + mockModelFile.getType.returns(ScalarDeclaration); + const getKeyType = sinon.stub(); + const getValueType = sinon.stub(); + + mockModelFile.getType.returns(mockScalarDeclaration); + mockScalarDeclaration.getType.returns('String'); + getKeyType.returns('SSN'); + getValueType.returns('String'); + mockMapDeclaration.getModelFile.returns(mockModelFile); + mockMapDeclaration.getName.returns('Map1'); + mockMapDeclaration.isMapDeclaration.returns(true); + mockMapDeclaration.getKey.returns({ getType: getKeyType }); + mockMapDeclaration.getValue.returns({ getType: getValueType }); + + typescriptVisitor.visitMapDeclaration(mockMapDeclaration, param); + + param.fileWriter.writeLine.withArgs(0, 'export type Map1 = Map;\n').calledOnce.should.be.ok; + }); + + it('should write a line with the name, key and value of the map ', () => { + let param = { + fileWriter: mockFileWriter + }; + + sandbox.restore(); + sandbox.stub(ModelUtil, 'isScalar').callsFake(() => { + return true; + }); + + let mockMapDeclaration = sinon.createStubInstance(MapDeclaration); + let mockScalarDeclaration = sinon.createStubInstance(ScalarDeclaration); + const mockModelFile = sinon.createStubInstance(ModelFile); + + mockModelFile.getType.returns(ScalarDeclaration); + const getKeyType = sinon.stub(); + const getValueType = sinon.stub(); + + mockModelFile.getType.returns(mockScalarDeclaration); + mockScalarDeclaration.getType.returns('String'); + getKeyType.returns('string'); + getValueType.returns('SSN'); + mockMapDeclaration.getModelFile.returns(mockModelFile); + mockMapDeclaration.getName.returns('Map1'); + mockMapDeclaration.isMapDeclaration.returns(true); + mockMapDeclaration.getKey.returns({ getType: getKeyType }); + mockMapDeclaration.getValue.returns({ getType: getValueType }); + + typescriptVisitor.visitMapDeclaration(mockMapDeclaration, param); + + param.fileWriter.writeLine.withArgs(0, 'export type Map1 = Map;\n').calledOnce.should.be.ok; }); }); From 6b5eecb09bf72a2671fa1635ece615089552c750 Mon Sep 17 00:00:00 2001 From: Jonathan Casey Date: Tue, 14 Nov 2023 16:44:19 +0000 Subject: [PATCH 17/20] test(*): snapshot update Signed-off-by: Jonathan Casey --- test/codegen/__snapshots__/codegen.js.snap | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/codegen/__snapshots__/codegen.js.snap b/test/codegen/__snapshots__/codegen.js.snap index 37ad1bb4..68a70a11 100644 --- a/test/codegen/__snapshots__/codegen.js.snap +++ b/test/codegen/__snapshots__/codegen.js.snap @@ -5167,7 +5167,7 @@ xmlns:concerto="concerto" - + @@ -10798,7 +10798,7 @@ xmlns:concerto="concerto" - + From 025d948fe8f6a6bec3cf02d87c510a674844bbba Mon Sep 17 00:00:00 2001 From: Jonathan Casey Date: Wed, 15 Nov 2023 15:34:33 +0000 Subject: [PATCH 18/20] feat(*): update xsd and test cov Signed-off-by: Jonathan Casey --- .../fromcto/xmlschema/xmlschemavisitor.js | 23 ++- test/codegen/__snapshots__/codegen.js.snap | 144 +++++++++++---- .../fromcto/xmlschema/xmlschemavisitor.js | 167 +++++++++++++----- 3 files changed, 251 insertions(+), 83 deletions(-) diff --git a/lib/codegen/fromcto/xmlschema/xmlschemavisitor.js b/lib/codegen/fromcto/xmlschema/xmlschemavisitor.js index 9f751050..3b190b09 100644 --- a/lib/codegen/fromcto/xmlschema/xmlschemavisitor.js +++ b/lib/codegen/fromcto/xmlschema/xmlschemavisitor.js @@ -162,19 +162,26 @@ class XmlSchemaVisitor { */ visitMapDeclaration(mapDeclaration, parameters) { - const key = this.toXsType(mapDeclaration.getKey().getType(), mapDeclaration.getKey(), mapDeclaration); + const key = this.toXsType(mapDeclaration.getKey().getType(), mapDeclaration.getKey(), mapDeclaration); const value = this.toXsType(mapDeclaration.getValue().getType(), mapDeclaration.getValue(), mapDeclaration); - parameters.fileWriter.writeLine(0, `` ); + // write the element representing the MapDeclaration + parameters.fileWriter.writeLine(0, `` ); + parameters.fileWriter.writeLine(0, '' ); + parameters.fileWriter.writeLine(1, ''); + parameters.fileWriter.writeLine(2, ``); + parameters.fileWriter.writeLine(1, ''); + parameters.fileWriter.writeLine(0, ''); + parameters.fileWriter.writeLine(0, ''); + + // write the Entry type reprenting the schema of the MapDeclaration + parameters.fileWriter.writeLine(0, `` ); parameters.fileWriter.writeLine(1, ''); parameters.fileWriter.writeLine(2, ``); parameters.fileWriter.writeLine(2, ``); parameters.fileWriter.writeLine(1, ''); parameters.fileWriter.writeLine(0, ''); - // declare the element - const { name: namespace } = ModelUtil.parseNamespace(mapDeclaration.getNamespace()); - parameters.fileWriter.writeLine(0, `` ); return null; } @@ -304,12 +311,12 @@ class XmlSchemaVisitor { default: if(!ModelUtil.getNamespace(type)) { const typeDeclaration = mapDeclaration.getModelFile().getType(type); - if (typeDeclaration?.isClassDeclaration?.()) { + if (typeDeclaration?.isClassDeclaration?.() && ['Concept', 'Asset', 'Transaction', 'Participant', 'Event'].includes(type)) { + return `concerto:${mapElement.getType()}`; + } else if (typeDeclaration?.isClassDeclaration?.() ) { return `${ModelUtil.parseNamespace(mapDeclaration.getModelFile().getNamespace()).name}:${mapElement.getType()}`; } else if (typeDeclaration?.isScalarDeclaration?.()) { return this.toXsType(typeDeclaration.getType()); - } else { - return `concerto:${mapElement.getType()}`; } } return `${ModelUtil.parseNamespace(ModelUtil.getNamespace(type)).name}:${ModelUtil.getShortName(type)}`; diff --git a/test/codegen/__snapshots__/codegen.js.snap b/test/codegen/__snapshots__/codegen.js.snap index 68a70a11..510b662e 100644 --- a/test/codegen/__snapshots__/codegen.js.snap +++ b/test/codegen/__snapshots__/codegen.js.snap @@ -5107,13 +5107,19 @@ xmlns:concerto="concerto" - + + + + + + + + - @@ -5143,48 +5149,84 @@ xmlns:concerto="concerto" > - + + + + + + + + - - + + + + + + + + - - + + + + + + + + - - + + + + + + + + - - + + + + + + + + - + + + + + + + - - + + - @@ -10738,13 +10780,19 @@ xmlns:concerto="concerto" - + + + + + + + + - @@ -10774,48 +10822,84 @@ xmlns:concerto="concerto" > - + + + + + + + + - - + + + + + + + + - - + + + + + + + + - - + + + + + + + + - - + + + + + + + + - + + + + + + + - - + + - diff --git a/test/codegen/fromcto/xmlschema/xmlschemavisitor.js b/test/codegen/fromcto/xmlschema/xmlschemavisitor.js index c43844fc..44be6e9e 100644 --- a/test/codegen/fromcto/xmlschema/xmlschemavisitor.js +++ b/test/codegen/fromcto/xmlschema/xmlschemavisitor.js @@ -399,30 +399,35 @@ describe('XmlSchemaVisitor', function () { fileWriter: mockFileWriter }; - const getAllDeclarations = sinon.stub(); const mockMapDeclaration = sinon.createStubInstance(MapDeclaration); const findStub = sinon.stub(); const getKeyType = sinon.stub(); const getValueType = sinon.stub(); - getAllDeclarations.returns({ find: findStub }); findStub.returns(mockMapDeclaration); getKeyType.returns('String'); getValueType.returns('String'); mockMapDeclaration.getName.returns('Map1'); mockMapDeclaration.getKey.returns({ getType: getKeyType }); mockMapDeclaration.getValue.returns({ getType: getValueType }); - mockMapDeclaration.getModelFile.returns({ getAllDeclarations: getAllDeclarations }); xmlSchemaVisitor.visitMapDeclaration(mockMapDeclaration, param); - param.fileWriter.writeLine.callCount.should.deep.equal(7); - param.fileWriter.writeLine.getCall(0).args.should.deep.equal([0, '']); - param.fileWriter.writeLine.getCall(1).args.should.deep.equal([1, '']); - param.fileWriter.writeLine.getCall(2).args.should.deep.equal([2, '']); - param.fileWriter.writeLine.getCall(3).args.should.deep.equal([2, '']); + param.fileWriter.writeLine.callCount.should.deep.equal(13); + param.fileWriter.writeLine.getCall(0).args.should.deep.equal([0, '']); + param.fileWriter.writeLine.getCall(1).args.should.deep.equal([0, '']); + param.fileWriter.writeLine.getCall(2).args.should.deep.equal([1, '']); + param.fileWriter.writeLine.getCall(3).args.should.deep.equal([2, '']); param.fileWriter.writeLine.getCall(4).args.should.deep.equal([1, '']); param.fileWriter.writeLine.getCall(5).args.should.deep.equal([0, '']); + param.fileWriter.writeLine.getCall(6).args.should.deep.equal([0, '']); + + param.fileWriter.writeLine.getCall(7).args.should.deep.equal([0, '']); + param.fileWriter.writeLine.getCall(8).args.should.deep.equal([1, '']); + param.fileWriter.writeLine.getCall(9).args.should.deep.equal([2, '']); + param.fileWriter.writeLine.getCall(10).args.should.deep.equal([2, '']); + param.fileWriter.writeLine.getCall(11).args.should.deep.equal([1, '']); + param.fileWriter.writeLine.getCall(12).args.should.deep.equal([0, '']); }); @@ -454,16 +459,24 @@ describe('XmlSchemaVisitor', function () { xmlSchemaVisitor.visitMapDeclaration(mockMapDeclaration, param); - param.fileWriter.writeLine.callCount.should.deep.equal(7); - param.fileWriter.writeLine.getCall(0).args.should.deep.equal([0, '']); - param.fileWriter.writeLine.getCall(1).args.should.deep.equal([1, '']); - param.fileWriter.writeLine.getCall(2).args.should.deep.equal([2, '']); - param.fileWriter.writeLine.getCall(3).args.should.deep.equal([2, '']); + param.fileWriter.writeLine.callCount.should.deep.equal(13); + param.fileWriter.writeLine.getCall(0).args.should.deep.equal([0, '']); + param.fileWriter.writeLine.getCall(1).args.should.deep.equal([0, '']); + param.fileWriter.writeLine.getCall(2).args.should.deep.equal([1, '']); + param.fileWriter.writeLine.getCall(3).args.should.deep.equal([2, '']); param.fileWriter.writeLine.getCall(4).args.should.deep.equal([1, '']); param.fileWriter.writeLine.getCall(5).args.should.deep.equal([0, '']); + param.fileWriter.writeLine.getCall(6).args.should.deep.equal([0, '']); + + param.fileWriter.writeLine.getCall(7).args.should.deep.equal([0, '']); + param.fileWriter.writeLine.getCall(8).args.should.deep.equal([1, '']); + param.fileWriter.writeLine.getCall(9).args.should.deep.equal([2, '']); + param.fileWriter.writeLine.getCall(10).args.should.deep.equal([2, '']); + param.fileWriter.writeLine.getCall(11).args.should.deep.equal([1, '']); + param.fileWriter.writeLine.getCall(12).args.should.deep.equal([0, '']); }); - it('should write the map declaration for a map ', () => { + it('should write the map declaration for a map ', () => { let param = { fileWriter: mockFileWriter @@ -475,38 +488,34 @@ describe('XmlSchemaVisitor', function () { const mockMapDeclaration = sinon.createStubInstance(MapDeclaration); const mockDeclaration = sinon.createStubInstance(ClassDeclaration); - const isClassDeclaration = sinon.stub(); - const getNamespaceStub = sinon.stub(); + const mockModelFile = sinon.createStubInstance(ModelFile); const getKeyType = sinon.stub(); const getValueType = sinon.stub(); - const getType = sinon.stub(); - mockMapDeclaration.getModelFile.returns({ getType: getType}); - getType.returns(mockDeclaration); + mockMapDeclaration.getModelFile.returns(mockModelFile); + mockModelFile.getNamespace.returns('org.acme'); + mockModelFile.getType.returns(mockDeclaration); mockDeclaration.isClassDeclaration.returns(true); - mockDeclaration.isScalarDeclaration.returns(false); mockDeclaration.getType.returns('Person'); - getNamespaceStub.returns(''); mockMapDeclaration.isClassDeclaration.returns(true); getKeyType.returns('String'); getValueType.returns('Person'); - isClassDeclaration.returns(true); mockMapDeclaration.getName.returns('Map1'); mockMapDeclaration.getKey.returns({ getType: getKeyType }); mockMapDeclaration.getValue.returns({ getType: getValueType }); xmlSchemaVisitor.visitMapDeclaration(mockMapDeclaration, param); - param.fileWriter.writeLine.callCount.should.deep.equal(7); - param.fileWriter.writeLine.getCall(0).args.should.deep.equal([0, '']); - param.fileWriter.writeLine.getCall(1).args.should.deep.equal([1, '']); - param.fileWriter.writeLine.getCall(2).args.should.deep.equal([2, '']); - param.fileWriter.writeLine.getCall(3).args.should.deep.equal([2, '']); + param.fileWriter.writeLine.callCount.should.deep.equal(13); + param.fileWriter.writeLine.getCall(0).args.should.deep.equal([0, '']); + param.fileWriter.writeLine.getCall(1).args.should.deep.equal([0, '']); + param.fileWriter.writeLine.getCall(2).args.should.deep.equal([1, '']); + param.fileWriter.writeLine.getCall(3).args.should.deep.equal([2, '']); param.fileWriter.writeLine.getCall(4).args.should.deep.equal([1, '']); param.fileWriter.writeLine.getCall(5).args.should.deep.equal([0, '']); }); - it('should write the map declaration for a map ', () => { + it('should write the map declaration for a map ', () => { let param = { fileWriter: mockFileWriter @@ -524,16 +533,24 @@ describe('XmlSchemaVisitor', function () { xmlSchemaVisitor.visitMapDeclaration(mockMapDeclaration, param); - param.fileWriter.writeLine.callCount.should.deep.equal(7); - param.fileWriter.writeLine.getCall(0).args.should.deep.equal([0, '']); - param.fileWriter.writeLine.getCall(1).args.should.deep.equal([1, '']); - param.fileWriter.writeLine.getCall(2).args.should.deep.equal([2, '']); - param.fileWriter.writeLine.getCall(3).args.should.deep.equal([2, '']); + param.fileWriter.writeLine.callCount.should.deep.equal(13); + param.fileWriter.writeLine.getCall(0).args.should.deep.equal([0, '']); + param.fileWriter.writeLine.getCall(1).args.should.deep.equal([0, '']); + param.fileWriter.writeLine.getCall(2).args.should.deep.equal([1, '']); + param.fileWriter.writeLine.getCall(3).args.should.deep.equal([2, '']); param.fileWriter.writeLine.getCall(4).args.should.deep.equal([1, '']); param.fileWriter.writeLine.getCall(5).args.should.deep.equal([0, '']); + param.fileWriter.writeLine.getCall(6).args.should.deep.equal([0, '']); + + param.fileWriter.writeLine.getCall(7).args.should.deep.equal([0, '']); + param.fileWriter.writeLine.getCall(8).args.should.deep.equal([1, '']); + param.fileWriter.writeLine.getCall(9).args.should.deep.equal([2, '']); + param.fileWriter.writeLine.getCall(10).args.should.deep.equal([2, '']); + param.fileWriter.writeLine.getCall(11).args.should.deep.equal([1, '']); + param.fileWriter.writeLine.getCall(12).args.should.deep.equal([0, '']); }); - it('should write the map declaration for a map ', () => { + it('should write the map declaration for a map ', () => { let param = { fileWriter: mockFileWriter @@ -551,16 +568,24 @@ describe('XmlSchemaVisitor', function () { xmlSchemaVisitor.visitMapDeclaration(mockMapDeclaration, param); - param.fileWriter.writeLine.callCount.should.deep.equal(7); - param.fileWriter.writeLine.getCall(0).args.should.deep.equal([0, '']); - param.fileWriter.writeLine.getCall(1).args.should.deep.equal([1, '']); - param.fileWriter.writeLine.getCall(2).args.should.deep.equal([2, '']); - param.fileWriter.writeLine.getCall(3).args.should.deep.equal([2, '']); + param.fileWriter.writeLine.callCount.should.deep.equal(13); + param.fileWriter.writeLine.getCall(0).args.should.deep.equal([0, '']); + param.fileWriter.writeLine.getCall(1).args.should.deep.equal([0, '']); + param.fileWriter.writeLine.getCall(2).args.should.deep.equal([1, '']); + param.fileWriter.writeLine.getCall(3).args.should.deep.equal([2, '']); param.fileWriter.writeLine.getCall(4).args.should.deep.equal([1, '']); param.fileWriter.writeLine.getCall(5).args.should.deep.equal([0, '']); + param.fileWriter.writeLine.getCall(6).args.should.deep.equal([0, '']); + + param.fileWriter.writeLine.getCall(7).args.should.deep.equal([0, '']); + param.fileWriter.writeLine.getCall(8).args.should.deep.equal([1, '']); + param.fileWriter.writeLine.getCall(9).args.should.deep.equal([2, '']); + param.fileWriter.writeLine.getCall(10).args.should.deep.equal([2, '']); + param.fileWriter.writeLine.getCall(11).args.should.deep.equal([1, '']); + param.fileWriter.writeLine.getCall(12).args.should.deep.equal([0, '']); }); - it('should write the map declaration for a map ', () => { + it('should write the map declaration for a map ', () => { let param = { fileWriter: mockFileWriter @@ -580,15 +605,67 @@ describe('XmlSchemaVisitor', function () { xmlSchemaVisitor.visitMapDeclaration(mockMapDeclaration, param); - param.fileWriter.writeLine.callCount.should.deep.equal(7); - param.fileWriter.writeLine.getCall(0).args.should.deep.equal([0, '']); - param.fileWriter.writeLine.getCall(1).args.should.deep.equal([1, '']); - param.fileWriter.writeLine.getCall(2).args.should.deep.equal([2, '']); - param.fileWriter.writeLine.getCall(3).args.should.deep.equal([2, '']); + param.fileWriter.writeLine.callCount.should.deep.equal(13); + param.fileWriter.writeLine.getCall(0).args.should.deep.equal([0, '']); + param.fileWriter.writeLine.getCall(1).args.should.deep.equal([0, '']); + param.fileWriter.writeLine.getCall(2).args.should.deep.equal([1, '']); + param.fileWriter.writeLine.getCall(3).args.should.deep.equal([2, '']); param.fileWriter.writeLine.getCall(4).args.should.deep.equal([1, '']); param.fileWriter.writeLine.getCall(5).args.should.deep.equal([0, '']); + param.fileWriter.writeLine.getCall(6).args.should.deep.equal([0, '']); + + param.fileWriter.writeLine.getCall(7).args.should.deep.equal([0, '']); + param.fileWriter.writeLine.getCall(8).args.should.deep.equal([1, '']); + param.fileWriter.writeLine.getCall(9).args.should.deep.equal([2, '']); + param.fileWriter.writeLine.getCall(10).args.should.deep.equal([2, '']); + param.fileWriter.writeLine.getCall(11).args.should.deep.equal([1, '']); + param.fileWriter.writeLine.getCall(12).args.should.deep.equal([0, '']); }); + it('should write the map declaration for a map ', () => { + + let param = { + fileWriter: mockFileWriter + }; + const mockMapDeclaration = sinon.createStubInstance(MapDeclaration); + const mockDeclaration = sinon.createStubInstance(ClassDeclaration); + const mockModelFile = sinon.createStubInstance(ModelFile); + const getKeyType = sinon.stub(); + const getValueType = sinon.stub(); + + mockMapDeclaration.getModelFile.returns(mockModelFile); + mockModelFile.getNamespace.returns('org.acme'); + mockModelFile.getType.returns(mockDeclaration); + mockDeclaration.isClassDeclaration.returns(true); + mockDeclaration.getType.returns('Concept'); + mockMapDeclaration.isClassDeclaration.returns(true); + getKeyType.returns('String'); + getValueType.returns('Concept'); + mockMapDeclaration.getName.returns('Map1'); + mockMapDeclaration.getKey.returns({ getType: getKeyType }); + mockMapDeclaration.getValue.returns({ getType: getValueType }); + + xmlSchemaVisitor.visitMapDeclaration(mockMapDeclaration, param); + + param.fileWriter.writeLine.callCount.should.deep.equal(13); + param.fileWriter.writeLine.getCall(0).args.should.deep.equal([0, '']); + param.fileWriter.writeLine.getCall(1).args.should.deep.equal([0, '']); + param.fileWriter.writeLine.getCall(2).args.should.deep.equal([1, '']); + param.fileWriter.writeLine.getCall(3).args.should.deep.equal([2, '']); + param.fileWriter.writeLine.getCall(4).args.should.deep.equal([1, '']); + param.fileWriter.writeLine.getCall(5).args.should.deep.equal([0, '']); + param.fileWriter.writeLine.getCall(6).args.should.deep.equal([0, '']); + + param.fileWriter.writeLine.getCall(7).args.should.deep.equal([0, '']); + param.fileWriter.writeLine.getCall(8).args.should.deep.equal([1, '']); + param.fileWriter.writeLine.getCall(9).args.should.deep.equal([2, '']); + param.fileWriter.writeLine.getCall(10).args.should.deep.equal([2, '']); + param.fileWriter.writeLine.getCall(11).args.should.deep.equal([1, '']); + param.fileWriter.writeLine.getCall(12).args.should.deep.equal([0, '']); + + }); + + }); describe('visitField', () => { From 4239ab226b32c16eafe05b99f9e67d2268c9d7ae Mon Sep 17 00:00:00 2001 From: Jonathan Casey Date: Wed, 15 Nov 2023 16:32:23 +0000 Subject: [PATCH 19/20] test(*): resets sandbox for test scenario Signed-off-by: Jonathan Casey --- test/codegen/fromcto/xmlschema/xmlschemavisitor.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/codegen/fromcto/xmlschema/xmlschemavisitor.js b/test/codegen/fromcto/xmlschema/xmlschemavisitor.js index 44be6e9e..83385b6d 100644 --- a/test/codegen/fromcto/xmlschema/xmlschemavisitor.js +++ b/test/codegen/fromcto/xmlschema/xmlschemavisitor.js @@ -633,6 +633,8 @@ describe('XmlSchemaVisitor', function () { const getKeyType = sinon.stub(); const getValueType = sinon.stub(); + sandbox.reset(); + mockMapDeclaration.getModelFile.returns(mockModelFile); mockModelFile.getNamespace.returns('org.acme'); mockModelFile.getType.returns(mockDeclaration); From c78ccdeabeacc2418996fc4775c1746ebe0b260a Mon Sep 17 00:00:00 2001 From: Jonathan Casey Date: Thu, 16 Nov 2023 09:46:56 +0000 Subject: [PATCH 20/20] test(*): fix casing Signed-off-by: Jonathan Casey --- test/codegen/fromcto/xmlschema/xmlschemavisitor.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/codegen/fromcto/xmlschema/xmlschemavisitor.js b/test/codegen/fromcto/xmlschema/xmlschemavisitor.js index 83385b6d..5dac9808 100644 --- a/test/codegen/fromcto/xmlschema/xmlschemavisitor.js +++ b/test/codegen/fromcto/xmlschema/xmlschemavisitor.js @@ -393,7 +393,7 @@ describe('XmlSchemaVisitor', function () { sandbox.restore(); }); - it('should write the map declaration for a map ', () => { + it('should write the map declaration for a map ', () => { let param = { fileWriter: mockFileWriter @@ -431,7 +431,7 @@ describe('XmlSchemaVisitor', function () { }); - it('should write the map declaration for a map ', () => { + it('should write the map declaration for a map ', () => { let param = { fileWriter: mockFileWriter };