Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
135 commits
Select commit Hold shift + click to select a range
2ef906d
WIP CDGen
luepges Feb 3, 2025
98c5eec
Document & TC
luepges Feb 4, 2025
7c6d7dc
Merge branch 'dev' of github.com-work:MontiCore/cd4analysis into cd2p…
luepges Feb 4, 2025
4820676
Add tests for the decorators
MisterErwin Feb 9, 2025
e8fe3bf
Add generated Setters for generated Builder classes
Hendrik7889 Feb 10, 2025
7aa9ce5
Seperate between build() and unsafeBuild()
Hendrik7889 Feb 10, 2025
4de4d0c
added seperate variables for methods
Hendrik7889 Feb 18, 2025
14a5355
added is valid clause in build method and added isValid and isAbsent …
Hendrik7889 Feb 18, 2025
e9686aa
comments
Hendrik7889 Feb 18, 2025
e6136f1
Mulitple fixes
Hendrik7889 Feb 21, 2025
9307483
Fixed lengthened error code, and added return type to setter methods
Hendrik7889 Feb 24, 2025
8ba088c
small fix and addition to the SetterDecorator
Hendrik7889 Feb 24, 2025
131f859
generate attributes and getter before checking for set method in pojo…
Hendrik7889 Feb 24, 2025
71cf70d
restructured build of build, unsafeBuild, isValid, and isAbsent methods
Hendrik7889 Feb 24, 2025
eb99766
fixed bug
Hendrik7889 Feb 24, 2025
a886f6c
fixed edgecase for attributes with no Setters
Hendrik7889 Mar 4, 2025
98dfb1f
added name check for setter detection
Hendrik7889 Mar 4, 2025
a2178c2
added TOP mechanism protection + tests
Hendrik7889 Mar 10, 2025
1bf08d0
set empty optional if optional is not present in unsafeBuild
Hendrik7889 Mar 17, 2025
f9b0a4e
fixed tests
Hendrik7889 Mar 17, 2025
218e1cd
adding observable interface to class
Hendrik7889 Mar 17, 2025
37ca4c5
add beginning for TOP-Mecanism tests
Hendrik7889 Mar 24, 2025
8598807
Merge branch 'dev' into cd2pojo-draft
Hendrik7889 Mar 27, 2025
562c3cc
complete merger and added
Hendrik7889 Mar 27, 2025
4848033
added tests
Hendrik7889 Mar 27, 2025
b312475
fixed 2 bugs in the build and unsafebuild methods and the setter in a…
Hendrik7889 Mar 30, 2025
f4e7ec3
refactor test
Hendrik7889 Mar 31, 2025
428f9a2
TODO init ObserverList
Hendrik7889 Apr 2, 2025
ec94969
added ObserverDecorator
Hendrik7889 Apr 2, 2025
6be1b24
Update BuilderDecoratorTest.java
Hendrik7889 Apr 2, 2025
2e5646a
improved BuilderDecoratorTest and reworked design choices in build an…
Hendrik7889 Apr 4, 2025
eb22e5f
BuilderDecorator improvements
Hendrik7889 Apr 7, 2025
3c18e17
Update BuilderDecoratorTest.java
Hendrik7889 Apr 7, 2025
fb04452
move dependency classes to correct directory
Hendrik7889 Apr 7, 2025
4272ee9
rename Observe into Observable
Hendrik7889 Apr 7, 2025
f27b3c2
ObserverDecorator: setter adjustment to inluce notifyObserver call
Hendrik7889 Apr 7, 2025
17013f7
finalize gradle horrors
Hendrik7889 Apr 7, 2025
1e815a1
final touch #1 😧
Hendrik7889 Apr 7, 2025
179a5de
Update CDGenGradlePluginTest.java
Hendrik7889 Apr 14, 2025
7907802
reorganize tests
Hendrik7889 Apr 14, 2025
ba8bff8
Update isValid.ftl
Hendrik7889 Apr 17, 2025
fe2a2f9
current progress
Hendrik7889 Apr 19, 2025
1dcb358
Update deepEquals3.ftl
Hendrik7889 Apr 19, 2025
47f42b6
Update DeepCloneAndDeepEqualsDecorator.java
Hendrik7889 Apr 19, 2025
42d8564
fix template bug
Hendrik7889 Apr 24, 2025
d63b839
deepEquals syntax
Hendrik7889 Apr 24, 2025
7f2bfd4
exchange all MCCollectionSymTypeRelations with CD4AnalysisTypeDispatc…
Hendrik7889 Apr 24, 2025
e424e8d
added basic test
Hendrik7889 Apr 24, 2025
911e460
correct error in 7f2bfd464a459c5d8af86e346df060dfa4a0de4a
Hendrik7889 Apr 24, 2025
9048a19
rename deepEqualsInner to deepEquals3Inner
Hendrik7889 Apr 24, 2025
2ccd206
add pre decorate visitor for collecting information about the classes…
Hendrik7889 Apr 24, 2025
219f6c5
fixed issues on english mashines as .hashCode() produces comma or dot…
Hendrik7889 Apr 25, 2025
608c168
Implement alternative approach for obtaining class diagram types
Hendrik7889 Apr 25, 2025
95ce861
mid impl
Hendrik7889 Apr 27, 2025
2e6b226
added test for deepEquals and correct errors
Hendrik7889 Apr 27, 2025
d4de357
finish deepEquals
Hendrik7889 Apr 27, 2025
7f0e9e7
bug with compositions maybe
Hendrik7889 Apr 28, 2025
2103ac7
change way in which types are resolved
Hendrik7889 Apr 28, 2025
4392031
cleanup and restructure tests
Hendrik7889 Apr 28, 2025
4f65a43
added null safety and circular test for deepEquals
Hendrik7889 Apr 28, 2025
3a753aa
added null checks in tests
Hendrik7889 Apr 28, 2025
0eced72
added tests for composition and association
Hendrik7889 Apr 28, 2025
6effeec
moved type resolving into a init method to reduce duplicate expensive…
Hendrik7889 Apr 29, 2025
bca046a
init deepClone
Hendrik7889 Apr 29, 2025
70b65f2
some minor changes before Holidays
Hendrik7889 Apr 29, 2025
fc45b40
added deepClone with stack overflow exception
Hendrik7889 Apr 30, 2025
958ba62
almost done
Hendrik7889 Apr 30, 2025
acc08e7
name correction and some
Hendrik7889 May 1, 2025
269f87c
added clarification and cleanuop
Hendrik7889 May 1, 2025
7e2833f
added tests
Hendrik7889 May 1, 2025
b273401
added default constructor for builder when it does not exist
Hendrik7889 May 2, 2025
4e9136f
removed builder dependency for deepEquals
Hendrik7889 May 2, 2025
962dbc6
sync
Hendrik7889 May 16, 2025
233944c
add String support
Hendrik7889 May 16, 2025
1029026
fixed optional deepCopy correctness
Hendrik7889 May 16, 2025
9fad9f9
added map correctness tests for the rest
Hendrik7889 May 16, 2025
435ee7d
init map deep equals
Hendrik7889 May 19, 2025
b68d2e0
fixed deepClone for optionals
Hendrik7889 May 20, 2025
5d1cf88
deepEquals Map added
Hendrik7889 May 20, 2025
0fdf9fe
reformatting
Hendrik7889 May 20, 2025
dd93f67
added deepClone beginning
Hendrik7889 May 20, 2025
2a6c76e
added Map tests
Hendrik7889 May 23, 2025
0f61d6a
mid
Hendrik7889 May 23, 2025
064d106
Update deepEquals3Inner.ftl
Hendrik7889 May 23, 2025
9bf5a07
deepEquals finished
Hendrik7889 May 24, 2025
24de390
finished deepClone
Hendrik7889 May 24, 2025
687f65f
Merge branch 'dev' into cd2pojo-draft
Hendrik7889 May 24, 2025
6de5de7
fixed errors
Hendrik7889 May 24, 2025
3236cf1
added comment
Hendrik7889 May 24, 2025
9a37273
added top mecanism to abstract test to fix bug and fixed file structure
Hendrik7889 May 26, 2025
439a9ac
swapped datasrtucture of visitedObjects from set to map with a set to…
Hendrik7889 May 26, 2025
4db6aa0
added test for deepEquals with duplicated attribute references but di…
Hendrik7889 May 26, 2025
08b5bfa
separate tests into own methods
Hendrik7889 May 26, 2025
8c728fc
todo: sort other tests
Hendrik7889 May 26, 2025
776a732
update documentation
Hendrik7889 May 26, 2025
c11469e
Removed unnecessary boolean in map for deepClone.
Hendrik7889 May 28, 2025
181a08d
finishing touches
Hendrik7889 May 28, 2025
126012b
Merge branch 'dev' into cd2pojo-draft
Hendrik7889 Jun 2, 2025
d9fc930
rearranged but i get the cd parser errors
Hendrik7889 Jun 2, 2025
ec87d09
actively remove Logs to ensure tests pass as WIP is logged
Hendrik7889 Jun 2, 2025
2cf1262
updated top mechanism and builderDecoration improvement
Hendrik7889 Jun 2, 2025
dee48bb
conform naming sheme
Hendrik7889 Jun 2, 2025
f520302
Merge remote-tracking branch 'origin/dev' into cd2pojo-draft
luepges Jun 4, 2025
ec02e94
format
luepges Jun 4, 2025
dc66db9
document gradle
luepges Jun 4, 2025
2f3cdcd
cleanup format
luepges Jun 4, 2025
a63863d
add the attributes logic to the visit(ASTAttribute node) method
Hendrik7889 Jun 5, 2025
5fd1f84
apply spotless formatting
Hendrik7889 Jun 5, 2025
bb96145
Merge branch 'dev' into cd2pojo-draft
Hendrik7889 Jun 6, 2025
e35565e
sync
Hendrik7889 Jun 17, 2025
c8a65db
add addTraversedElementMethod
Hendrik7889 Jun 17, 2025
3ebeaf7
finished Visitor Decorator
Hendrik7889 Jun 21, 2025
0395716
spotlessApply VisitorDecoratorResultTest
Hendrik7889 Jun 21, 2025
71ab174
fixed MyCD cd to allow for deletion of the makeMethodsInInterfacesAbs…
Hendrik7889 Jun 21, 2025
5387279
Merge pull request #51 from MontiCore/cd2pojo-draft-Visitor
Hendrik7889 Jun 21, 2025
70ad5b6
Merge branch 'dev' into cd2pojo-draft
Hendrik7889 Jun 21, 2025
f3ad21c
Merge remote-tracking branch 'origin/dev' into cd2pojo-draft
luepges Jul 2, 2025
0aed51f
initialize Tags mill for lookups
luepges Jul 2, 2025
8f949d9
fix layout
luepges Jul 8, 2025
adf3a56
added enum and interface types
Hendrik7889 Jul 13, 2025
aa753dc
Fix: Address null handling issues after instanceof removal
Hendrik7889 Jul 13, 2025
94fa093
deepClone uses Builder if it is created
Hendrik7889 Jul 24, 2025
d07097a
issues with resolving attributes from interfaces and inheritanced cla…
Hendrik7889 Jul 24, 2025
aea80ce
Inheritance for deepEqualsAndDeepCloneDecorator and BuilderDEcorator
Hendrik7889 Jul 24, 2025
d62940b
Merge branch 'dev' into cd2pojo-draft
Hendrik7889 Jul 24, 2025
f81c665
removed duplication of getAllSuperClassesTransitive
Hendrik7889 Jul 25, 2025
6b3f249
spotlessApply
Hendrik7889 Jul 25, 2025
3ab3815
Update DeepCloneAndDeepEqualsDecoratorTest.java
Hendrik7889 Jul 28, 2025
2d5319e
Added InheritanceVisitorDecorator
Hendrik7889 Jul 29, 2025
6065de1
no clue what i am actually doing here
Hendrik7889 Jul 29, 2025
a978548
comments and spotlessa apply
Hendrik7889 Jul 30, 2025
594dfd6
Merge branch 'dev' into cd2pojo-draft
Hendrik7889 Aug 5, 2025
025854a
Update DecoratorConfig.java
Hendrik7889 Aug 5, 2025
2564cb7
improved getUpperInterfacesAndSuperClasses
Hendrik7889 Aug 5, 2025
e0b6488
needed changes for the DefaultCD2PojoDecoratorTest
Hendrik7889 Aug 5, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions cdlang/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,13 @@ sourceSets {
cdGenIntTest {
// Include target/cdGenOutTest/** as src dirs (which are generated by the CDGenTests)
java.srcDirs(() -> project.layout.buildDirectory.dir("cdGenOutTest").get().asFile.listFiles())
// Include src/cdGenIntTestHwc/java as a src dir (to test the TOP mechanism)
java.srcDirs(file('src/cdGenIntTestHwc/java'))
}
}
tasks.named('generateCdGenIntTestMCGrammars') {
dependsOn tasks.named('test')
}
dependencies {
cdGenIntTestImplementation "org.junit.jupiter:junit-jupiter:$junit_version"
cdGenIntTestRuntimeOnly 'org.junit.platform:junit-platform-launcher'
Expand Down
678 changes: 678 additions & 0 deletions cdlang/src/cdGenIntTest/java/builder/BuilderDecoratorResultTest.java

Large diffs are not rendered by default.

Large diffs are not rendered by default.

228 changes: 228 additions & 0 deletions cdlang/src/cdGenIntTest/java/observer/ObserverDecoratorResultTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,228 @@
/* (c) https://github.com/MontiCore/monticore */
package observer;

import TestObserver.B;
import TestObserver.IOtherCObservable;
import TestObserver.IOtherCObserver;
import TestObserver.OtherC;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.*;

/**
* Test the result of the Getter Decorator.
*/
public class ObserverDecoratorResultTest {

@Test
public void test() throws Exception {
checkClassAndMethodExistence();

TestObserver.Observer observer = new TestObserver.Observer();
TestObserver.Observer observer2 = new TestObserver.Observer();

OtherC pojo = new OtherC();
pojo.addObserver(observer);
pojo.addObserver(observer2);

B b = new B();
Set<B> set = new HashSet<>(Set.of(b));

//check if notify methods are implemented correctly
Assertions.assertEquals(0, observer.getCountUpdateObserver());
Assertions.assertEquals(0, observer2.getCountUpdateObserver());
pojo.notifyObserverMyBool(pojo, true);
Assertions.assertEquals(1, observer.getCountUpdateObserverMyBool());
Assertions.assertEquals(1, observer2.getCountUpdateObserverMyBool());

Assertions.assertEquals(0, observer.getCountUpdateObserverMyInt());
Assertions.assertEquals(0, observer2.getCountUpdateObserverMyInt());
pojo.notifyObserverMyInt(pojo, 42);
Assertions.assertEquals(1, observer.getCountUpdateObserverMyInt());
Assertions.assertEquals(1, observer2.getCountUpdateObserverMyInt());

Assertions.assertEquals(0, observer.getCountUpdateObserverManyB());
Assertions.assertEquals(0, observer2.getCountUpdateObserverManyB());
pojo.notifyObserverManyB(pojo, set);
Assertions.assertEquals(1, observer.getCountUpdateObserverManyB());
Assertions.assertEquals(1, observer2.getCountUpdateObserverManyB());

Assertions.assertEquals(0, observer.getCountUpdateObserverOptB());
Assertions.assertEquals(0, observer2.getCountUpdateObserverOptB());
pojo.notifyObserverOptB(pojo, Optional.of(b));
Assertions.assertEquals(1, observer.getCountUpdateObserverOptB());
Assertions.assertEquals(1, observer2.getCountUpdateObserverOptB());

Assertions.assertEquals(0, observer.getCountUpdateObserverOneB());
Assertions.assertEquals(0, observer2.getCountUpdateObserverOneB());
pojo.notifyObserverOneB(pojo, b);
Assertions.assertEquals(1, observer.getCountUpdateObserverOneB());
Assertions.assertEquals(1, observer2.getCountUpdateObserverOneB());

Assertions.assertEquals(0, observer.getCountUpdateObserver());
Assertions.assertEquals(0, observer2.getCountUpdateObserver());
pojo.notifyObservers(pojo);
Assertions.assertEquals(1, observer.getCountUpdateObserver());
Assertions.assertEquals(1, observer2.getCountUpdateObserver());

//check if setters are implemented correctly
pojo.setMyInt(42);
Assertions.assertEquals(2, observer.getCountUpdateObserverMyInt());
Assertions.assertEquals(2, observer2.getCountUpdateObserverMyInt());

pojo.setMyBool(true);
Assertions.assertEquals(2, observer.getCountUpdateObserverMyBool());
Assertions.assertEquals(2, observer2.getCountUpdateObserverMyBool());

pojo.setManyB(new HashSet<>());
Assertions.assertEquals(2, observer.getCountUpdateObserverManyB());
Assertions.assertEquals(2, observer2.getCountUpdateObserverManyB());

pojo.setOptB(null);
Assertions.assertEquals(2, observer.getCountUpdateObserverOptB());
Assertions.assertEquals(2, observer2.getCountUpdateObserverOptB());

pojo.setOneB(null);
Assertions.assertEquals(2, observer.getCountUpdateObserverOneB());
Assertions.assertEquals(2, observer2.getCountUpdateObserverOneB());

//check if removeObserver works
pojo.removeObserver(observer);

pojo.setMyBool(false);
Assertions.assertEquals(2, observer.getCountUpdateObserverMyBool());
Assertions.assertEquals(3, observer2.getCountUpdateObserverMyBool());

pojo.removeObserver(observer2);

pojo.setMyBool(false);
Assertions.assertEquals(2, observer.getCountUpdateObserverMyBool());
Assertions.assertEquals(3, observer2.getCountUpdateObserverMyBool());
}

/**
* Check for the existence of the interfaces and the methods in the interfaces as well as in the
* pojo
* We check for the following:
* Class: TestObserver.IOtherCObservable with methods notify and notify${attributeName} and
* addObserver and removeObserver
* Class: TestObserver.OtherC with methods notify and notify${attributeName} and addObserver and
* removeObserver
* Class: TestObserver.IOtherCObserver with methods update and update${attributeName}
* Method: TestObserver.IOtherCObservable
*
* @throws Exception when the class or method does not exist
*/
@Test
public void checkClassAndMethodExistence() throws Exception {
//check for the existence of the interfaces
Class<?> interfaceObservable = Class.forName("TestObserver.IOtherCObservable");
Assertions.assertTrue(Modifier.isPublic(interfaceObservable.getModifiers()));
Assertions.assertTrue(interfaceObservable.isInterface());

Class<?> interfaceObserver = Class.forName("TestObserver.IOtherCObserver");
Assertions.assertTrue(Modifier.isPublic(interfaceObserver.getModifiers()));
Assertions.assertTrue(interfaceObserver.isInterface());

Class<?> clazz = Class.forName("TestObserver.OtherC");
Assertions.assertTrue(Modifier.isPublic(clazz.getModifiers()));
Assertions.assertFalse(clazz.isInterface());

//check for the methods in the interface Observe
Method[] methods = interfaceObservable.getDeclaredMethods();
Assertions.assertEquals(9, methods.length);

//check methods of the pojo
Method addObserver = IOtherCObservable.class.getDeclaredMethod("addObserver",
TestObserver.IOtherCObserver.class);
Assertions.assertTrue(Modifier.isPublic(addObserver.getModifiers()));

Method removeObserver = IOtherCObservable.class.getDeclaredMethod("removeObserver",
TestObserver.IOtherCObserver.class);
Assertions.assertTrue(Modifier.isPublic(removeObserver.getModifiers()));

Method notifyObservers = IOtherCObservable.class.getDeclaredMethod("notifyObservers",
OtherC.class);
Assertions.assertTrue(Modifier.isPublic(notifyObservers.getModifiers()));

Method notifyObserverInt = IOtherCObservable.class.getDeclaredMethod("notifyObserverMyInt",
OtherC.class, int.class);
Assertions.assertTrue(Modifier.isPublic(notifyObserverInt.getModifiers()));

Method notifyObserverBoolean = IOtherCObservable.class.getDeclaredMethod("notifyObserverMyBool",
OtherC.class, boolean.class);
Assertions.assertTrue(Modifier.isPublic(notifyObserverBoolean.getModifiers()));

Method notifyObserverSet = IOtherCObservable.class.getDeclaredMethod("notifyObserverManyB",
OtherC.class, Set.class);
Assertions.assertTrue(Modifier.isPublic(notifyObserverSet.getModifiers()));

Method notifyObserverOptional = IOtherCObservable.class.getDeclaredMethod("notifyObserverOptB",
OtherC.class, Optional.class);
Assertions.assertTrue(Modifier.isPublic(notifyObserverOptional.getModifiers()));

Method notifyObserverB = IOtherCObservable.class.getDeclaredMethod("notifyObserverOneB",
OtherC.class, B.class);
Assertions.assertTrue(Modifier.isPublic(notifyObserverB.getModifiers()));

//check for the methods in the interface Observe
Method notifyPojoAddObserver = OtherC.class.getDeclaredMethod("addObserver",
TestObserver.IOtherCObserver.class);
Assertions.assertTrue(Modifier.isPublic(notifyPojoAddObserver.getModifiers()));

Method notifyPojoRemoveObserver = OtherC.class.getDeclaredMethod("removeObserver",
TestObserver.IOtherCObserver.class);
Assertions.assertTrue(Modifier.isPublic(notifyPojoRemoveObserver.getModifiers()));

Method notifyPojoNotifyObservers = OtherC.class.getDeclaredMethod("notifyObservers",
OtherC.class);
Assertions.assertTrue(Modifier.isPublic(notifyPojoNotifyObservers.getModifiers()));

Method notifyPojoNotifyObserverInt = OtherC.class.getDeclaredMethod("notifyObserverMyInt",
OtherC.class, int.class);
Assertions.assertTrue(Modifier.isPublic(notifyPojoNotifyObserverInt.getModifiers()));

Method notifyPojoNotifyObserverBoolean = OtherC.class.getDeclaredMethod("notifyObserverMyBool",
OtherC.class, boolean.class);
Assertions.assertTrue(Modifier.isPublic(notifyPojoNotifyObserverBoolean.getModifiers()));

Method notifyPojoNotifyObserverSet = OtherC.class.getDeclaredMethod("notifyObserverManyB",
OtherC.class, Set.class);
Assertions.assertTrue(Modifier.isPublic(notifyPojoNotifyObserverSet.getModifiers()));

Method notifyPojoNotifyObserverOptional = OtherC.class.getDeclaredMethod("notifyObserverOptB",
OtherC.class, Optional.class);
Assertions.assertTrue(Modifier.isPublic(notifyPojoNotifyObserverOptional.getModifiers()));

Method notifyPojoNotifyObserverB = OtherC.class.getDeclaredMethod("notifyObserverOneB",
OtherC.class, B.class);
Assertions.assertTrue(Modifier.isPublic(notifyPojoNotifyObserverB.getModifiers()));

//check for the methods in the interface Observer
Method update = IOtherCObserver.class.getDeclaredMethod("update", OtherC.class);
Assertions.assertTrue(Modifier.isPublic(update.getModifiers()));

Method updateObserverMyInt = IOtherCObserver.class.getDeclaredMethod("updateObserverMyInt",
OtherC.class, int.class);
Assertions.assertTrue(Modifier.isPublic(updateObserverMyInt.getModifiers()));

Method updateObserverMyBool = IOtherCObserver.class.getDeclaredMethod("updateObserverMyBool",
OtherC.class, boolean.class);
Assertions.assertTrue(Modifier.isPublic(updateObserverMyBool.getModifiers()));

Method updateObserverManyB = IOtherCObserver.class.getDeclaredMethod("updateObserverManyB",
OtherC.class, Set.class);
Assertions.assertTrue(Modifier.isPublic(updateObserverManyB.getModifiers()));

Method updateObserverOptB = IOtherCObserver.class.getDeclaredMethod("updateObserverOptB",
OtherC.class, Optional.class);
Assertions.assertTrue(Modifier.isPublic(updateObserverOptB.getModifiers()));

Method updateObserverOneB = IOtherCObserver.class.getDeclaredMethod("updateObserverOneB",
OtherC.class, B.class);
Assertions.assertTrue(Modifier.isPublic(updateObserverOneB.getModifiers()));
}

}
Loading
Loading