Skip to content
Permalink
Browse files
[TestGeneration] Adding the following updates:
  • Loading branch information
SultanEid committed Mar 16, 2020
1 parent a99b37f commit ba0f76b95d3108e6c017f4f2f7740b84297a365c
Show file tree
Hide file tree
Showing 98 changed files with 5,442 additions and 270 deletions.
@@ -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.