diff --git a/test/codegen/codegen.js b/test/codegen/codegen.js index e4933acf..de74a9d3 100644 --- a/test/codegen/codegen.js +++ b/test/codegen/codegen.js @@ -37,10 +37,15 @@ describe('codegen', function () { versionedModelManager = new ModelManager(); unversionedModelManager = new ModelManager(); + const base_cto = fs.readFileSync('./test/codegen/fromcto/data/model/hr_base.cto', 'utf-8'); const cto = fs.readFileSync('./test/codegen/fromcto/data/model/hr.cto', 'utf-8'); + + versionedModelManager.addCTOModel(base_cto, 'hr_base.cto'); versionedModelManager.addCTOModel(cto, 'hr.cto'); + const unversionedBaseCto = base_cto.replace('namespace org.acme.hr.base@1.0.0', 'namespace org.acme.hr.base'); const unversionedCto = cto.replace('namespace org.acme.hr@1.0.0', 'namespace org.acme.hr'); + unversionedModelManager.addCTOModel(unversionedBaseCto, 'hr_base.cto'); unversionedModelManager.addCTOModel(unversionedCto, 'hr.cto'); }); diff --git a/test/codegen/fromcto/data/model/hr.cto b/test/codegen/fromcto/data/model/hr.cto index 21c53218..b9006c58 100644 --- a/test/codegen/fromcto/data/model/hr.cto +++ b/test/codegen/fromcto/data/model/hr.cto @@ -1,55 +1,33 @@ namespace org.acme.hr@1.0.0 -enum State { - o MA - o NY - o CO - o WA - o IL - o CA -} - -concept Address { - o String street - o String city - o State state optional - o String zipCode - o String country - o Map1 dictionary1 - o Map2 dictionary2 - o Map3 dictionary3 - o Map4 dictionary4 - o Map5 dictionary5 - o Map6 dictionary6 -} -scalar Time extends DateTime - -map Map1 { +import org.acme.hr.base@1.0.0.{State, SSN, Time} + +map CompanyProperties { o String o String } -map Map2 { +map EmployeeLoginTimes { o String - o DateTime + o Time } -map Map3 { +map EmployeeSocialSecurityNumbers { o String o SSN } -map Map4 { +map EmployeeProfiles { o String o Concept } -map Map5 { +map EmployeeTShirtSizes { o SSN - o String + o TShirtSizeType } -map Map6 { +map EmployeeDirectory { o SSN o Employee } @@ -57,6 +35,11 @@ map Map6 { concept Company { o String name o Address headquarters + o CompanyProperties companyProperties optional + o EmployeeDirectory employeeDirectory optional + o EmployeeTShirtSizes employeeTShirtSizes optional + o EmployeeProfiles employeeProfiles optional + o EmployeeSocialSecurityNumbers employeeSocialSecurityNumbers optional } enum Department { @@ -82,8 +65,6 @@ asset Laptop extends Equipment { o LaptopMake make } -scalar SSN extends String default="000-00-0000" regex=/\d{3}-\d{2}-\{4}+/ - @resource abstract participant Person identified by email { o String email @@ -107,9 +88,6 @@ participant Employee extends Person { --> Manager manager optional } - - - participant Contractor extends Person { o Company company --> Manager manager optional diff --git a/test/codegen/fromcto/data/model/hr_base.cto b/test/codegen/fromcto/data/model/hr_base.cto new file mode 100644 index 00000000..2b863db8 --- /dev/null +++ b/test/codegen/fromcto/data/model/hr_base.cto @@ -0,0 +1,27 @@ +namespace org.acme.hr.base@1.0.0 + +enum State { + o MA + o NY + o CO + o WA + o IL + o CA +} + +enum TShirtSizeType { + o SMALL + o MEDIUM + o LARGE +} + +concept Address { + o String street + o String city + o State state optional + o String zipCode + o String country +} + +scalar Time extends DateTime +scalar SSN extends String default="000-00-0000" regex=/\d{3}-\d{2}-\{4}+/ \ No newline at end of file