From a0071cd8a5098c47beb3a8305511c2f95a384e68 Mon Sep 17 00:00:00 2001 From: anquetil Date: Sun, 17 Nov 2024 13:09:22 +0100 Subject: [PATCH] added more tests switched to JavaModel to check Parametrics --- ...ndencyStructuralMatrixBrowserTest.class.st | 54 +++++++++++++++++-- 1 file changed, 50 insertions(+), 4 deletions(-) diff --git a/src/MooseIDE-Tests/MiDependencyStructuralMatrixBrowserTest.class.st b/src/MooseIDE-Tests/MiDependencyStructuralMatrixBrowserTest.class.st index 438214e2..646ef84b 100644 --- a/src/MooseIDE-Tests/MiDependencyStructuralMatrixBrowserTest.class.st +++ b/src/MooseIDE-Tests/MiDependencyStructuralMatrixBrowserTest.class.st @@ -34,8 +34,9 @@ MiDependencyStructuralMatrixBrowserTest >> setUp [ | mth1 mth2 | super setUp. - - model := FamixStModel new. + + "Note: need to be a Java model to test ParametricEntities" + model := FamixJavaModel new. class1 := model newClassNamed: 'Class1'. class2 := model newClassNamed: 'Class2'. class3 := model newClassNamed: 'Class3'. @@ -118,11 +119,26 @@ MiDependencyStructuralMatrixBrowserTest >> testOutgoingDependencyFromInvocation dependencies := class1 methods anyOne queryAllOutgoingForDSM. self assert: dependencies size equals: 1. - self assert: dependencies anyOne class equals: FamixStInvocation. + self assert: dependencies anyOne class equals: FamixJavaInvocation. self assert: dependencies anyOne candidates anyOne name equals: 'mth2'. ] +{ #category : #tests } +MiDependencyStructuralMatrixBrowserTest >> testOutgoingDependencyFromMethodDeclaredType [ + + | mth2 dependencies | + mth2 := class2 methods anyOne. + mth2 declaredType: class3. + + dependencies := mth2 queryAllOutgoingForDSM. + + self assert: dependencies size equals: 1. + self assert: dependencies anyOne class equals: FamixJavaClass. + self assert: dependencies anyOne name equals: 'Class3'. + +] + { #category : #tests } MiDependencyStructuralMatrixBrowserTest >> testOutgoingDependencyFromVariableDeclaredType [ @@ -135,11 +151,41 @@ MiDependencyStructuralMatrixBrowserTest >> testOutgoingDependencyFromVariableDec dependencies := mth2 queryAllOutgoingForDSM. self assert: dependencies size equals: 1. - self assert: dependencies anyOne class equals: FamixStClass. + self assert: dependencies anyOne class equals: FamixJavaClass. self assert: dependencies anyOne name equals: 'Class3'. ] +{ #category : #tests } +MiDependencyStructuralMatrixBrowserTest >> testOutgoingDependencyFromVariableDeclaredTypeParametric [ + "code: + Class2 + mth2 + ParametricClass local2 + Note: FamixJavaConcretization is an association and we are not interested in its genericEntity here + Note: hueristic to detect a concreteParameter being a genuine class is to check it has children + That's why we use Class1 and not Class3 as concreteParameter" + + | mth2 parametricClass dependencies | + parametricClass := model newParametricClass + name: 'ParametricClass' ; + genericization: model newConcretization ; + addConcreteParameter: class1 ; + yourself. + + mth2 := class2 methods anyOne. + (model newLocalVariableNamed: 'local2') + parentBehaviouralEntity: mth2 ; + declaredType: parametricClass. + + dependencies := mth2 queryAllOutgoingForDSM. + + self assert: dependencies size equals: 2. + dependencies do: [ :dep | + { 'ParametricClass' . 'Class1' } includes: dep name + ] +] + { #category : #tests } MiDependencyStructuralMatrixBrowserTest >> testTitleOfDSM [