-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(u2d): add test for MocoUmlMediatingClassOptimizationTransformati…
…onRule
- Loading branch information
Showing
1 changed file
with
39 additions
and
0 deletions.
There are no files selected for viewing
39 changes: 39 additions & 0 deletions
39
src/Moco-U2D-Tests/MocoUmlMediatingClassOptimizationTransformationRuleTest.class.st
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,39 @@ | ||
Class { | ||
#name : #MocoUmlMediatingClassOptimizationTransformationRuleTest, | ||
#superclass : #MocoTransformationRuleTestCase, | ||
#category : #'Moco-U2D-Tests-Rule' | ||
} | ||
|
||
{ #category : #'private - processing' } | ||
MocoUmlMediatingClassOptimizationTransformationRuleTest >> execute [ | ||
^ self execute: MocoUmlMediatingClassOptimizationTransformationRule | ||
] | ||
|
||
{ #category : #tests } | ||
MocoUmlMediatingClassOptimizationTransformationRuleTest >> testOptimization [ | ||
| class table pk | | ||
class := MocoUmlClass new. | ||
table := MocoRdbTable new. | ||
|
||
table columns add: (MocoRdbColumn new name: 'ID'; yourself). | ||
table constraints add: (MocoRdbPrimaryKey new name: 'PK'; yourself). | ||
table constraints first columns add: (table columns first). | ||
|
||
table columns add: (MocoRdbColumn new name: 'FK'; yourself). | ||
table constraints add: (MocoRdbForeignKey new name: 'FK'; yourself). | ||
table constraints second columns add: (table columns second). | ||
|
||
(engine input) addElement: class; metaOf: class at: #generatedBy put: #MocoUmlManyToManyAssociationTransformationRule. | ||
engine addOutputElement: table withSource: class. | ||
|
||
self execute. | ||
|
||
self assert: (table columns size) equals: 1. | ||
|
||
pk := table constraints select: [ :each | each isKindOf: MocoRdbPrimaryKey ]. | ||
self assert: (pk size) equals: 1. | ||
pk := pk first. | ||
|
||
self assert: (pk columns size) equals: 1; | ||
assert: (pk columns first) identicalTo: (table columns first) | ||
] |