Skip to content

Commit

Permalink
test(codegen) update HR model to use multiple namespaces
Browse files Browse the repository at this point in the history
Signed-off-by: Dan Selman <[email protected]>
  • Loading branch information
dselman committed Oct 19, 2023
1 parent 53cb765 commit 1a4285f
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 37 deletions.
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
52 changes: 15 additions & 37 deletions test/codegen/fromcto/data/model/hr.cto
Original file line number Diff line number Diff line change
@@ -1,62 +1,45 @@
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].{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
}

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




participant Contractor extends Person {
o Company company
--> Manager manager optional
Expand Down
27 changes: 27 additions & 0 deletions test/codegen/fromcto/data/model/hr_base.cto
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
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
}

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

0 comments on commit 1a4285f

Please sign in to comment.