-
-
Notifications
You must be signed in to change notification settings - Fork 111
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Jonathan Casey <[email protected]>
- Loading branch information
1 parent
02dfcdb
commit 72baa6b
Showing
5 changed files
with
120 additions
and
13 deletions.
There are no files selected for viewing
20 changes: 20 additions & 0 deletions
20
packages/concerto-core/test/data/parser/mapdeclaration/base.cto
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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
namespace [email protected] | ||
|
||
concept Thing { | ||
o String name | ||
} | ||
|
||
scalar Time extends DateTime |
21 changes: 21 additions & 0 deletions
21
...es/concerto-core/test/data/parser/mapdeclaration/mapdeclaration.badkey.imported.thing.cto
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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
namespace [email protected] | ||
|
||
import [email protected].{Thing} | ||
|
||
map Dictionary { | ||
o Thing | ||
o String | ||
} |
21 changes: 21 additions & 0 deletions
21
.../concerto-core/test/data/parser/mapdeclaration/mapdeclaration.goodkey.imported.scalar.cto
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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
namespace [email protected] | ||
|
||
import [email protected] | ||
|
||
map Dictionary { | ||
o Time | ||
o String | ||
} |
21 changes: 21 additions & 0 deletions
21
...concerto-core/test/data/parser/mapdeclaration/mapdeclaration.goodvalue.imported.thing.cto
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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
namespace [email protected] | ||
|
||
import [email protected] | ||
|
||
map Dictionary { | ||
o String | ||
o Thing | ||
} |
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 |
---|---|---|
|
@@ -25,6 +25,7 @@ const ParserUtil = require('./parserutility'); | |
|
||
const ModelManager = require('../../lib/modelmanager'); | ||
const Util = require('../composer/composermodelutility'); | ||
const fs = require('fs'); | ||
|
||
const sinon = require('sinon'); | ||
const expect = require('chai').expect; | ||
|
@@ -46,7 +47,7 @@ describe('MapDeclaration', () => { | |
|
||
describe('#constructor', () => { | ||
|
||
it('should throw if ast contains no Map Key Property', () => { | ||
it('should throw if ast contains no Map Key Type', () => { | ||
(() => { | ||
new MapDeclaration(modelFile, { | ||
$class: '[email protected]', | ||
|
@@ -162,6 +163,13 @@ describe('MapDeclaration', () => { | |
let decl = introspectUtils.loadLastDeclaration('test/data/parser/mapdeclaration/mapdeclaration.goodkey.scalar.string.cto', MapDeclaration); | ||
decl.validate(); | ||
}); | ||
|
||
it('should validate when map key is imported and is of valid map key type', () => { | ||
const base_cto = fs.readFileSync('test/data/parser/mapdeclaration/base.cto', 'utf-8'); | ||
introspectUtils.modelManager.addCTOModel(base_cto, 'base.cto'); | ||
let decl = introspectUtils.loadLastDeclaration('test/data/parser/mapdeclaration/mapdeclaration.goodkey.imported.scalar.cto', MapDeclaration); | ||
decl.validate(); | ||
}); | ||
}); | ||
|
||
describe('#validate success scenarios - Map Value', () => { | ||
|
@@ -254,11 +262,18 @@ describe('MapDeclaration', () => { | |
let decl = introspectUtils.loadLastDeclaration('test/data/parser/mapdeclaration/mapdeclaration.goodvalue.primitive.long.cto', MapDeclaration); | ||
decl.validate(); | ||
}); | ||
|
||
it('should validate when map value is imported and is of valid map key type', () => { | ||
const base_cto = fs.readFileSync('test/data/parser/mapdeclaration/base.cto', 'utf-8'); | ||
introspectUtils.modelManager.addCTOModel(base_cto, 'base.cto'); | ||
let decl = introspectUtils.loadLastDeclaration('test/data/parser/mapdeclaration/mapdeclaration.goodvalue.imported.thing.cto', MapDeclaration); | ||
decl.validate(); | ||
}); | ||
}); | ||
|
||
describe('#validate failure scenarios - Map Key', () => { | ||
|
||
it('should throw if ast contains illegal Map Key Property', () => { | ||
it('should throw if ast contains illegal Map Key Type', () => { | ||
(() => { | ||
new MapDeclaration(modelFile, { | ||
$class: '[email protected]', | ||
|
@@ -273,42 +288,42 @@ describe('MapDeclaration', () => { | |
}).should.throw(IllegalModelException); | ||
}); | ||
|
||
it('should throw if ast contains illegal Map Key Property - Concept', () => { | ||
it('should throw if ast contains illegal Map Key Type - Concept', () => { | ||
(() => { | ||
let decl = introspectUtils.loadLastDeclaration('test/data/parser/mapdeclaration/mapdeclaration.badkey.declaration.concept.cto', MapDeclaration); | ||
decl.validate().should.throw(IllegalModelException); | ||
}); | ||
}); | ||
|
||
it('should throw if ast contains illegal Map Key Property - Scalar Long', () => { | ||
it('should throw if ast contains illegal Map Key Type - Scalar Long', () => { | ||
(() => { | ||
let decl = introspectUtils.loadLastDeclaration('test/data/parser/mapdeclaration/mapdeclaration.badkey.scalar.long.cto', MapDeclaration); | ||
decl.validate(); | ||
}); | ||
}); | ||
|
||
it('should throw if ast contains illegal Map Key Property - Scalar Integer', () => { | ||
it('should throw if ast contains illegal Map Key Type - Scalar Integer', () => { | ||
(() => { | ||
let decl = introspectUtils.loadLastDeclaration('test/data/parser/mapdeclaration/mapdeclaration.badkey.scalar.integer.cto', MapDeclaration); | ||
decl.validate().should.throw(IllegalModelException); | ||
}); | ||
}); | ||
|
||
it('should throw if ast contains illegal Map Key Property - Scalar Double', () => { | ||
it('should throw if ast contains illegal Map Key Type - Scalar Double', () => { | ||
(() => { | ||
let decl = introspectUtils.loadLastDeclaration('test/data/parser/mapdeclaration/mapdeclaration.badkey.scalar.double.cto', MapDeclaration); | ||
decl.validate().should.throw(IllegalModelException); | ||
}); | ||
}); | ||
|
||
it('should throw if ast contains illegal Map Key Property - Scalar Boolean', () => { | ||
it('should throw if ast contains illegal Map Key Type - Scalar Boolean', () => { | ||
(() => { | ||
let decl = introspectUtils.loadLastDeclaration('test/data/parser/mapdeclaration/mapdeclaration.badkey.scalar.boolean.cto', MapDeclaration); | ||
decl.validate().should.throw(IllegalModelException); | ||
}); | ||
}); | ||
|
||
it('should throw if ast contains illegal Map Key Property - Boolean', () => { | ||
it('should throw if ast contains illegal Map Key Type - Boolean', () => { | ||
(() => { | ||
new MapDeclaration(modelFile, { | ||
$class: '[email protected]', | ||
|
@@ -323,7 +338,7 @@ describe('MapDeclaration', () => { | |
}).should.throw(IllegalModelException); | ||
}); | ||
|
||
it('should throw if ast contains illegal Map Key Property - Integer', () => { | ||
it('should throw if ast contains illegal Map Key Type - Integer', () => { | ||
(() => { | ||
new MapDeclaration(modelFile, { | ||
$class: '[email protected]', | ||
|
@@ -338,7 +353,7 @@ describe('MapDeclaration', () => { | |
}).should.throw(IllegalModelException); | ||
}); | ||
|
||
it('should throw if ast contains illegal Map Key Property - Long', () => { | ||
it('should throw if ast contains illegal Map Key Type - Long', () => { | ||
(() => { | ||
new MapDeclaration(modelFile, { | ||
$class: '[email protected]', | ||
|
@@ -353,7 +368,7 @@ describe('MapDeclaration', () => { | |
}).should.throw(IllegalModelException); | ||
}); | ||
|
||
it('should throw if ast contains illegal Map Key Property - Double', () => { | ||
it('should throw if ast contains illegal Map Key Type - Double', () => { | ||
(() => { | ||
new MapDeclaration(modelFile, { | ||
$class: '[email protected]', | ||
|
@@ -368,7 +383,7 @@ describe('MapDeclaration', () => { | |
}).should.throw(IllegalModelException); | ||
}); | ||
|
||
it('should throw if ast contains illegal Map Key Property - Enum', () => { | ||
it('should throw if ast contains illegal Map Key Type - Enum', () => { | ||
(() => { | ||
new MapDeclaration(modelFile, { | ||
$class: '[email protected]', | ||
|
@@ -386,6 +401,15 @@ describe('MapDeclaration', () => { | |
}); | ||
}).should.throw(IllegalModelException); | ||
}); | ||
|
||
it('should throw when map key is imported and is an illegal Map Key Type', () => { | ||
(() => { | ||
const base_cto = fs.readFileSync('test/data/parser/mapdeclaration/base.cto', 'utf-8'); | ||
introspectUtils.modelManager.addCTOModel(base_cto, 'base.cto'); | ||
let decl = introspectUtils.loadLastDeclaration('test/data/parser/mapdeclaration/mapdeclaration.badkey.imported.thing.cto', MapDeclaration); | ||
decl.validate().should.throw(IllegalModelException); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('#validate failure scenarios - Map Value', () => { | ||
|
@@ -489,7 +513,7 @@ describe('MapDeclaration', () => { | |
}); | ||
|
||
describe('#getKey', () => { | ||
it('should return the map key property', () => { | ||
it('should return the Map Key Type', () => { | ||
let clz = new MapDeclaration(modelFile, { | ||
$class: '[email protected]', | ||
name: 'MapPermutation1', | ||
|