Skip to content
Permalink
Browse files

[TestGeneration] Adding the following updates:

  • Loading branch information
SultanEid committed Mar 8, 2020
1 parent a99b37f commit ba0f76b95d3108e6c017f4f2f7740b84297a365c
Showing with 5,442 additions and 270 deletions.
  1. +6 −1 UmpleTToJunit/UmpleTLTemplates/JUnitGenerator.ump
  2. +3 −3 UmpleTToJunit/UmpleTLTemplates/depends.ump
  3. +1 −1 UmpleTToJunit/UmpleTLTemplates/members_AllAssertions.ump
  4. +12 −0 UmpleTToJunit/UmpleTLTemplates/where_init.ump
  5. +4 −2 UmpleTToPhpUnit/UmpleTLTemplates/PhpUnitGenerator.ump
  6. +3 −3 UmpleTToPhpUnit/UmpleTLTemplates/depends.ump
  7. +5 −1 UmpleTToPhpUnit/UmpleTLTemplates/members_AllTestCases.ump
  8. +10 −0 UmpleTToPhpUnit/UmpleTLTemplates/where_init.ump
  9. +4 −1 UmpleTToRubyUnit/UmpleTLTemplates/RubyUnitGenerator.ump
  10. +3 −3 UmpleTToRubyUnit/UmpleTLTemplates/depends.ump
  11. +12 −0 UmpleTToRubyUnit/UmpleTLTemplates/where_init.ump
  12. +45 −0 UmpleToTest/UmpleTLTemplates/association_ImmutableDirectedOptionalOneToMany.ump
  13. +38 −0 UmpleToTest/UmpleTLTemplates/association_ManyToOne.ump
  14. +28 −0 UmpleToTest/UmpleTLTemplates/association_ManyToOptionalOne.ump
  15. +24 −24 UmpleToTest/UmpleTLTemplates/association_NNToMany.ump
  16. +48 −34 UmpleToTest/UmpleTLTemplates/association_OneToMany.ump
  17. +16 −16 UmpleToTest/UmpleTLTemplates/association_OptionalNToMany.ump
  18. +0 −52 UmpleToTest/UmpleTLTemplates/association_immutableOneToMany.ump
  19. +25 −25 UmpleToTest/UmpleTLTemplates/association_optionlOneToMany.ump
  20. +29 −13 UmpleToTest/UmpleTLTemplates/members_AllAssociations.ump
  21. +1 −1 cruise.umple.test-parser/src/ump/Master.ump
  22. +2 −1 cruise.umple.test-parser/src/ump/TestCaseTemplate_model.ump
  23. +73 −3 cruise.umple.test-parser/src/ump/Utility.ump
  24. +118 −17 cruise.umple.test-parser/src/ump/mbt_parser_src.ump
  25. +2 −2 cruise.umple.test-parser/test/cruise/umple/testgenerator/jUnit/TestcaseTest.java.txt
  26. +2 −1 cruise.umple.test-parser/test/cruise/umple/testgenerator/jUnit/testGenerator_jUnit_testcase.umpt
  27. +366 −34 cruise.umple/src/Generator_CodeTest.ump
  28. +22 −0 cruise.umple/src/Umple.ump
  29. +29 −0 cruise.umple/test/cruise/umple/implementation/test/Airline/test/AirlineTest.umpt
  30. +40 −0 cruise.umple/test/cruise/umple/implementation/test/Airline/test/BookingTest.umpt
  31. +40 −0 cruise.umple/test/cruise/umple/implementation/test/Airline/test/EmployeeRoleTest.umpt
  32. +644 −0 ...mple/implementation/test/Airline/test/GenericTestCase_association_optionalOneToOne_ModelTest.umpt
  33. +40 −0 cruise.umple/test/cruise/umple/implementation/test/Airline/test/PassengerRoleTest.umpt
  34. +29 −0 cruise.umple/test/cruise/umple/implementation/test/Airline/test/PersonRoleTest.umpt
  35. +52 −0 cruise.umple/test/cruise/umple/implementation/test/Airline/test/PersonTest.umpt
  36. +46 −0 cruise.umple/test/cruise/umple/implementation/test/Airline/test/RegularFlightTest.umpt
  37. +34 −0 cruise.umple/test/cruise/umple/implementation/test/Airline/test/SpecificFlightTest.umpt
  38. +43 −24 cruise.umple/test/cruise/umple/implementation/test/GenericTestCase_association_optionalOneToOne.ump
  39. +1 −1 cruise.umple/test/cruise/umple/implementation/test/TestCaseAction.ump
  40. +2 −2 cruise.umple/test/cruise/umple/implementation/test/TestTemplateTest.java
  41. +76 −0 cruise.umple/test/cruise/umple/implementation/test/test/ATest.umpt
  42. +64 −0 cruise.umple/test/cruise/umple/implementation/test/test/BTest.umpt
  43. +44 −0 cruise.umple/test/cruise/umple/implementation/test/test/CalculatorTest.umpt
  44. +67 −0 cruise.umple/test/cruise/umple/implementation/test/test/ClassAssertionTest.umpt
  45. +23 −0 cruise.umple/test/cruise/umple/implementation/test/test/ClassAssertion_ModelTest.umpt
  46. +29 −0 cruise.umple/test/cruise/umple/implementation/test/test/ControllerTest.umpt
  47. +29 −0 cruise.umple/test/cruise/umple/implementation/test/test/CorporateClientTest.umpt
  48. +52 −0 cruise.umple/test/cruise/umple/implementation/test/test/CourseTest.umpt
  49. +23 −0 cruise.umple/test/cruise/umple/implementation/test/test/GenericTestCase_Integer_ModelTest.umpt
  50. +23 −0 cruise.umple/test/cruise/umple/implementation/test/test/GenericTestCase_ModelTest.umpt
  51. +23 −0 cruise.umple/test/cruise/umple/implementation/test/test/GenericTestCase_String_ModelTest.umpt
  52. +171 −0 cruise.umple/test/cruise/umple/implementation/test/test/GenericTestCase_association_ModelTest.umpt
  53. +83 −0 .../test/cruise/umple/implementation/test/test/GenericTestCase_association_manyToMany_ModelTest.umpt
  54. +83 −0 .../cruise/umple/implementation/test/test/GenericTestCase_association_manyToMany_RNav_ModelTest.umpt
  55. +171 −0 ...e/test/cruise/umple/implementation/test/test/GenericTestCase_association_oneToMany_ModelTest.umpt
  56. +171 −0 ...t/cruise/umple/implementation/test/test/GenericTestCase_association_oneToMany_RNav_ModelTest.umpt
  57. +171 −0 ...ruise/umple/implementation/test/test/GenericTestCase_association_optionalOneToMany_ModelTest.umpt
  58. +171 −0 .../umple/implementation/test/test/GenericTestCase_association_optionalOneToMany_RNav_ModelTest.umpt
  59. +119 −0 ...cruise/umple/implementation/test/test/GenericTestCase_association_optionalOneToOne_ModelTest.umpt
  60. +84 −0 ...e/umple/implementation/test/test/GenericTestCase_association_optionalOneToOne_RNav_ModelTest.umpt
  61. +113 −0 .../test/cruise/umple/implementation/test/test/GenericTestCase_association_toSingular_ModelTest.umpt
  62. +23 −0 ....umple/test/cruise/umple/implementation/test/test/GenericTestCase_attribute_prefix_ModelTest.umpt
  63. +23 −0 ...e.umple/test/cruise/umple/implementation/test/test/GenericTestCase_attribute_regex_ModelTest.umpt
  64. +23 −0 ....umple/test/cruise/umple/implementation/test/test/GenericTestCase_attribute_suffix_ModelTest.umpt
  65. +23 −0 cruise.umple/test/cruise/umple/implementation/test/test/GenericTestCase_method_ModelTest.umpt
  66. +40 −0 cruise.umple/test/cruise/umple/implementation/test/test/ImmutableATest.umpt
  67. +29 −0 cruise.umple/test/cruise/umple/implementation/test/test/IndividualStudentTest.umpt
  68. +40 −0 cruise.umple/test/cruise/umple/implementation/test/test/JobTest.umpt
  69. +47 −0 cruise.umple/test/cruise/umple/implementation/test/test/LazyATest.umpt
  70. +23 −0 cruise.umple/test/cruise/umple/implementation/test/test/LazyAttribute_ModelTest.umpt
  71. +29 −0 cruise.umple/test/cruise/umple/implementation/test/test/Level3Test.umpt
  72. +23 −0 cruise.umple/test/cruise/umple/implementation/test/test/MixsetTest_ModelTest.umpt
  73. +23 −0 ...mple/test/cruise/umple/implementation/test/test/MixsetTest_SameTestMultipleMixsets_ModelTest.umpt
  74. +23 −0 cruise.umple/test/cruise/umple/implementation/test/test/MixsetTest_action_ModelTest.umpt
  75. +23 −0 cruise.umple/test/cruise/umple/implementation/test/test/MixsetTest_multiple_ModelTest.umpt
  76. +83 −0 cruise.umple/test/cruise/umple/implementation/test/test/NNToManyAssociation_ModelTest.umpt
  77. +29 −0 cruise.umple/test/cruise/umple/implementation/test/test/NumberTest.umpt
  78. +113 −0 cruise.umple/test/cruise/umple/implementation/test/test/OneToManyAssociation_ModelTest.umpt
  79. +80 −0 cruise.umple/test/cruise/umple/implementation/test/test/OptionalOneToManyAssociation_ModelTest.umpt
  80. +29 −0 cruise.umple/test/cruise/umple/implementation/test/test/OrganizationTest.umpt
  81. +132 −0 cruise.umple/test/cruise/umple/implementation/test/test/PersonTest.umpt
  82. +40 −0 cruise.umple/test/cruise/umple/implementation/test/test/ScoreTest.umpt
  83. +82 −0 cruise.umple/test/cruise/umple/implementation/test/test/StudentTest.umpt
  84. +314 −0 cruise.umple/test/cruise/umple/implementation/test/test/TestCaseAction_ModelTest.umpt
  85. +23 −0 cruise.umple/test/cruise/umple/implementation/test/test/TestCaseAction_trait_ModelTest.umpt
  86. +23 −0 cruise.umple/test/cruise/umple/implementation/test/test/TestCase_AbstractTest_ModelTest.umpt
  87. +27 −0 cruise.umple/test/cruise/umple/implementation/test/test/TestCase_AnscestralTest_ModelTest.umpt
  88. +23 −0 cruise.umple/test/cruise/umple/implementation/test/test/TestSequence_noTestCases_ModelTest.umpt
  89. +23 −0 cruise.umple/test/cruise/umple/implementation/test/test/TraitAssertion_ModelTest.umpt
  90. +23 −0 ...e/test/cruise/umple/implementation/test/test/TraitAssertion_SameTestMultipleTraits_ModelTest.umpt
  91. +23 −0 cruise.umple/test/cruise/umple/implementation/test/test/TraitAssertion_multipleTraits_ModelTest.umpt
  92. +27 −0 cruise.umple/test/cruise/umple/implementation/test/test/attribute_ModelTest.umpt
  93. +23 −0 cruise.umple/test/cruise/umple/implementation/test/test/elseStatementTest_ModelTest.umpt
  94. +23 −0 cruise.umple/test/cruise/umple/implementation/test/test/ifElseStatementTest_ModelTest.umpt
  95. +23 −0 cruise.umple/test/cruise/umple/implementation/test/test/ifStatementTest_ModelTest.umpt
  96. +23 −0 cruise.umple/test/cruise/umple/implementation/test/test/immutableAttribute_ModelTest.umpt
  97. +87 −0 cruise.umple/test/cruise/umple/implementation/test/test/interfaceTest_ModelTest.umpt
  98. +85 −5 ...e/test/cruise/umple/implementation/test/testGenericTestcase_association_optionalOneToOne.test.txt
