-
-
Notifications
You must be signed in to change notification settings - Fork 118
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature(validation) add Ergo-style validation
Signed-off-by: Jerome Simeon <[email protected]>
- Loading branch information
1 parent
0a6176d
commit ad0ce5e
Showing
8 changed files
with
255 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,12 +27,15 @@ describe('Wildcards Model', function () { | |
let factory; | ||
let modelManager; | ||
let serializer; | ||
let ergoSerializer; | ||
|
||
beforeEach(() => { | ||
modelManager = new ModelManager(); | ||
Util.addComposerSystemModels(modelManager); | ||
factory = new Factory(modelManager); | ||
serializer = new Serializer(factory, modelManager); | ||
ergoSerializer = new Serializer(factory, modelManager); | ||
ergoSerializer.setDefaultOptions({ ergo: true }); | ||
const files = [ | ||
'./test/data/model/dependencies/base/base.cto', | ||
'./test/data/model/wildcards.cto' | ||
|
@@ -77,6 +80,36 @@ describe('Wildcards Model', function () { | |
resource.person.getFullyQualifiedIdentifier().should.equal('stdlib.base.Person#ALICE_1'); | ||
}); | ||
|
||
it('should parse a resource using types from a wildcard import (Ergo)', () => { | ||
const json = { | ||
$class: 'org.acme.wildcards.MyAsset', | ||
assetId: '1', | ||
concept: { | ||
$class: 'org.acme.wildcards.MyConcept', | ||
gender: { 'type': 'stdlib.base.Gender', 'data': { 'right' : { 'left': 'FEMALE' } } } | ||
}, | ||
participant: { | ||
$class: 'org.acme.wildcards.MyParticipant', | ||
participantId: '1', | ||
firstName: 'Alice', | ||
lastName: 'A', | ||
contactDetails: { | ||
$class: 'stdlib.base.ContactDetails', | ||
email: '[email protected]' | ||
} | ||
}, | ||
person: 'resource:stdlib.base.Person#ALICE_1' | ||
}; | ||
const resource = ergoSerializer.fromJSON(json); | ||
resource.assetId.should.equal('1'); | ||
resource.concept.gender.should.equal('FEMALE'); | ||
resource.participant.participantId.should.equal('1'); | ||
resource.participant.firstName.should.equal('Alice'); | ||
resource.participant.lastName.should.equal('A'); | ||
resource.participant.contactDetails.email.should.equal('[email protected]'); | ||
resource.person.getFullyQualifiedIdentifier().should.equal('stdlib.base.Person#ALICE_1'); | ||
}); | ||
|
||
it('should serialize a resource using types from a wildcard import', () => { | ||
const resource = factory.newResource('org.acme.wildcards', 'MyAsset', '1'); | ||
resource.assetId = '1'; | ||
|
Oops, something went wrong.