Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(codegen) update HR model to use multiple namespaces #68

Merged
merged 9 commits into from
Nov 2, 2023
Merged
5 changes: 5 additions & 0 deletions test/codegen/codegen.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 [email protected]', 'namespace org.acme.hr.base');
const unversionedCto = cto.replace('namespace [email protected]', 'namespace org.acme.hr');
unversionedModelManager.addCTOModel(unversionedBaseCto, 'hr_base.cto');
unversionedModelManager.addCTOModel(unversionedCto, 'hr.cto');
});

Expand Down
53 changes: 13 additions & 40 deletions test/codegen/fromcto/data/model/hr.cto
Original file line number Diff line number Diff line change
@@ -1,62 +1,40 @@
namespace [email protected]

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 [email protected].{Address, State, SSN, Time, EmployeeTShirtSizes}

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 {
o SSN
o String
}

map Map6 {
map EmployeeDirectory {
o SSN
o Employee
}

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 {
Expand All @@ -82,8 +60,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
Expand All @@ -107,9 +83,6 @@ participant Employee extends Person {
--> Manager manager optional
}




participant Contractor extends Person {
o Company company
--> Manager manager optional
Expand Down
32 changes: 32 additions & 0 deletions test/codegen/fromcto/data/model/hr_base.cto
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
namespace [email protected]

enum State {
o MA
o NY
o CO
o WA
o IL
o CA
}

enum TShirtSizeType {
o SMALL
o MEDIUM
o LARGE
}

map EmployeeTShirtSizes {
o SSN
o TShirtSizeType
}

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}+/