/* Tefkat: version 2.0.9.02 The version being used was losing order of model elements during transformation. To deal with this issue, the ‘order’ attribute is added in the meta-models as a work around. */ TRANSFORMATION smc2xunit : smc->xUnit IMPORT http://smc IMPORT http://xUnit /****************************************************************************************************** Following rule creates a test suite for every uml model in the input file. ******************************************************************************************************/ RULE Model_2_TestSuite(model, testSuite) FORALL Model model MAKE TestSuite testSuite SET testSuite.name = model.name ; /****************************************************************************************************** Following rule creates a test case for every smc in the model. ******************************************************************************************************/ RULE smc_2_TestCase(model, testSuite, smc, testCase) EXTENDS Model_2_TestSuite(model, testSuite) FORALL smc smc WHERE smc.owner = model MAKE TestCase testCase SET testCase.name = smc.name, testSuite.testCase = testCase ; /****************************************************************************************************** Following rule creates an assertion for every message in the smc model. ******************************************************************************************************/ RULE Message_2_Assertion(model, testSuite, smc, testCase, message, assertion, method) EXTENDS Interaction_2_TestCase(model, testSuite, smc, testCase) FORALL Message message WHERE message.owner = smc MAKE Assertion assertion, Method method SET assertion.name = append( append(smc.name, "_"), message.name), method.name = message.name, method.static = message.static, assertion.order = message.order, assertion.assertionType = message.assertionType, assertion.method = method, testCase.assertion= assertion, testSuite.testCase = testCase ; /****************************************************************************************************** Following rule creates an ‘owner class’ object in the xUnit model for every owner class in the smc model. ******************************************************************************************************/ RULE OwnerClass_2_OwnerClass(model, testSuite, smc, testCase, message, assertion, method, c1, c2) EXTENDS Message_2_Assertion(model, testSuite, smc, testCase, message, assertion, method) FORALL ::smc::OwnerClass c1 WHERE c1.owner = message MAKE ::xUnit::OwnerClass c2 SET c2.name = c1.name, method.ownerClass = c2 ; /****************************************************************************************************** Following rule creates a parameter object in the xUnit model. ******************************************************************************************************/ RULE Parameter_2_Parameter(model, testSuite, smc, testCase, message, assertion, method, p1, p2) EXTENDS Message_2_Assertion(model, testSuite, smc, testCase, message, assertion, method) FORALL ::smc::Parameter p1 WHERE p1.owner = message MAKE ::xUnit::Parameter p2 SET p2.name = p1.name, p2.type = p1.type, p2.setter = p1.setter, method.parameter = p2 ; /****************************************************************************************************** Following rule creates an expcted value in the xUnit model. ******************************************************************************************************/ RULE ExpectedValue_2_ExpectedValue(model, testSuite, smc, testCase, message, assertion, method, e1, e2) EXTENDS Message_2_Assertion(model, testSuite, smc, testCase, message, assertion, method) FORALL ::smc::ExpectedValue e1 WHERE e1.owner = message MAKE ::xUnit::ExpectedValue e2 SET e2.name = e1.name, e2.type = e1.type, e2.setter = e1.setter, assertion.expectedValue = e2 ; /****************************************************************************************************** Following rule creates a simple attribute in the parameter. ******************************************************************************************************/ RULE SimpleAttribute_2_Parameter(model, testSuite, smc, testCase, message, assertion, method, p1, p2, sp1, sp2) EXTENDS Parameter_2_Parameter(model, testSuite, smc, testCase, message, assertion, method, p1, p2) FORALL ::smc::SimpleAttribute sp1 WHERE sp1.owner = p1 MAKE ::xUnit::SimpleAttribute sp2 SET sp2.name = sp1.name, sp2.type = sp1.type, sp2.setter = sp1.setter, p2.simpleAttribute = sp2 ; /****************************************************************************************************** Following rule creates a complex attribute in the parameter. ******************************************************************************************************/ RULE ComplexAttribute_2_Parameter(model, testSuite, smc, testCase, message, assertion, method, p1, p2, cp1, cp2) EXTENDS Parameter_2_Parameter(model, testSuite, smc, testCase, message, assertion, method, p1, p2) FORALL ::smc::ComplexAttribute cp1 WHERE cp1.owner = p1 MAKE ::xUnit::ComplexAttribute cp2 SET cp2.name = cp1.name, cp2.type = cp1.type, cp2.setter = cp1.setter, p2.complexAttribute = cp2 ; /****************************************************************************************************** Following rule creates a simple attribute in the complex attribute of a parameter. ******************************************************************************************************/ RULE SimpleAttribute_2_ComplexAttribute_Parameter(model, testSuite, smc, testCase, message, assertion, method, p1, p2, cp1, cp2, scp1, scp2) EXTENDS ComplexAttribute_2_Parameter(model, testSuite, smc, testCase, message, assertion, method, p1, p2, cp1, cp2) FORALL ::smc::SimpleAttribute scp1 WHERE scp1.owner = cp1 MAKE ::xUnit::SimpleAttribute scp2 SET scp2.name = scp1.name, scp2.type = scp1.type, scp2.setter = scp1.setter, cp2.simpleAttribute = scp2 ; /****************************************************************************************************** Following rule creates a complex attribute with in the complex attribute of a parameter. ******************************************************************************************************/ RULE ComplexAttribute_2_ComplexAttribute_Parameter(model, testSuite, smc, testCase, message, assertion, method, p1, p2, cp1, cp2, ccp1, ccp2) EXTENDS ComplexAttribute_2_Parameter(model, testSuite, smc, testCase, message, assertion, method, p1, p2, cp1, cp2) FORALL ::smc::ComplexAttribute ccp1 WHERE ccp1.owner = cp1 MAKE ::xUnit::ComplexAttribute ccp2 SET ccp2.name = ccp1.name, ccp2.type = ccp1.type, ccp2.setter = ccp1.setter, cp2.complexAttribute = ccp2 ; /****************************************************************************************************** Following rule creates a simple attribute with in the complex attribute of a parameter. ******************************************************************************************************/ RULE SimpleAttribute_2_ComplexComplex_Parameter(model, testSuite, smc, testCase, message, assertion, method, p1, p2, cp1, cp2, ccp1, ccp2, s1, s2) EXTENDS ComplexAttribute_2_ComplexAttribute_Parameter(model, testSuite, smc, testCase, message, assertion, method, p1, p2, cp1, cp2, ccp1, ccp2) FORALL ::smc::SimpleAttribute s1 WHERE s1.owner = ccp1 MAKE ::xUnit::SimpleAttribute s2 SET s2.name = s1.name, s2.type = s1.type, s2.setter = s1.setter, ccp2.simpleAttribute = s2 ; /****************************************************************************************************** Following rule creates a simple attribute in an expected value oobject. ******************************************************************************************************/ RULE SimpleAttribute_2_ExpectedValue(model, testSuite, smc, testCase, message, assertion, method, e1, e2, se1, se2) EXTENDS ExpectedValue_2_ExpectedValue(model, testSuite, smc, testCase, message, assertion, method, e1, e2) FORALL ::smc::SimpleAttribute se1 WHERE se1.owner = e1 MAKE ::xUnit::SimpleAttribute se2 SET se2.name = se1.name, se2.type = se1.type, se2.setter = se1.setter, e2.simpleAttribute = se2 ; /****************************************************************************************************** Following rule creates a complex attribute in an expected value object. ******************************************************************************************************/ RULE ComplexAttribute_2_ExpectedValue(model, testSuite, smc, testCase, message, assertion, method, e1, e2, ce1, ce2) EXTENDS ExpectedValue_2_ExpectedValue(model, testSuite, smc, testCase, message, assertion, method, e1, e2) FORALL ::smc::ComplexAttribute ce1 WHERE ce1.owner = e1 MAKE ::xUnit::ComplexAttribute ce2 SET ce2.name = ce1.name, ce2.type = ce1.type, ce2.setter = ce1.setter, e2.complexAttribute = ce2 ; /****************************************************************************************************** Following rule creates a simple attribute in complex attribute for an expected value object. ******************************************************************************************************/ RULE SimpleAttribute_2_ComplexAttribute_ExpectedValue(model, testSuite, smc, testCase, message, assertion, method, e1, e2, ce1, ce2, sce1, sce2) EXTENDS ComplexAttribute_2_ExpectedValue(model, testSuite, smc, testCase, message, assertion, method, e1, e2, ce1, ce2) FORALL ::smc::SimpleAttribute sce1 WHERE sce1.owner = ce1 MAKE ::xUnit::SimpleAttribute sce2 SET sce2.name = sce1.name, sce2.type = sce1.type, sce2.setter = sce1.setter, ce2.simpleAttribute = sce2 ; /****************************************************************************************************** Following rule creates a complex attribute in complex attribute for an expected value object. ******************************************************************************************************/ RULE ComplexAttribute_2_ComplexAttribute_ExpectedValue(model, testSuite, smc, testCase, message, assertion, method, e1, e2, ce1, ce2, cce1, cce2) EXTENDS ComplexAttribute_2_ExpectedValue(model, testSuite, smc, testCase, message, assertion, method, e1, e2, ce1, ce2) FORALL ::smc::ComplexAttribute cce1 WHERE cce1.owner = ce1 MAKE ::xUnit::ComplexAttribute cce2 SET cce2.name = cce1.name, cce2.type = cce1.type, cce2.setter = cce1.setter, ce2.complexAttribute = cce2 ; /****************************************************************************************************** Following rule creates a simple attribute in complex attribute an expected value object. ******************************************************************************************************/ RULE SimpleAttribute_2_ComplexComplex_ExpectedValue(model, testSuite, smc, testCase, message, assertion, method, e1, e2, ce1, ce2, cce1, cce2, s1, s2) EXTENDS ComplexAttribute_2_ComplexAttribute_ExpectedValue(model, testSuite, smc, testCase, message, assertion, method, e1, e2, ce1, ce2, cce1, cce2) FORALL ::smc::SimpleAttribute s1 WHERE s1.owner = cce1 MAKE ::xUnit::SimpleAttribute s2 SET s2.name = s1.name, s2.type = s1.type, s2.setter = s1.setter, cce2.simpleAttribute = s2 ; /****************************************************************************************************** Following rule creates a constructor paramerter object in the xUnit model. ******************************************************************************************************/ RULE ConstructorParameter_2_ConstructorParameter(model, testSuite, smc, testCase, message, assertion, method, c1, c2, cp1, cp2) EXTENDS OwnerClass_2_OwnerClass(model, testSuite, smc, testCase, message, assertion, method, c1, c2) FORALL ::smc::ConstructorParameter cp1 WHERE cp1.owner = c1 MAKE ::xUnit::ConstructorParameter cp2 SET cp2.name = cp1.name, cp2.type = cp1.type, cp2.setter = cp1.setter, c2.constructorParameter = cp2 ; /****************************************************************************************************** Following rule creates a simple attribute in constructor paramerter object. ******************************************************************************************************/ RULE SimpleAttribute_2_ConstructorParameter(model, testSuite, smc, testCase, message, assertion, method, c1, c2, cp1, cp2, se1, se2) EXTENDS ConstructorParameter_2_ConstructorParameter(model, testSuite, smc, testCase, message, assertion, method, c1, c2, cp1, cp2) FORALL ::smc::SimpleAttribute se1 WHERE se1.owner = cp1 MAKE ::xUnit::SimpleAttribute se2 SET se2.name = se1.name, se2.type = se1.type, se2.setter = se1.setter, cp2.simpleAttribute = se2 ; /****************************************************************************************************** Following rule creates a complex attribute in constructor paramerter object. ******************************************************************************************************/ RULE ComplexAttribute_2_ConstructorParameter(model, testSuite, smc, testCase, message, assertion, method, c1, c2, cp1, cp2, ce1, ce2) EXTENDS ConstructorParameter_2_ConstructorParameter(model, testSuite, smc, testCase, message, assertion, method, c1, c2, cp1, cp2) FORALL ::smc::ComplexAttribute ce1 WHERE ce1.owner = cp1 MAKE ::xUnit::ComplexAttribute ce2 SET ce2.name = ce1.name, ce2.type = ce1.type, ce2.setter = ce1.setter, cp2.complexAttribute = ce2 ; /****************************************************************************************************** Following rule creates a simple attribute in complex attribute for a constructor paramerter object. *******************************************************************************************************/ RULE SimpleAttribute_2_ComplexAttribute_ConstructorParameter(model, testSuite, smc, testCase, message, assertion, method, c1, c2, cp1, cp2, ce1, ce2, sce1, sce2) EXTENDS ComplexAttribute_2_ConstructorParameter(model, testSuite, smc, testCase, message, assertion, method, c1, c2, cp1, cp2, ce1, ce2) FORALL ::smc::SimpleAttribute sce1 WHERE sce1.owner = ce1 MAKE ::xUnit::SimpleAttribute sce2 SET sce2.name = sce1.name, sce2.type = sce1.type, sce2.setter = sce1.setter, ce2.simpleAttribute = sce2 ;