@@ -5,6 +5,7 @@ use where_init.ump;
use members_AllTestCases.ump;
use members_AllAssertions.ump;
use assertion_true.ump;
use depends.ump;



@@ -19,6 +20,7 @@ class JUnitGenerator {
depend java.util.*;
depend cruise.umple.testgenerator.*;
depend cruise.umple.testgenerator.Action;
depend cruise.umple.testgenerator.Depend;

isA ILang;

@@ -59,16 +61,19 @@ class JUnitGenerator {



<<#// if (uClass.numberOfComments() > 0) { if(!uClass.getComments().get(0).getIsInline()) {append(realSb, "\n{0}", Comment.format("Multiline",uClass.getComments()));} else { append(realSb, "\n{0}", Comment.format("Multiline",uClass.getComments()));} } #>>


import org.junit.*;

////---- Tests for <<=model.getFile()>>----/////


<<@UmpleTToJUnit.depends>>


public class <<=model.getFile().subSequence(0, model.getFile().length()-4)>>Test {


<<@UmpleTToJUnit.where_init >>
<<@UmpleTToJUnit.members_Setup >>
<<@UmpleTToJUnit.members_TearDown >>
@@ -1,4 +1,4 @@
class UmpleToTest {
class UmpleTToJUnit {
depends <<!<</*depends*/>><<#
/*
This file generates depends classes for test model
@@ -7,9 +7,9 @@ This file generates depends classes for test model
String depend;
isFirst = true;

for (String dep : aTestModel.getDepends())
for (Depend dep : model.getDepends())
{
appendln(realSb, "import {0};",dep)) ;
appendln(realSb, "import {0};",dep.getName()) ;
}
appendln(realSb,"");

@@ -15,7 +15,7 @@ members_AllAssertions <<!<</*members_AllAssertions*/>><<#

if(as.getType().equals("assertEqual"))
{#>>
Assert.assertEqual (<<=as.getAssertCode()>>);<<#}
Assert.assertEquals (<<=as.getAssertCode()>>);<<#}

if(as.getType().equals("assertNull"))
{#>>
@@ -5,6 +5,18 @@ This file generates initializations for classes in JUnit class
*/
isFirst = true;

if(model.hasTestInitializations())
{
for (TestInitialization init : model.getTestInitializations())
{

#>><<@UmpleTToJUnit.testcase_init>><<#

}


}



#>>!>>
@@ -3,6 +3,8 @@ use members_Setup.ump;
use members_TearDown.ump;
use where_init.ump;
use members_AllTestCases.ump;
use depends.ump;




@@ -17,6 +19,7 @@ class PhpUnitGenerator {
depend java.util.*;
depend cruise.umple.testgenerator.*;
depend cruise.umple.testgenerator.Action;
depend cruise.umple.testgenerator.Depend;

isA ILang;

@@ -60,9 +63,8 @@ class PhpUnitGenerator {
<<#// if (uClass.numberOfComments() > 0) { if(!uClass.getComments().get(0).getIsInline()) {append(realSb, "\n{0}", Comment.format("Multiline",uClass.getComments()));} else { append(realSb, "\n{0}", Comment.format("Multiline",uClass.getComments()));} } #>>

<?php

////---- Tests for <<=model.getFile()>>----/////

<<@UmpleTToPhpUnit.depends >>


class <<=model.getFile().subSequence(0, model.getFile().length()-4)>>Test extends UnitTestCase{
@@ -1,4 +1,4 @@
class UmpleToTest {
class UmpleTToPhpUnit {
depends <<!<</*depends*/>><<#
/*
This file generates depends classes for test model
@@ -7,9 +7,9 @@ This file generates depends classes for test model
String depend;
isFirst = true;

for (String dep : aTestModel.getDepends())
for (Depend dep : model.getDepends())
{
appendln(realSb, "import {0};",dep)) ;
appendln(realSb, "use {0};",dep.getName()) ;
}
appendln(realSb,"");

@@ -49,8 +49,12 @@ else{
{
if (act.getLocOrder() == i)
{
if(act.getName().equals("initAttMethodCall"))
{
act.setCode(act.getCode().replace(".","->"));
}
#>>
<<=act.getCode()>><<#
<<=act.getCode()>>;<<#
}

}
@@ -4,7 +4,17 @@ class UmpleTToPhpUnit {
This file generates initializations for classes in PhpUnit class
*/
isFirst = true;
if(model.hasTestInitializations())
{
for (TestInitialization init : model.getTestInitializations())
{

#>><<@UmpleTToPhpUnit.testcase_init>><<#

}


}


#>>!>>
@@ -5,6 +5,7 @@ use where_init.ump;
use members_AllTestCases.ump;
use members_AllAssertions.ump;
use testcase_init.ump;
use depends.ump;



@@ -19,6 +20,7 @@ class RubyUnitGenerator {
depend java.util.*;
depend cruise.umple.testgenerator.*;
depend cruise.umple.testgenerator.Action;
depend cruise.umple.testgenerator.Depend;

isA ILang;

@@ -62,13 +64,14 @@ class RubyUnitGenerator {
<<#// if (uClass.numberOfComments() > 0) { if(!uClass.getComments().get(0).getIsInline()) {append(realSb, "\n{0}", Comment.format("Multiline",uClass.getComments()));} else { append(realSb, "\n{0}", Comment.format("Multiline",uClass.getComments()));} } #>>

require 'test/unit'
<<@UmpleTToRubyUnit.depends>>

######---- Tests for <<=model.getFile()>> ----#####

module <<=model.getFile().subSequence(0, model.getFile().length()-4)+"Module">>

class <<=model.getFile().subSequence(0, model.getFile().length()-4)>>Test
<<@UmpleTToRubyUnit.where_init >>
<<@UmpleTToRubyUnit.where_init>>
<<@UmpleTToRubyUnit.members_Setup>>
<<@UmpleTToRubyUnit.members_TearDown>>
<<@UmpleTToRubyUnit.members_AllTestCases>>
@@ -1,4 +1,4 @@
class UmpleToTest {
class UmpleTToRubyUnit {
depends <<!<</*depends*/>><<#
/*
This file generates depends classes for test model
@@ -7,9 +7,9 @@ This file generates depends classes for test model
String depend;
isFirst = true;

for (String dep : aTestModel.getDepends())
for (Depend dep : model.getDepends())
{
appendln(realSb, "import {0};",dep)) ;
appendln(realSb, "require {0}",dep.getName()) ;
}
appendln(realSb,"");

@@ -4,5 +4,17 @@ class UmpleTToRubyUnit {
This file generates initializations for classes in RubyUnit class
*/
isFirst = true;

if(model.hasTestInitializations())
{
for (TestInitialization init : model.getTestInitializations())
{

#>><<@UmpleTToRubyUnit.testcase_init>><<#

}


}
#>>!>>
}
@@ -0,0 +1,45 @@

class UmpleToTest {
association_ImmutableDirectedOptionalOneToMany <<!<</*association_ImmutableDirectedOptionalOneToMany*/>><<#
/*
This file creates the necessary for Optional One To Many Association
*/


String buffName = "some" +uClass.getName();
String buffName2 = "some"+av.getRelatedAssociation().getUmpleClass().getName().getClassName();#>>
/////// Association: -- <<=av.getRelatedAssociation().getUmpleClass().getName().getMultiplicity().getRange()>> <<=av.getRelatedAssociation().getUmpleClass().getName().getClassName()>> ///////
//create ... without ...
test create<<=uClass.getName()>>Without<<=av.getRelatedAssociation().getUmpleClass().getName().getClassName()>> {
<<=uClass.getName()>> <<=buffName>> = new <<=uClass.getName()>>();
assertTrue (some<<=av.getRelatedAssociation().getUmpleClass().getName().getClassName()>>.get<<=av.getRelatedAssociation().getUmpleClass().getName().getRoleName().toUpperCase()>>()!= null);
}
//replace
<<#buffName = "some"+av.getRelatedAssociation().getUmpleClass().getName().getClassName();#>>



//delete
test Delete<<=av.getRelatedAssociation().getUmpleClass().getName().getClassName()>> {
// delete <<=av.getRelatedAssociation().getUmpleClass().getName().getClassName()>> in <<=uClass.getName()>>
<<=buffName>>2.delete();
assertEqual (null, <<=buffName>>2.get<<=av.getUmpleClass().getName().getClassName()>>(0));
}
//add to new B

test settable<<=av.getRelatedAssociation().getUmpleClass().getName().getClassName()>>ToNew<<=uClass.getName()>> {
<<=av.getRelatedAssociation().getUmpleClass().getName().getClassName()>> <<=buffName2>> = new <<=av.getRelatedAssociation().getUmpleClass().getName().getClassName()>>();
<<=av.getRelatedAssociation().getUmpleClass().getName().getClassName()>> <<=buffName2>>2 = new <<=av.getRelatedAssociation().getUmpleClass().getName().getClassName()>>();

<<=av.getUmpleClass().getName().getClassName()>> some<<=av.getUmpleClass().getName().getClassName()>> = new <<=av.getUmpleClass().getName().getClassName()>>();
<<=buffName>>.add<<=av.getRelatedAssociation().getUmpleClass().getName().getClassName()>>(some<<=av.getRelatedAssociation().getUmpleClass().getName().getClassName()>>);
<<=buffName>>.add<<=av.getRelatedAssociation().getUmpleClass().getName().getClassName()>>(some<<=av.getRelatedAssociation().getUmpleClass().getName().getClassName()>>2);

assertEqual(some<<=av.getRelatedAssociation().getUmpleClass().getName().getClassName()>>2, <<=buffName>>.get<<=av.getRelatedAssociation().getUmpleClass().getName().getClassName()>>();
assertEqual (<<=buffName>>, some<<=av.getRelatedAssociation().getUmpleClass().getName().getClassName()>>2.get<<=av.getUmpleClass().getName().getClassName()>>(0));
assertEqual (<<=buffName>>, some<<=av.getRelatedAssociation().getUmpleClass().getName().getClassName()>>.getNumberOf<<=av.getUmpleClass().getName().getClassName()>>s());
}<<#


#>>!>>
}
@@ -0,0 +1,38 @@
class UmpleToTest {
association_ManyToOne <<!<</*association_ManyToOne*/>><<#


String relatedAv = av.getRelatedAssociation().getUmpleClass().getName();
String buffName = "a" +uClass.getName();#>>

/////// Association: -- <<=av.getRelatedAssociation().getMultiplicity().getRange()>> <<=av.getRelatedAssociation().getUmpleClass().getName()>> ///////

test create<<=uClass.getName()>>With<<=av.getRelatedAssociation().getUmpleClass().getName()>> {
<<=gen.dependencyInjection(uClass)>>
<<=uClass.getName()>> <<=gen.initiateClass(uClass)>>;

assertTrue (a<<=uClass.getName()>>.get<<=av.getName()>>() == a<<=relatedAv>>);
}



test replace<<=relatedAv>>{

<<=gen.dependencyInjection(uClass)>>
<<=uClass.getName()>> b<<=gen.initiateClass(uClass)>>;

<<=gen.dependencyInjection(av.getRelatedAssociation().getUmpleClass())>>
<<=relatedAv>> b<<=gen.initiateClass(av.getRelatedAssociation().getUmpleClass())>>;

a<<=uClass.getName()>>.set<<=relatedAv>>(ba<<=relatedAv>>);

assertTrue (ba<<=relatedAv>> == a<<=uClass.getName()>>.get<<=relatedAv>>());


}


<<#

#>>!>>
}
@@ -0,0 +1,28 @@

class UmpleToTest {
association_ManyToOptionalOne <<!<</*association_ManyToOptionalOne*/>><<#
/*
This file creates the necessary for Optional One To Many Association
*/


String buffName = "a" +uClass.getName();
String buffName2 = "a"+av.getRelatedAssociation().getUmpleClass().getName();#>>
/////// Association: -- <<=av.getRelatedAssociation().getMultiplicity().getRange()>> <<=av.getRelatedAssociation().getUmpleClass().getName()>> ///////
//create ... without ...
test remove<<=av.getRelatedAssociation().getUmpleClass().getName()>> {
<<=gen.dependencyInjection(uClass)>>
<<=uClass.getName()>> <<=gen.initiateClass(uClass)>>;

<<=gen.dependencyInjection(av.getRelatedAssociation().getUmpleClass())>>
<<=av.getRelatedAssociation().getUmpleClass().getName()>> <<=gen.initiateClass(av.getRelatedAssociation().getUmpleClass())>>;
<<=buffName>>.add<<=av.getRelatedAssociation().getUmpleClass().getName()>>(<<=buffName2>>);
<<=buffName>>.remove<<=av.getRelatedAssociation().getUmpleClass().getName()>>(<<=buffName2>>);

assertTrue (a<<=av.getUmpleClass().getName()>>.get<<=av.getName()>>At(0) == null);
}



!>>
}

0 comments on commit ba0f76b

Please sign in to comment.
You can’t perform that action at this time.