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

bug(vocabulary): fix for vocabulary management for ScalarDeclaration #662

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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');
});
});