Skip to content

Commit

Permalink
bug(vocabulary): fix for vocabulary management for ScalarDeclaration (#…
Browse files Browse the repository at this point in the history
…662)

Signed-off-by: sanketshevkar <[email protected]>
  • Loading branch information
sanketshevkar authored Jun 28, 2023
1 parent fa0f2ed commit 7926fae
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion packages/concerto-vocabulary/lib/vocabularymanager.js
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ class VocabularyManager {
});
}

decl.getProperties().forEach(property => {
decl.getProperties?.().forEach(property => {
const propertyTerm = this.resolveTerm(modelManager, model.getNamespace(), locale, decl.getName(), property.getName());

if (propertyTerm) {
Expand Down
2 changes: 2 additions & 0 deletions packages/concerto-vocabulary/test/org.acme.cto
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ enum Color {
o GREEN
}

scalar SSN extends String default="000-00-0000"

asset Vehicle identified by vin {
o String vin
o Color color
Expand Down
11 changes: 8 additions & 3 deletions packages/concerto-vocabulary/test/vocabularymanager.js
Original file line number Diff line number Diff line change
Expand Up @@ -248,11 +248,11 @@ describe('VocabularyManager', () => {
result.additionalVocabularies.length.should.equal(1);
result.additionalVocabularies[0].getNamespace().should.equal('com.example');
result.vocabularies['org.acme/en'].additionalTerms.should.have.members(['Vehicle.model']);
result.vocabularies['org.acme/en'].missingTerms.should.have.members(['Color.RED', 'Color.BLUE', 'Color.GREEN', 'Vehicle.color']);
result.vocabularies['org.acme/en'].missingTerms.should.have.members(['Color.RED', 'Color.BLUE', 'Color.GREEN', 'SSN', 'Vehicle.color']);
result.vocabularies['org.acme/en-gb'].additionalTerms.should.have.members(['Milkfloat']);
result.vocabularies['org.acme/fr'].missingTerms.should.have.members(['Color', 'Vehicle.color', 'Truck']);
result.vocabularies['org.acme/fr'].missingTerms.should.have.members(['Color', 'SSN', 'Vehicle.color', 'Truck']);
result.vocabularies['org.acme/fr'].additionalTerms.should.have.members([]);
result.vocabularies['org.acme/zh-cn'].missingTerms.should.have.members(['Truck']);
result.vocabularies['org.acme/zh-cn'].missingTerms.should.have.members(['SSN', 'Truck']);
result.vocabularies['org.acme/zh-cn'].additionalTerms.should.have.members([]);
});

Expand All @@ -271,5 +271,10 @@ describe('VocabularyManager', () => {
const decorator = vehicleDecl.getDecorator('Term');
decorator.getArguments()[0].should.equal('A road vehicle');
vehicleDecl.getProperty('vin').getDecorator('Term').getArguments()[0].should.equal('Vehicle Identification Number');

const scalarDeclarations = mf.getScalarDeclarations();
const ssnDeclaration = scalarDeclarations[0];
const ssnDecorator = ssnDeclaration.getDecorator('Term');
ssnDecorator.getArguments()[0].should.equal('SSN');
});
});

0 comments on commit 7926fae

Please sign in to comment.